diff --git a/Cargo.toml b/Cargo.toml index 9e3aa52..127c596 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,20 +16,20 @@ 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-rc.1" } +dioxus-time = { path = "packages/time", version = "0.7.0-rc.1" } +dioxus_storage = { path = "packages/storage", version = "0.7.0-rc.1" } +dioxus-geolocation = { path = "packages/geolocation", version = "0.7.0-rc.1" } +dioxus-notification = { path = "packages/notification", version = "0.7.0-rc.1" } +dioxus-sync = { path = "packages/sync", version = "0.7.0-rc.1" } +dioxus-util = { path = "packages/util", version = "0.7.0-rc.1" } +dioxus-window = { path = "packages/window", version = "0.7.0-rc.1" } # Dioxus -dioxus = "0.6.0" -dioxus-signals = "0.6.0" -dioxus-desktop = "0.6.0" -dioxus-config-macro = "0.6.0" +dioxus = "^0.7.0-rc.1" +dioxus-signals = "^0.7.0-rc.1" +dioxus-desktop = "^0.7.0-rc.1" +dioxus-config-macro = "^0.7.0-rc.1" # Deps cfg-if = "1.0.0" diff --git a/packages/geolocation/Cargo.toml b/packages/geolocation/Cargo.toml index b93b4b0..f498a55 100644 --- a/packages/geolocation/Cargo.toml +++ b/packages/geolocation/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dioxus-geolocation" -version = "0.1.0-alpha.1" +version = "0.7.0-rc.1" description = "Geolocation utilities and hooks for Dioxus." readme = "./README.md" diff --git a/packages/geolocation/src/use_geolocation.rs b/packages/geolocation/src/use_geolocation.rs index 33f0ab9..9b3833d 100644 --- a/packages/geolocation/src/use_geolocation.rs +++ b/packages/geolocation/src/use_geolocation.rs @@ -3,8 +3,8 @@ use super::core::{Error, Event, Geocoordinates, Geolocator, PowerMode, Status}; use dioxus::{ prelude::{ - ReadOnlySignal, Signal, UnboundedReceiver, provide_context, try_consume_context, - use_coroutine, use_hook, use_signal, + ReadSignal, Signal, UnboundedReceiver, provide_context, try_consume_context, use_coroutine, + use_hook, use_signal, }, signals::{Readable, Writable}, }; @@ -14,7 +14,7 @@ use std::sync::Once; static INIT: Once = Once::new(); /// Provides the latest geocoordinates. Good for navigation-type apps. -pub fn use_geolocation() -> ReadOnlySignal> { +pub fn use_geolocation() -> ReadSignal> { // Store the coords let mut coords: Signal> = use_signal(|| Err(Error::NotInitialized)); @@ -52,7 +52,7 @@ pub fn use_geolocation() -> ReadOnlySignal> { } } - use_hook(|| ReadOnlySignal::new(coords)) + use_hook(|| ReadSignal::new(coords)) } /// Must be called before any use of the geolocation abstraction. diff --git a/packages/notification/Cargo.toml b/packages/notification/Cargo.toml index 74753b3..c5feea6 100644 --- a/packages/notification/Cargo.toml +++ b/packages/notification/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dioxus-notification" -version = "0.1.0-alpha.1" +version = "0.7.0-rc.1" description = "Send notifications from your Dioxus apps." readme = "./README.md" diff --git a/packages/sdk/Cargo.toml b/packages/sdk/Cargo.toml index 366610f..c3adcca 100644 --- a/packages/sdk/Cargo.toml +++ b/packages/sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dioxus-sdk" -version = "0.7.0-alpha.1" +version = "0.7.0-rc.1" description = "A platform agnostic library for supercharging your productivity with Dioxus." readme = "../../README.md" @@ -32,4 +32,4 @@ util = ["dep:dioxus-util"] window = ["dep:dioxus-window"] [package.metadata.docs.rs] -all-features = true \ No newline at end of file +all-features = true diff --git a/packages/storage/Cargo.toml b/packages/storage/Cargo.toml index ded109b..e7d6ac1 100644 --- a/packages/storage/Cargo.toml +++ b/packages/storage/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dioxus_storage" -version = "0.1.0-alpha.1" +version = "0.7.0-rc.1" description = "Local and persistent storage utilities for Dioxus." readme = "./README.md" diff --git a/packages/storage/src/client_storage/memory.rs b/packages/storage/src/client_storage/memory.rs index d0433ba..ffa36eb 100644 --- a/packages/storage/src/client_storage/memory.rs +++ b/packages/storage/src/client_storage/memory.rs @@ -5,6 +5,8 @@ use std::ops::{Deref, DerefMut}; use std::rc::Rc; use std::sync::Arc; +use dioxus::core::{consume_context_from_scope, provide_root_context}; + use crate::StorageBacking; #[derive(Clone)] @@ -42,15 +44,14 @@ impl SessionStore { /// Get the current session store from the root context, or create a new one if it doesn't exist. fn get_current_session() -> Self { - dioxus::prelude::consume_context_from_scope::(dioxus::prelude::ScopeId::ROOT) - .map_or_else( - || { - let session = Self::new(); - dioxus::prelude::provide_root_context(session.clone()); - session - }, - |s| s, - ) + consume_context_from_scope::(dioxus::prelude::ScopeId::ROOT).map_or_else( + || { + let session = Self::new(); + provide_root_context(session.clone()); + session + }, + |s| s, + ) } } diff --git a/packages/storage/src/lib.rs b/packages/storage/src/lib.rs index 89881f0..fdaf72a 100644 --- a/packages/storage/src/lib.rs +++ b/packages/storage/src/lib.rs @@ -30,6 +30,7 @@ mod client_storage; mod persistence; pub use client_storage::{LocalStorage, SessionStorage}; +use dioxus::core::{ReactiveContext, current_scope_id, generation, needs_update}; use dioxus::logger::tracing::trace; use futures_util::stream::StreamExt; pub use persistence::{ @@ -401,10 +402,7 @@ where pub fn new(key: S::Key, data: T) -> Self { Self { key, - data: Signal::new_in_scope( - data, - current_scope_id().expect("must be called from inside of the dioxus context"), - ), + data: Signal::new_in_scope(data, current_scope_id()), } } } diff --git a/packages/sync/Cargo.toml b/packages/sync/Cargo.toml index abbbc55..be64bba 100644 --- a/packages/sync/Cargo.toml +++ b/packages/sync/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dioxus-sync" -version = "0.1.0-alpha.1" +version = "0.7.0-rc.1" description = "Synchronization primitives for your Dioxus app." readme = "./README.md" diff --git a/packages/time/Cargo.toml b/packages/time/Cargo.toml index 6008097..ea39594 100644 --- a/packages/time/Cargo.toml +++ b/packages/time/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dioxus-time" -version = "0.1.0-alpha.1" +version = "0.7.0-rc.1" description = "Timing utilities and hooks for Dioxus." readme = "./README.md" @@ -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"] } \ No newline at end of file +gloo-timers = { version = "0.3.0", features = ["futures"] } diff --git a/packages/time/src/debounce.rs b/packages/time/src/debounce.rs index 1e2ed66..1d1f61d 100644 --- a/packages/time/src/debounce.rs +++ b/packages/time/src/debounce.rs @@ -1,9 +1,5 @@ use crate::{TimeoutHandle, UseTimeout, use_timeout}; -use dioxus::{ - dioxus_core::SpawnIfAsync, - hooks::use_signal, - signals::{Signal, Writable}, -}; +use dioxus::{dioxus_core::SpawnIfAsync, hooks::use_signal, prelude::WritableExt, signals::Signal}; use std::time::Duration; /// The interface for calling a debounce. @@ -48,7 +44,7 @@ impl UseDebounce { /// // Create a two second debounce. /// // This will print "ran" after two seconds since the last action call. /// let mut debounce = use_debounce(Duration::from_secs(2), |_| println!("ran")); -/// +/// /// rsx! { /// button { /// onclick: move |_| { @@ -71,7 +67,7 @@ impl UseDebounce { /// #[component] /// fn App() -> Element { /// let mut debounce = use_debounce(Duration::from_secs(5), |_| println!("ran")); -/// +/// /// rsx! { /// button { /// // Start the debounce on click. @@ -102,7 +98,7 @@ impl UseDebounce { /// tokio::time::sleep(Duration::from_secs(2)).await; /// println!("after async"); /// }); -/// +/// /// rsx! { /// button { /// onclick: move |_| { diff --git a/packages/time/src/interval.rs b/packages/time/src/interval.rs index fdcc290..cd859bb 100644 --- a/packages/time/src/interval.rs +++ b/packages/time/src/interval.rs @@ -1,6 +1,7 @@ use dioxus::{ + core::Task, dioxus_core::SpawnIfAsync, - prelude::{Callback, Task, Writable, spawn, use_hook}, + prelude::{Callback, WritableExt, spawn, use_hook}, signals::Signal, }; use std::time::Duration; @@ -52,7 +53,7 @@ impl UseInterval { /// let mut time_elapsed = use_signal(|| 0); /// // Create an interval that increases the time elapsed signal by one every second. /// use_interval(Duration::from_secs(1), move |()| time_elapsed += 1); -/// +/// /// rsx! { /// "It has been {time_elapsed} since the app started." /// } @@ -70,7 +71,7 @@ impl UseInterval { /// fn App() -> Element { /// let mut time_elapsed = use_signal(|| 0); /// let mut interval = use_interval(Duration::from_secs(1), move |()| time_elapsed += 1); -/// +/// /// rsx! { /// "It has been {time_elapsed} since the app started." /// button { @@ -99,7 +100,7 @@ impl UseInterval { /// tokio::time::sleep(Duration::from_secs(1)).await; /// println!("Done!"); /// }); -/// +/// /// rsx! { /// "It has been {time_elapsed} since the app started." /// } diff --git a/packages/time/src/timeout.rs b/packages/time/src/timeout.rs index 61ca1d2..a34ebb0 100644 --- a/packages/time/src/timeout.rs +++ b/packages/time/src/timeout.rs @@ -1,6 +1,7 @@ use dioxus::{ + core::Task, dioxus_core::SpawnIfAsync, - prelude::{Callback, Task, spawn, use_hook}, + prelude::{Callback, spawn, use_hook}, signals::Signal, }; use futures::{SinkExt, StreamExt, channel::mpsc}; diff --git a/packages/util/Cargo.toml b/packages/util/Cargo.toml index ef7d895..61f245f 100644 --- a/packages/util/Cargo.toml +++ b/packages/util/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dioxus-util" -version = "0.1.0-alpha.1" +version = "0.7.0-rc.1" description = "General utilities for Dioxus apps." readme = "./README.md" diff --git a/packages/util/src/scroll.rs b/packages/util/src/scroll.rs index b348b16..be04677 100644 --- a/packages/util/src/scroll.rs +++ b/packages/util/src/scroll.rs @@ -1,4 +1,4 @@ -use dioxus::prelude::*; +use dioxus::{core::use_drop, prelude::*}; use std::sync::atomic::{AtomicUsize, Ordering}; /// Scroll metrics. diff --git a/packages/window/Cargo.toml b/packages/window/Cargo.toml index e318540..619cc36 100644 --- a/packages/window/Cargo.toml +++ b/packages/window/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dioxus-window" -version = "0.1.0-alpha.1" +version = "0.7.0-rc.1" description = "Window utilities and hooks for Dioxus." readme = "./README.md" diff --git a/packages/window/src/size.rs b/packages/window/src/size.rs index 5b03889..d753996 100644 --- a/packages/window/src/size.rs +++ b/packages/window/src/size.rs @@ -13,7 +13,7 @@ //! //! fn App() -> Element { //! let size = use_window_size(); -//! let size = size().unwrap(); +//! let size = size().unwrap(); //! //! rsx! { //! p { "Width: {size.width}" } @@ -21,13 +21,12 @@ //! } //! } //! ``` +use dioxus::core::provide_root_context; use dioxus::hooks::use_effect; use dioxus::prelude::{ - ReadOnlySignal, ScopeId, Signal, Writable, provide_root_context, try_use_context, use_hook, - warnings::signal_write_in_component_body, + ReadSignal, ReadableExt, ScopeId, Signal, WritableExt, try_use_context, use_hook, }; use dioxus::signals::Readable; -use dioxus::warnings::Warning as _; use std::error::Error; use std::fmt::Display; @@ -75,7 +74,7 @@ type WindowSizeResult = Result; /// /// fn App() -> Element { /// let size = use_window_size(); -/// +/// /// let half_of_width = use_memo(move || { /// let width = size.width().unwrap(); /// width / 2 @@ -120,7 +119,7 @@ impl ReadableWindowSizeExt for R where R: Readable /// /// fn App() -> Element { /// let size = use_window_size(); -/// let size = size().unwrap(); +/// let size = size().unwrap(); /// /// rsx! { /// p { "Width: {size.width}" } @@ -128,7 +127,7 @@ impl ReadableWindowSizeExt for R where R: Readable /// } /// } /// ``` -pub fn use_window_size() -> ReadOnlySignal { +pub fn use_window_size() -> ReadSignal { let mut window_size = match try_use_context::>() { Some(w) => w, // This should only run once. @@ -144,7 +143,7 @@ pub fn use_window_size() -> ReadOnlySignal { listen(window_size); }); - use_hook(|| ReadOnlySignal::new(window_size)) + use_hook(|| ReadSignal::new(window_size)) } // Listener for the web implementation. @@ -177,9 +176,7 @@ fn listen(mut window_size: Signal) { _ => Err(WindowSizeError::CheckFailed), }; - signal_write_in_component_body::allow(move || { - window_size.set(value); - }); + window_size.set(value); }) as Box); let on_resize_cb = on_resize.as_ref().clone(); @@ -199,12 +196,10 @@ fn listen(mut window_size: Signal) { .. } = event { - signal_write_in_component_body::allow(move || { - window_size.set(Ok(WindowSize { - width: size.width, - height: size.height, - })); - }); + window_size.set(Ok(WindowSize { + width: size.width, + height: size.height, + })); } }); } @@ -223,7 +218,7 @@ fn listen(mut window_size: Signal) { /// /// fn App() -> Element { /// let size = use_signal(get_window_size); -/// let size = size().unwrap(); +/// let size = size().unwrap(); /// /// rsx! { /// p { "Width: {size.width}" } diff --git a/packages/window/src/theme.rs b/packages/window/src/theme.rs index b8cbf13..7d3a705 100644 --- a/packages/window/src/theme.rs +++ b/packages/window/src/theme.rs @@ -17,7 +17,7 @@ //! #[component] //! fn App() -> Element { //! let theme = use_system_theme(); -//! +//! //! // Default to a light theme in the event of an error. //! let class = match theme().unwrap_or(Theme::Light) { //! Theme::Light => "bg-light", @@ -32,7 +32,7 @@ //! } //! } //! ``` -use dioxus::prelude::*; +use dioxus::{core::provide_root_context, prelude::*}; use std::{error::Error, fmt::Display}; /// A color theme. @@ -109,7 +109,7 @@ type ThemeResult = Result; /// } /// } /// ``` -pub fn use_system_theme() -> ReadOnlySignal { +pub fn use_system_theme() -> ReadSignal { let mut system_theme = match try_use_context::>() { Some(s) => s, // This should only run once. @@ -125,7 +125,7 @@ pub fn use_system_theme() -> ReadOnlySignal { listen(system_theme); }); - use_hook(|| ReadOnlySignal::new(system_theme)) + use_hook(|| ReadSignal::new(system_theme)) } // The listener implementation for wasm targets.