Skip to content

Commit

Permalink
Merge branch 'master' into storage
Browse files Browse the repository at this point in the history
  • Loading branch information
ealmloff committed Mar 27, 2024
2 parents 9e4e53b + 191a66b commit e1ad3ab
Show file tree
Hide file tree
Showing 40 changed files with 321 additions and 251 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ jobs:
clippy:
if: github.event.pull_request.draft == false
name: Clippy
runs-on: ubuntu-latest
runs-on: windows-latest
steps:
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: sudo apt-get update
- run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev
- run: rustup target add wasm32-unknown-unknown
- run: rustup component add clippy
- uses: actions/checkout@v3
- run: cargo clippy --workspace --examples --tests --features clipboard,notifications,utils,i18n,storage -- -D warnings
- run: cargo clippy --package dioxus-std --target wasm32-unknown-unknown --tests --features wasm-testing -- -D warnings
- run: cargo clippy --package dioxus-std --tests --features desktop-testing -- -D warnings
6 changes: 3 additions & 3 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v3
- run: rustup target add wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
- run: cargo build --verbose --target wasm32-unknown-unknown --no-default-features --features wasm-testing
- run: cargo build --package dioxus-std --verbose --target wasm32-unknown-unknown --no-default-features --features wasm-testing
# need to run tests here

desktop:
Expand All @@ -29,5 +29,5 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- run: cargo build --verbose --no-default-features --features desktop-testing
- run: cargo test --verbose --no-default-features --features desktop-testing
- run: cargo build --package dioxus-std --verbose --no-default-features --features desktop-testing
- run: cargo test --package dioxus-std --verbose --no-default-features --features desktop-testing
9 changes: 3 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"rust-analyzer.cargo.features": [
"clipboard",
"geolocation",
"utils",
"i18n"
"desktop-testing"
],
//"rust-analyzer.check.allTargets": true,
}
"rust-analyzer.cargo.extraArgs": ["--exclude=color_scheme"]
}
93 changes: 9 additions & 84 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,84 +1,9 @@
[package]
name = "dioxus-std"
version = "0.4.0"
authors = ["Jonathan Kelley", "Dioxus Labs", "ealmloff", "DogeDark"]
edition = "2021"
description = "Platform agnostic library for supercharging your productivity with Dioxus"
license = "MIT"
repository = "https://github.com/DioxusLabs/dioxus-std/"
homepage = "https://dioxuslabs.com"
keywords = ["dom", "gui", "dioxus", "standard", "hooks"]
categories = ["multimedia","os", "wasm"]

# This is making it harder to develop for a specific platform when examples are different targets.
# Workaround: Open example project as it's own project.
#[workspace]
#members = ["./examples/*"]

[features]
clipboard = ["dep:copypasta"]
notifications = ["dep:notify-rust"]
geolocation = ["dep:windows", "dep:futures-util", "dep:futures", "dep:web-sys", "dep:wasm-bindgen", "utils"]
color_scheme = ["dep:web-sys", "dep:wasm-bindgen", "dep:wasm-bindgen-futures"]
utils = ["dep:async-broadcast", "dep:uuid"]
i18n = ["dep:serde", "dep:serde_json", "dep:unic-langid"]
storage = ["dep:dioxus-signals", "dep:serde", "dep:postcard", "dep:once_cell", "dep:web-sys", "web-sys/Document", "web-sys/Element", "web-sys/HtmlDocument", "web-sys/Storage", "dep:wasm-bindgen", "dep:wasm-bindgen-futures", "dep:directories", "dep:yazi", "dep:tokio"]
all = ["clipboard", "notifications", "geolocation", "color_scheme", "utils", "i18n", "storage"]
default = []

# CI testing
wasm-testing = ["geolocation", "color_scheme", "utils", "i18n", "storage"]
desktop-testing = ["clipboard", "notifications", "geolocation", "utils", "i18n", "storage"]

[dependencies]
dioxus = { git = "https://github.com/DioxusLabs/dioxus.git", rev = "647815fa6f6db2304cda5bd36c78b4f8b0379f39" }
cfg-if = "1.0.0"

# utils
uuid = { version = "1.3.2", features = ["v4"], optional = true }
async-broadcast = { version = "0.5.1", optional = true }
# clipboard
copypasta = { version = "0.8.2", optional = true }
# notifications
notify-rust = { version = "4.8.0", optional = true }
# geolocation
futures = { version = "0.3.28", features = ["std"], optional = true }
futures-util = {version = "0.3.28", optional = true }
# i18n
serde = { version = "1.0.163", optional = true }
serde_json = { version = "1.0.96", optional = true }
unic-langid = { version = "0.9.1", features = ["serde"], optional = true }
# storage
rustc-hash = "1.1.0"
postcard = { version = "1.0.2", features = ["use-std"], optional = true }
once_cell = { version = "1.17.0", optional = true }
dioxus-signals = { git = "https://github.com/DioxusLabs/dioxus.git", rev = "647815fa6f6db2304cda5bd36c78b4f8b0379f39", features = [
"serialize",
], optional = true }
tokio = { version = "1.33.0", features = ["sync"], optional = true }
yazi = { version = "0.1.4", optional = true }
log = "0.4.6"

# WebAssembly Debug
wasm-logger = "0.2.0"
console_error_panic_hook = "0.1.7"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
directories = { version = "4.0.1", optional = true }

[target.'cfg(windows)'.dependencies]
windows = { version = "0.48.0", features = ["Foundation", "Devices_Geolocation"], optional = true }

[target.'cfg(target_family = "wasm")'.dependencies]
web-sys = { version = "0.3.60", features = ["Window", "MediaQueryList", "Navigator", "Geolocation", "PositionOptions", "EventTarget", "EventListener", "StorageEvent"], optional = true }
wasm-bindgen = { version = "0.2.87", optional = true }
wasm-bindgen-futures = { version = "0.4.35", optional = true}
js-sys = "0.3.62"
# channel
uuid = { version = "1.3.2", features = ["v4", "js"]}

[package.metadata.docs.rs]
default-target = "x86_64-pc-windows-msvc"
no-default-features = true
features = ["desktop-testing"]

[workspace]
resolver = "2"
members = [
"std",
"examples/*",
]

[workspace.dependencies]
dioxus-std = { path = "./std"}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ sudo apt-get install xorg-dev
You can add `dioxus-std` to your application by adding it to your dependencies.
```toml
[dependencies]
dioxus-std = { version = "0.4.0", features = [] }
dioxus-std = { version = "0.4.2", features = [] }
```

## License
Expand Down
3 changes: 3 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ Learn how to use the `channel` abstraction.

### [`storage`](./storage/)
Learn how to use the `storage` abstraction.

### [`clipboard`](./clipboard/)
Learn how to use the `clipboard` abstraction.
2 changes: 1 addition & 1 deletion examples/channel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
dioxus-std = { path="../../", features = ["utils"] }
dioxus-std = { workspace = true, features = ["utils"]}
dioxus = "0.4"
dioxus-web = "0.4"

Expand Down
4 changes: 2 additions & 2 deletions examples/channel/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ fn main() {
fn app(cx: Scope) -> Element {
let channel = use_channel::<String>(cx, 5);

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

let send = move |_: MouseEvent| {
let send = |_: MouseEvent| {
to_owned![channel];
async move {
channel.send("Hello").await.ok();
Expand Down
9 changes: 9 additions & 0 deletions examples/clipboard/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "clipboard"
version = "0.1.0"
edition = "2021"

[dependencies]
dioxus-std = { workspace = true, features = ["clipboard"] }
dioxus = "0.4"
dioxus-desktop = "0.4"
46 changes: 46 additions & 0 deletions examples/clipboard/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
use dioxus::prelude::*;
use dioxus_std::clipboard::use_clipboard;

fn main() {
dioxus_desktop::launch(app);
}

fn app(cx: Scope) -> Element {
let clipboard = use_clipboard(cx);
let text = use_state(cx, String::new);

let oninput = |e: FormEvent| {
text.set(e.data.value.clone());
};

let oncopy = {
to_owned![clipboard];
move |_| match clipboard.set(text.get().clone()) {
Ok(_) => println!("Copied to clipboard: {}", text.get()),
Err(err) => println!("Error on copy: {err:?}"),
}
};

let onpaste = move |_| match clipboard.get() {
Ok(contents) => {
println!("Pasted from clipboard: {contents}");
text.set(contents);
}
Err(err) => println!("Error on paste: {err:?}"),
};

render!(
input {
oninput: oninput,
value: "{text}"
}
button {
onclick: oncopy,
"Copy"
}
button {
onclick: onpaste,
"Paste"
}
)
}
2 changes: 1 addition & 1 deletion examples/color_scheme/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
dioxus-std = { path="../../", features = ["color_scheme"] }
dioxus-std = { workspace = true, features = ["color_scheme"] }
dioxus = "0.4"
dioxus-web = "0.4"

Expand Down
2 changes: 1 addition & 1 deletion examples/geolocation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
dioxus-std = { path="../../", features = ["geolocation"] }
dioxus-std = { workspace = true, features = ["geolocation"] }
dioxus = "0.4"
dioxus-desktop = "0.4"
#dioxus-web = "0.4"
6 changes: 2 additions & 4 deletions examples/geolocation/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use dioxus::prelude::*;
use dioxus_std::geolocation::{
init_geolocator, use_geolocation, PowerMode
};
use dioxus_std::geolocation::{init_geolocator, use_geolocation, PowerMode};

fn main() {
dioxus_desktop::launch(app);
Expand Down Expand Up @@ -34,7 +32,7 @@ fn app(cx: Scope) -> Element {
h1 { "🗺️ Dioxus Geolocation Example 🛰️" }
h3 { "Your initial location is:"}

p {
p {
if let Some(coords) = initial_coords {
format!("Latitude: {} | Longitude: {}", coords.latitude, coords.longitude)
} else {
Expand Down
2 changes: 1 addition & 1 deletion examples/i18n/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
dioxus-std = { path="../../", features = ["i18n"] }
dioxus-std = { workspace = true, features = ["i18n"] }
dioxus = "0.4"
dioxus-web = "0.4"

Expand Down
100 changes: 0 additions & 100 deletions src/clipboard/mod.rs

This file was deleted.

Loading

0 comments on commit e1ad3ab

Please sign in to comment.