Skip to content

Commit

Permalink
Merge branch 'main' into leptos_v0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
gbj authored Jan 14, 2024
2 parents 50bec1c + d71fead commit 8257430
Show file tree
Hide file tree
Showing 40 changed files with 899 additions and 136 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/get-changed-examples-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

- name: Get example project directories that changed
id: changed-dirs
uses: tj-actions/changed-files@v39
uses: tj-actions/changed-files@v41
with:
dir_names: true
dir_names_max_depth: "2"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/get-example-changed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

- name: Get example files that changed
id: changed-files
uses: tj-actions/changed-files@v39
uses: tj-actions/changed-files@v41
with:
files: |
examples
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/get-leptos-changed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

- name: Get source files that changed
id: changed-source
uses: tj-actions/changed-files@v39
uses: tj-actions/changed-files@v41
with:
files: |
integrations
Expand Down
3 changes: 2 additions & 1 deletion examples/ssr_modes/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ use thiserror::Error;
pub fn App() -> impl IntoView {
// Provides context that manages stylesheets, titles, meta tags, etc.
provide_meta_context();
let fallback = || view! { "Page not found." }.into_view();

view! {
<Stylesheet id="leptos" href="/pkg/ssr_modes.css"/>
<Title text="Welcome to Leptos"/>

<Router>
<Router fallback>
<main>
<Routes>
// We’ll load the home page with out-of-order streaming and <Suspense/>
Expand Down
3 changes: 2 additions & 1 deletion examples/ssr_modes_axum/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ use thiserror::Error;
pub fn App() -> impl IntoView {
// Provides context that manages stylesheets, titles, meta tags, etc.
provide_meta_context();
let fallback = || view! { "Page not found." }.into_view();

view! {
<Stylesheet id="leptos" href="/pkg/ssr_modes.css"/>
<Title text="Welcome to Leptos"/>

<Router>
<Router fallback>
<main>
<Routes>
// We’ll load the home page with out-of-order streaming and <Suspense/>
Expand Down
148 changes: 148 additions & 0 deletions integrations/actix/tests/extract_routes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
use leptos::*;
use leptos_actix::generate_route_list;
use leptos_router::{Route, Router, Routes, TrailingSlash};

#[component]
fn DefaultApp() -> impl IntoView {
let view = || view! { "" };
view! {
<Router>
<Routes>
<Route path="/foo" view/>
<Route path="/bar/" view/>
<Route path="/baz/:id" view/>
<Route path="/baz/:name/" view/>
<Route path="/baz/*any" view/>
</Routes>
</Router>
}
}

#[test]
fn test_default_app() {
let routes = generate_route_list(DefaultApp);

// We still have access to the original (albeit normalized) Leptos paths:
assert_same(
&routes,
|r| r.leptos_path(),
&["/bar", "/baz/*any", "/baz/:id", "/baz/:name", "/foo"],
);

// ... But leptos-actix has also reformatted "paths" to work for Actix.
assert_same(
&routes,
|r| r.path(),
&["/bar", "/baz/{id}", "/baz/{name}", "/baz/{tail:.*}", "/foo"],
);
}

#[component]
fn ExactApp() -> impl IntoView {
let view = || view! { "" };
let trailing_slash = TrailingSlash::Exact;
view! {
<Router trailing_slash>
<Routes>
<Route path="/foo" view/>
<Route path="/bar/" view/>
<Route path="/baz/:id" view/>
<Route path="/baz/:name/" view/>
<Route path="/baz/*any" view/>
</Routes>
</Router>
}
}

#[test]
fn test_exact_app() {
let routes = generate_route_list(ExactApp);

// In Exact mode, the Leptos paths no longer have their trailing slashes stripped:
assert_same(
&routes,
|r| r.leptos_path(),
&["/bar/", "/baz/*any", "/baz/:id", "/baz/:name/", "/foo"],
);

// Actix paths also have trailing slashes as a result:
assert_same(
&routes,
|r| r.path(),
&[
"/bar/",
"/baz/{id}",
"/baz/{name}/",
"/baz/{tail:.*}",
"/foo",
],
);
}

#[component]
fn RedirectApp() -> impl IntoView {
let view = || view! { "" };
let trailing_slash = TrailingSlash::Redirect;
view! {
<Router trailing_slash>
<Routes>
<Route path="/foo" view/>
<Route path="/bar/" view/>
<Route path="/baz/:id" view/>
<Route path="/baz/:name/" view/>
<Route path="/baz/*any" view/>
</Routes>
</Router>
}
}

#[test]
fn test_redirect_app() {
let routes = generate_route_list(RedirectApp);

assert_same(
&routes,
|r| r.leptos_path(),
&[
"/bar",
"/bar/",
"/baz/*any",
"/baz/:id",
"/baz/:id/",
"/baz/:name",
"/baz/:name/",
"/foo",
"/foo/",
],
);

// ... But leptos-actix has also reformatted "paths" to work for Actix.
assert_same(
&routes,
|r| r.path(),
&[
"/bar",
"/bar/",
"/baz/{id}",
"/baz/{id}/",
"/baz/{name}",
"/baz/{name}/",
"/baz/{tail:.*}",
"/foo",
"/foo/",
],
);
}

fn assert_same<'t, T, F, U>(
input: &'t Vec<T>,
mapper: F,
expected_sorted_values: &[U],
) where
F: Fn(&'t T) -> U + 't,
U: Ord + std::fmt::Debug,
{
let mut values: Vec<U> = input.iter().map(mapper).collect();
values.sort();
assert_eq!(values, expected_sorted_values);
}
26 changes: 13 additions & 13 deletions integrations/axum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ pub type PinnedHtmlStream =
/// - [`ResponseOptions`]
/// - [`MetaContext`](leptos_meta::MetaContext)
/// - [`RouterIntegrationContext`](leptos_router::RouterIntegrationContext)
#[tracing::instrument(level = "info", fields(error), skip_all)]
#[tracing::instrument(level = "trace", fields(error), skip_all)]
pub fn render_app_to_stream<IV>(
options: LeptosOptions,
app_fn: impl Fn() -> IV + Clone + Send + 'static,
Expand All @@ -408,7 +408,7 @@ where
/// The difference between calling this and `render_app_to_stream_with_context()` is that this
/// one respects the `SsrMode` on each Route and thus requires `Vec<RouteListing>` for route checking.
/// This is useful if you are using `.leptos_routes_with_handler()`
#[tracing::instrument(level = "info", fields(error), skip_all)]
#[tracing::instrument(level = "trace", fields(error), skip_all)]
pub fn render_route<IV>(
options: LeptosOptions,
paths: Vec<RouteListing>,
Expand Down Expand Up @@ -478,7 +478,7 @@ where
/// - [ResponseOptions]
/// - [MetaContext](leptos_meta::MetaContext)
/// - [RouterIntegrationContext](leptos_router::RouterIntegrationContext)
#[tracing::instrument(level = "info", fields(error), skip_all)]
#[tracing::instrument(level = "trace", fields(error), skip_all)]
pub fn render_app_to_stream_in_order<IV>(
options: LeptosOptions,
app_fn: impl Fn() -> IV + Clone + Send + 'static,
Expand Down Expand Up @@ -519,7 +519,7 @@ where
/// - [ResponseOptions]
/// - [MetaContext](leptos_meta::MetaContext)
/// - [RouterIntegrationContext](leptos_router::RouterIntegrationContext)
#[tracing::instrument(level = "info", fields(error), skip_all)]
#[tracing::instrument(level = "trace", fields(error), skip_all)]
pub fn render_app_to_stream_with_context<IV>(
options: LeptosOptions,
additional_context: impl Fn() + 'static + Clone + Send,
Expand All @@ -546,7 +546,7 @@ where
/// The difference between calling this and `render_app_to_stream_with_context()` is that this
/// one respects the `SsrMode` on each Route, and thus requires `Vec<RouteListing>` for route checking.
/// This is useful if you are using `.leptos_routes_with_handler()`.
#[tracing::instrument(level = "info", fields(error), skip_all)]
#[tracing::instrument(level = "trace", fields(error), skip_all)]
pub fn render_route_with_context<IV>(
options: LeptosOptions,
paths: Vec<RouteListing>,
Expand Down Expand Up @@ -630,7 +630,7 @@ where
/// - [ResponseOptions]
/// - [MetaContext](leptos_meta::MetaContext)
/// - [RouterIntegrationContext](leptos_router::RouterIntegrationContext)
#[tracing::instrument(level = "info", fields(error), skip_all)]
#[tracing::instrument(level = "trace", fields(error), skip_all)]
pub fn render_app_to_stream_with_context_and_replace_blocks<IV>(
options: LeptosOptions,
additional_context: impl Fn() + 'static + Clone + Send,
Expand Down Expand Up @@ -688,7 +688,7 @@ where
}
}

#[tracing::instrument(level = "info", fields(error), skip_all)]
#[tracing::instrument(level = "trace", fields(error), skip_all)]
async fn generate_response(
res_options: ResponseOptions,
rx: Receiver<String>,
Expand Down Expand Up @@ -730,7 +730,7 @@ async fn generate_response(
}
res
}
#[tracing::instrument(level = "info", fields(error), skip_all)]
#[tracing::instrument(level = "trace", fields(error), skip_all)]
async fn forward_stream(
options: &LeptosOptions,
res_options2: ResponseOptions,
Expand Down Expand Up @@ -791,7 +791,7 @@ async fn forward_stream(
/// - [ResponseOptions]
/// - [MetaContext](leptos_meta::MetaContext)
/// - [RouterIntegrationContext](leptos_router::RouterIntegrationContext)
#[tracing::instrument(level = "info", fields(error), skip_all)]
#[tracing::instrument(level = "trace", fields(error), skip_all)]
pub fn render_app_to_stream_in_order_with_context<IV>(
options: LeptosOptions,
additional_context: impl Fn() + 'static + Clone + Send,
Expand Down Expand Up @@ -921,7 +921,7 @@ fn provide_contexts(
/// - [ResponseOptions]
/// - [MetaContext](leptos_meta::MetaContext)
/// - [RouterIntegrationContext](leptos_router::RouterIntegrationContext)
#[tracing::instrument(level = "info", fields(error), skip_all)]
#[tracing::instrument(level = "trace", fields(error), skip_all)]
pub fn render_app_async<IV>(
options: LeptosOptions,
app_fn: impl Fn() -> IV + Clone + Send + 'static,
Expand Down Expand Up @@ -963,7 +963,7 @@ where
/// - [ResponseOptions]
/// - [MetaContext](leptos_meta::MetaContext)
/// - [RouterIntegrationContext](leptos_router::RouterIntegrationContext)
#[tracing::instrument(level = "info", fields(error), skip_all)]
#[tracing::instrument(level = "trace", fields(error), skip_all)]
pub fn render_app_async_stream_with_context<IV>(
options: LeptosOptions,
additional_context: impl Fn() + 'static + Clone + Send,
Expand Down Expand Up @@ -1092,7 +1092,7 @@ where
/// - [ResponseOptions]
/// - [MetaContext](leptos_meta::MetaContext)
/// - [RouterIntegrationContext](leptos_router::RouterIntegrationContext)
#[tracing::instrument(level = "info", fields(error), skip_all)]
#[tracing::instrument(level = "trace", fields(error), skip_all)]
pub fn render_app_async_with_context<IV>(
options: LeptosOptions,
additional_context: impl Fn() + 'static + Clone + Send,
Expand Down Expand Up @@ -1564,7 +1564,7 @@ where
LeptosOptions: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
#[tracing::instrument(level = "info", fields(error), skip_all)]
#[tracing::instrument(level = "trace", fields(error), skip_all)]
fn leptos_routes<IV>(
self,
options: &S,
Expand Down
2 changes: 1 addition & 1 deletion leptos/src/animated_show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use leptos_reactive::{
/// ```
#[cfg_attr(
any(debug_assertions, feature = "ssr"),
tracing::instrument(level = "info", skip_all)
tracing::instrument(level = "trace", skip_all)
)]
#[component]
pub fn AnimatedShow(
Expand Down
2 changes: 1 addition & 1 deletion leptos/src/for_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ use std::hash::Hash;
/// ```
#[cfg_attr(
any(debug_assertions, feature = "ssr"),
tracing::instrument(level = "info", skip_all)
tracing::instrument(level = "trace", skip_all)
)]
#[component(transparent)]
pub fn For<IF, I, T, EF, N, KF, K>(
Expand Down
2 changes: 1 addition & 1 deletion leptos/src/portal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use leptos_macro::component;
/// Setting `use_shadow` to `true` places the element in a shadow root to isolate styles.
#[cfg_attr(
any(debug_assertions, feature = "ssr"),
tracing::instrument(level = "info", skip_all)
tracing::instrument(level = "trace", skip_all)
)]
#[component]
pub fn Portal(
Expand Down
2 changes: 1 addition & 1 deletion leptos/src/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use leptos_reactive::{create_memo, signal_prelude::*};
/// ```
#[cfg_attr(
any(debug_assertions, feature = "ssr"),
tracing::instrument(level = "info", skip_all)
tracing::instrument(level = "trace", skip_all)
)]
#[component]
pub fn Show<W>(
Expand Down
2 changes: 1 addition & 1 deletion leptos/src/suspense_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ use std::rc::Rc;
/// ```
#[cfg_attr(
any(debug_assertions, feature = "ssr"),
tracing::instrument(level = "info", skip_all)
tracing::instrument(level = "trace", skip_all)
)]
#[component]
pub fn Suspense<V>(
Expand Down
2 changes: 1 addition & 1 deletion leptos/src/transition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ use std::{
/// ```
#[cfg_attr(
any(debug_assertions, feature = "ssr"),
tracing::instrument(level = "info", skip_all)
tracing::instrument(level = "trace", skip_all)
)]
#[component(transparent)]
pub fn Transition(
Expand Down
2 changes: 1 addition & 1 deletion leptos_dom/src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl From<ComponentRepr> for View {
}

impl IntoView for ComponentRepr {
#[cfg_attr(any(debug_assertions, feature = "ssr"), instrument(level = "info", name = "<Component />", skip_all, fields(name = %self.name)))]
#[cfg_attr(any(debug_assertions, feature = "ssr"), instrument(level = "trace", name = "<Component />", skip_all, fields(name = %self.name)))]
fn into_view(self) -> View {
self.into()
}
Expand Down
2 changes: 1 addition & 1 deletion leptos_dom/src/components/dyn_child.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ where
{
#[cfg_attr(
any(debug_assertions, feature = "ssr"),
instrument(level = "info", name = "<DynChild />", skip_all)
instrument(level = "trace", name = "<DynChild />", skip_all)
)]
#[inline]
fn into_view(self) -> View {
Expand Down
Loading

0 comments on commit 8257430

Please sign in to comment.