From 56a79edf34034d3c672fa02b5004acc8c5489162 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Sun, 27 Oct 2024 13:50:41 -0400 Subject: [PATCH 1/4] chore: fix `leptos_dom` reexports (closes #3166) --- leptos/src/lib.rs | 2 +- leptos_dom/src/lib.rs | 1 - router/src/form.rs | 2 +- router/src/location/history.rs | 4 ++-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/leptos/src/lib.rs b/leptos/src/lib.rs index 94a3bd1d5e..89b6ab712a 100644 --- a/leptos/src/lib.rs +++ b/leptos/src/lib.rs @@ -163,7 +163,7 @@ pub mod prelude { form::*, hydration::*, into_view::*, mount::*, suspense::*, }; pub use leptos_config::*; - pub use leptos_dom::{helpers::*, *}; + pub use leptos_dom::{helpers::*, logging}; pub use leptos_macro::*; pub use leptos_server::*; pub use oco_ref::*; diff --git a/leptos_dom/src/lib.rs b/leptos_dom/src/lib.rs index 925cba8b9c..ca96132cee 100644 --- a/leptos_dom/src/lib.rs +++ b/leptos_dom/src/lib.rs @@ -8,5 +8,4 @@ pub mod helpers; pub mod macro_helpers; /// Utilities for simple isomorphic logging to the console or terminal. -#[macro_use] pub mod logging; diff --git a/router/src/form.rs b/router/src/form.rs index e4f39cf7fc..2ac2d7bd9e 100644 --- a/router/src/form.rs +++ b/router/src/form.rs @@ -4,7 +4,7 @@ use crate::{ location::{BrowserUrl, LocationProvider}, NavigateOptions, }; -use leptos::{ev, html::form, prelude::*, task::spawn_local}; +use leptos::{ev, html::form, logging::*, prelude::*, task::spawn_local}; use std::{error::Error, sync::Arc}; use wasm_bindgen::{JsCast, UnwrapThrowExt}; use web_sys::{FormData, RequestRedirect, Response}; diff --git a/router/src/location/history.rs b/router/src/location/history.rs index 16d7c878b8..db5d83ccfc 100644 --- a/router/src/location/history.rs +++ b/router/src/location/history.rs @@ -253,7 +253,7 @@ impl LocationProvider for BrowserUrl { let Some(url) = resolve_redirect_url(loc) else { return; // resolve_redirect_url() already logs an error }; - let current_origin = helpers::location().origin().unwrap(); + let current_origin = location().origin().unwrap(); if url.origin() == current_origin { let navigate = navigate.clone(); // delay by a tick here, so that the Action updates *before* the redirect @@ -261,7 +261,7 @@ impl LocationProvider for BrowserUrl { navigate(&url.href(), Default::default()); }); // Use set_href() if the conditions for client-side navigation were not satisfied - } else if let Err(e) = helpers::location().set_href(&url.href()) { + } else if let Err(e) = location().set_href(&url.href()) { leptos::logging::error!("Failed to redirect: {e:#?}"); } } From bc41cfbf3df45e46ccea3407622a0b4eb7d29895 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Sun, 27 Oct 2024 13:52:11 -0400 Subject: [PATCH 2/4] remove duplicate logging export --- leptos/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/leptos/src/lib.rs b/leptos/src/lib.rs index 89b6ab712a..9aa0843a81 100644 --- a/leptos/src/lib.rs +++ b/leptos/src/lib.rs @@ -163,7 +163,7 @@ pub mod prelude { form::*, hydration::*, into_view::*, mount::*, suspense::*, }; pub use leptos_config::*; - pub use leptos_dom::{helpers::*, logging}; + pub use leptos_dom::helpers::*; pub use leptos_macro::*; pub use leptos_server::*; pub use oco_ref::*; From 5bc3311a70098f8a10d64e519aada4cfcd209748 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Sun, 27 Oct 2024 18:39:36 -0400 Subject: [PATCH 3/4] chore: update example imports --- examples/axum_js_ssr/src/main.rs | 1 + examples/portal/src/main.rs | 2 +- examples/static_routing/src/main.rs | 1 + examples/stores/src/lib.rs | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/axum_js_ssr/src/main.rs b/examples/axum_js_ssr/src/main.rs index a823fc976c..2c5ae4e802 100644 --- a/examples/axum_js_ssr/src/main.rs +++ b/examples/axum_js_ssr/src/main.rs @@ -26,6 +26,7 @@ async fn main() { }; use axum_js_ssr::app::*; use http_body_util::BodyExt; + use leptos::logging::log; use leptos::prelude::*; use leptos_axum::{generate_route_list, LeptosRoutes}; diff --git a/examples/portal/src/main.rs b/examples/portal/src/main.rs index 1d37d6e205..5468e435ae 100644 --- a/examples/portal/src/main.rs +++ b/examples/portal/src/main.rs @@ -6,7 +6,7 @@ fn main() { _ = console_log::init_with_level(log::Level::Debug); console_error_panic_hook::set_once(); let handle = mount_to( - helpers::document() + document() .get_element_by_id("app") .unwrap() .unchecked_into(), diff --git a/examples/static_routing/src/main.rs b/examples/static_routing/src/main.rs index 7821f72c14..0d67d75d42 100644 --- a/examples/static_routing/src/main.rs +++ b/examples/static_routing/src/main.rs @@ -2,6 +2,7 @@ #[tokio::main] async fn main() { use axum::Router; + use leptos::logging; use leptos::prelude::*; use leptos_axum::{generate_route_list_with_ssg, LeptosRoutes}; use static_routing::app::*; diff --git a/examples/stores/src/lib.rs b/examples/stores/src/lib.rs index 70ed1fd67a..e88a71a977 100644 --- a/examples/stores/src/lib.rs +++ b/examples/stores/src/lib.rs @@ -1,6 +1,7 @@ use std::sync::atomic::{AtomicUsize, Ordering}; use chrono::{Local, NaiveDate}; +use leptos::logging::warn; use leptos::prelude::*; use reactive_stores::{Field, Patch, Store}; use serde::{Deserialize, Serialize}; From 75a997d3df6acc6602d9ff2bcd1a3d59866e4324 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Sun, 27 Oct 2024 19:07:47 -0400 Subject: [PATCH 4/4] chore: update example imports --- examples/ssr_modes_axum/src/main.rs | 1 + examples/static_routing/src/main.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/ssr_modes_axum/src/main.rs b/examples/ssr_modes_axum/src/main.rs index 83b2215df2..70fd8adf4d 100644 --- a/examples/ssr_modes_axum/src/main.rs +++ b/examples/ssr_modes_axum/src/main.rs @@ -2,6 +2,7 @@ #[tokio::main] async fn main() { use axum::Router; + use leptos::logging::log; use leptos::prelude::*; use leptos_axum::{generate_route_list, LeptosRoutes}; use ssr_modes_axum::app::*; diff --git a/examples/static_routing/src/main.rs b/examples/static_routing/src/main.rs index 0d67d75d42..1a1952aac1 100644 --- a/examples/static_routing/src/main.rs +++ b/examples/static_routing/src/main.rs @@ -2,7 +2,7 @@ #[tokio::main] async fn main() { use axum::Router; - use leptos::logging; + use leptos::logging::log; use leptos::prelude::*; use leptos_axum::{generate_route_list_with_ssg, LeptosRoutes}; use static_routing::app::*;