Skip to content

Releases: leptos-rs/leptos

`v0.2.2`

12 Mar 19:03
@gbj gbj
8f94c8e
Compare
Choose a tag to compare

I forgot to make a tag or publish release notes for 0.2.1. These are both patch releases that include some performance improvements, a number of bugfixes, and spinning out a framework-independent server function crate, but don't include any particularly big new features.

Small new features

  • rkyv encoding as an option for resources
  • allowing multiple class names in class = syntax in view! macro
  • provide a new LeptosRequest<_> type that allows Leptos Axum apps access to the request via use_context, which allows you to use Axum extractors without a special handler
  • preliminary hot-reloading support, to be built into cargo-leptos, for updating static parts of the view before recompiling the Rust parts of your app

What's Changed

  • Some cleanups in router/matching/resolve_paths by @g-re-g in #569
  • perf: improvements to element creation in <For/> by @gbj in #579
  • feat: Support rkyv encoding by @617a7a in #577
  • make counter test compile by @eiswind in #588
  • fix: mouseenter and mouseleave do not bubble by @gbj in #593
  • Update example readme by @brendonotto in #595
  • examples: include missing examples in CI by @gbj in #598
  • fix: SSR + hydration improvements by @gbj in #599
  • cx typo in 02_getting_started.md by @iagafonov in #602
  • Fix typo in 03_components.md by @makoven in #603
  • In Action::dispatch() set new value before resetting input signal by @Qwox0 in #604
  • fix: memory leak in render_to_stream by @gbj in #601
  • Make server functions framework agnostic by @Demonthos in #596
  • use create_node_ref instead of NodeRef::new by @iagafonov in #607
  • publish framework-independent server_fn crate by @gbj in #605
  • fix compilation error, Issue #608 by @kulak in #609
  • updated error handling code in book by @iagafonov in #610
  • feat: support expr for #[prop(default=...)] by @ModProg in #611
  • Minor: Clippy - Simplified conditional logic in transition.rs. by @martinfrances107 in #615
  • docs: improve "Getting Started" page by @gbj in #618
  • feat: allow multiple class names in view! macro class = (closes #612) by @gbj in #614
  • tests: use check instead of build in CI for disk space by @gbj in #616
  • docs: add patterns for global state (closes #245) by @gbj in #619
  • feat: allow easier client-side form validation (closes #413) by @gbj in #620
  • fix: suppress warnings caused by resource loading in generate_route_list (closes #582) by @gbj in #621
  • CI: exclude rkyv combos with other serialization traits by @gbj in #622
  • docs: add a chapter on async actions and create_action by @gbj in #623
  • [WIP] feat: hot reloading support for cargo-leptos by @gbj in #592
  • fix: added missing attributes of events that don't bubble by @WafflePersonThing in #625
  • fix: boolean attributes in SSR by @gbj in #629
  • docs: fix instruction typos by @Banyc in #631
  • docs: Update 04_iteration.md by @jfloresremar in #630
  • bump typed-builder to version 0.13. by @martinfrances107 in #633
  • de-duplicate todomvc example by @erwanvivien in #634
  • CI: split into three actions by @gbj in #636
  • New example: session_auth_axum by @j0lol in #589
  • fix: custom events (closes issue #641) by @gbj in #642
  • Bump tower-http upto 0.4. by @martinfrances107 in #638
  • Minor: form component Removed unused variables. by @martinfrances107 in #640
  • Bump serde-wasm-bindgen to 0.5. by @martinfrances107 in #639
  • Cargo machete: Strip down leptos_server. by @martinfrances107 in #644
  • Unit tests for leptos-config and new functions for loading configuration by @vaniusrb in #628
  • chore: typo (closes issue #645) by @gbj in #646
  • bump bytecheck to 0.7, remove deprecated simdutf8_std. by @martinfrances107 in #647
  • Bumped typed-builder up to 0.14. by @martinfrances107 in #648
  • fix spelling error for document by @zackshen in #651
  • docs: add create_effect chapter by @gbj in #653
  • Make server functions work outside of WASM by @Demonthos in #643
  • πŸ”§ Fix(leptos_dom/logging): Fix showing warning instead of error by @pikhosh in #654
  • feat: impl IntoView for &Fragment by @gbj in #655
  • cargo machete: leptos_macro - Removed unused crates. by @martinfrances107 in #656
  • Put the Request on the Context for Axum by @benwis in #632
  • feat: add fragment support for hot reloading and fix some stuff by @gbj in #659
  • Copy & Clone for MaybeSignal by @CharlesTaylor7 in #660
  • fix: text node issue in template macro by @gbj in #661
  • fix: apply patches to all instances of a view, not just the first one by @gbj in #663
  • Typo fixes and other small changes to the docs by @elliotwaite in #662
  • Clippy: signal_wrappers_read, was using .clone() when copy is available. by @martinfrances107 in #665
  • v0.2.2 by @gbj in #667

New Contributors

Full Changelog: v0.2.0...v0.2.2

`v0.2.0`

25 Feb 21:03
@gbj gbj
Compare
Choose a tag to compare

v0.2.0

v0.2.0 is an incremental change over 0.1.x. There are a few small things that have been breaking changes over the last two months, one big new feature, and a lot of small improvements and changes.

Async Rendering and In-Order Streaming

The biggest new feature of 0.2.0 that requires explanation is support for async rendering and in-order streaming, which you can activate via the new ssr prop on a <Route/>. (See the ssr_modes and ssr_modes_axum examples.)

With this new feature, Leptos now supports four different ways to render HTML that contains async data loaded under <Suspense/>. You can opt in to one or the other on a per-route basis.

  1. Synchronous: Serve an HTML shell that includes fallback for any Suspense. Load data on the client, replacing fallback once they're loaded.
    • Pros: App shell appears very quickly: great TTFB (time to first byte).
    • Cons: Resources load relatively slowly; you need to wait for JS + WASM to load before even making a request.
  2. Out-of-order streaming: Serve an HTML shell that includes fallback for any Suspense. Load data on the server, streaming it down to the client as it resolves, and streaming down HTML for Suspense nodes.
    • Pros: Combines the best of synchronous and async, with a very fast shell and resources that begin loading on the server.
    • Cons: Requires JS for suspended fragments to appear in correct order. Weaker meta tag support when it depends on data that's under suspense (has already streamed down <head>)
  3. In-order streaming: Walk through the tree, returning HTML synchronously as in synchronous rendering and out-of-order streaming until you hit a Suspense. At that point, wait for all its data to load, then render it, then the rest of the tree.
    • Pros: Does not require JS for HTML to appear in correct order.
    • Cons: Loads the shell more slowly than out-of-order streaming or synchronous rendering because it needs to pause at every Suspense. Cannot begin hydration until the entire page has loaded, so earlier pieces
      of the page will not be interactive until the suspended chunks have loaded.
  4. async: Load all resources on the server. Wait until all data are loaded, and render HTML in one sweep.
    • Pros: Better handling for meta tags (because you know async data even before you render the <head>). Faster complete load than synchronous because async resources begin loading on server.
    • Cons: Slower load time/TTFB: you need to wait for all async resources to load before displaying anything on the client.

The mode defaults to out-of-order streaming. For a path that includes multiple nested routes, the most
restrictive mode will be used: i.e., if even a single nested route asks for async rendering, the whole initial
request will be rendered async. (async is the most restrictive requirement, followed by in-order, out-of-order, and synchronous.)

Because you have the ability to opt into these different modes on a per-route basis, you can choose the rendering strategy that is best for youβ€”not only for your app in general, but for any given page.

Other Features and Improvements

  • New <Html/> and <Body/> components in leptos_meta that let you change things like <html> lang and dir, and add a class to the <body>
  • Restoring on: event listeners on <Component/> nodes, e.g., <MyFancyButton on:click=.../> without needing to create an on_click prop
  • Adding a <Redirect/> component in the router that works during client-side navigation or server-side rendering
  • Children, AttributeValue, and other type aliases to make it easier to accept a variety of types in your components
  • Experimentation with new docs using CodeSandboxes and an expanding set of tutorials
  • So, so, so, so many bugfixes, typos, docs improvements, and small changes by many, many, many members of the community. Thanks to you all!

Breaking Changes Since 0.1.3

  • Resource::read() and Resource::with() now take a Scope as their first argument, i.e., resource.read() is now resource.read(cx). This is necessary for correct <Suspense/> behavior.
  • The Errors type has been modified to hide its internals and expose IntoIter directly. In 99% of cases this just means replacing references like errors.get().0.into_iter() with errors.get().into_iter()
  • Most of the methods on various signal types have been moved into traits instead. This should not cause any actual changes to the way you use them, and if you are accustomed to use leptos::* you probably won't notice the difference; if you are manually importing types you will need to import the signal traits as well.
  • The <For/> component view argument now takes a Scope as its first argument, i.e., a change from view=move |counter| { ... } to view=move |cx, counter| { ... }
  • The <ErrorBoundary/> component fallback argument now takes a Fn(Scope, RwSignal<Errors>) -> impl IntoView instead of Fn(Scope, Option<RwSignal<Errors>>) -> impl IntoView
  • NodeRef now takes NodeRef<T> instead of NodeRef<HtmlElement<T>>. We're also deprecating NodeRef::new(cx) in favor of create_node_ref(cx) to follow the same pattern as everything else in the framework.
  • We've finally achieved full consistency between cargo-leptos and the server integrations whether you're using cargo-leptos or not. The site_address field is now named site_addr; the compiler should actually prompt you correctly for this one.
  • The current Leptos global namespace is polluted with a huge number of types and reexports, making it harder to find things in docs and adding compile-time overhead. If you're used to use leptos::* you may need to manually import a few additional types. We're also no longer reexporting wasm-bindgen, web-sys, and js-sys so you may need to add them as dependencies to your Cargo.toml
  • APIs to modify status code and headers in HTTP responses are now synchronous, making them easier to set in components

Complete CHANGELOG

  • Add Children type alias by @gbj in #403
  • Fix boolean attributes in view macro fast-path SSR by @gbj in #408
  • Add <Html/> and <Body/> components in leptos_meta by @gbj in #407
  • Minor: Bump typed-builder from 0.11 to 0.12. by @martinfrances107 in #409
  • Escape and tokens in documentation markup. by @martinfrances107 in #410
  • fix: correct types for top-level <option> and <use> in SSR view macro by @gbj in #416
  • Switch RwLock to parking_lot so they are no longer async by @benwis in #414
  • Add leptos_routes functions for integrations by @b4-io in #415
  • Fix issues with attribute names in SSR by @gbj in #418
  • Implemented update_returning for StoredValue by @thestarmaker in #419
  • Update ErrorBoundary to use miette::Diagnostic instead of Error, and various other tweaks by @benwis in #401
  • Fix some small issues in axum_errors example by @gbj in #424
  • fix: Make all fragment rendering lazy (closes #299 and #421) by @gbj in #425
  • fixes cx not found on components marked with #[component(transparent)] by @jquesada2016 in #423
  • Several Minor Updates on Examples by @Indrazar in #427
  • Make RouteDefinition public by @gbj in #430
  • docs: Document inner_html attribute by @gbj in #429
  • chore: switch examples to check instead of build (for CI) & add missing examples by @gbj in #437
  • Fix top-level SVG elements in SSR by @gbj in #435
  • fix: correct behavior of <Show/> by @gbj in #436
  • Dedup from_str implementations for Env by @g-re-g in #426
  • leptos-server: Removed unused dependency on log, linear-map and rmp-serde. by @martinfrances107 in #439
  • leptos_macro: Machete - Removed unused deps. by @martinfrances107 in #441
  • router: Machete - Removed unused deps. by @martinfrances107 in #442
  • use latest tokio in leptos_axum by @Gentle in #443
  • fix: successfully pass context to nested routes via <Outlet/> by @gbj in #447
  • feature: allow on: event listeners on <Component/> nodes by @gbj in #448
  • fix: update leptos dependencies paths to the workspace by @turbotobias in #449
  • fix: leptos_router hydration issues by @gbj in #450
  • Clippy: "{input} is not a supported environment." by @martinfrances107 in #451
  • fix: stack overflow in with nested outlet (closes #452) by @gbj in #453
  • fix: typo in leptos_config description by @odiseo0 in #455
  • docs: add new Children types to macro docs by @gbj in https://g...
Read more

`v0.2.0-beta`

20 Feb 16:21
@gbj gbj
3220419
Compare
Choose a tag to compare
`v0.2.0-beta` Pre-release
Pre-release

v0.2.0-beta

This release is a preview, and also serves to generate new docs on docs.rs, as the current ones are getting slightly out of sync with our main branch here.

Changes from 0.2.0-alpha to 0.2.0-beta

  • Resource::read() and Resource::with() now take a Scope as their first argument, i.e., resource.read() is now resource.read(cx). This is necessary for correct <Suspense/> behavior.
  • The Errors type has been modified to hide its internals and expose IntoIter directly. In 99% of cases this just means replacing references like errors.get().0.into_iter() with errors.get().into_iter()
  • Most of the methods on various signal types have been moved into traits instead. This should not cause any actual changes to the way you use them, and if you are accustomed to use leptos::* you probably won't notice the difference; if you are manually importing types you will need to import the signal traits as well.

Included below are the notes for 0.2.0-alpha, so you can see changes since 0.1.3 as well.

Breaking Changes since 0.1.3

  • The <For/> component view argument now takes a Scope as its first argument, i.e., a change from view=move |counter| { ... } to view=move |cx, counter| { ... }
  • The <ErrorBoundary/> component fallback argument now takes a Fn(Scope, RwSignal<Errors>) -> impl IntoView instead of Fn(Scope, Option<RwSignal<Errors>>) -> impl IntoView
  • NodeRef now takes NodeRef<T> instead of NodeRef<HtmlElement<T>>. We're also deprecating NodeRef::new(cx) in favor of create_node_ref(cx) to follow the same pattern as everything else in the framework.
  • We've finally achieved full consistency between cargo-leptos and the server integrations whether you're using cargo-leptos or not. The site_address field is now named site_addr; the compiler should actually prompt you correctly for this one.
  • The current Leptos global namespace is polluted with a huge number of types and reexports, making it harder to find things in docs and adding compile-time overhead. If you're used to use leptos::* you may need to manually import a few additional types. We're also no longer reexporting wasm-bindgen, web-sys, and js-sys so you may need to add them as dependencies to your Cargo.toml
  • APIs to modify status code and headers in HTTP responses are now synchronous, making them easier to set in components

Other Improvements

  • New <Html/> and <Body/> components in leptos_meta that let you change things like <html> lang and dir, and add a class to the <body>
  • Restoring on: event listeners on <Component/> nodes, e.g., <MyFancyButton on:click=.../> without needing to create an on_click prop
  • Adding a <Redirect/> component in the router that works during client-side navigation or server-side rendering
  • Children, AttributeValue, and other type aliases to make it easier to accept a variety of types in your components
  • Experimentation with new docs using CodeSandboxes and an expanding set of tutorials
  • So, so, so, so many bugfixes, typos, docs improvements, and small changes by many, many, many members of the community. Thanks to you all!

What's Changed

  • leptos_dom erros.rs remove() does not need to be generic. by @martinfrances107 in #516
  • fix: correct namespace for Unit in empty views (closes #518) by @gbj in #520
  • Reexport web-sys event types to make it easier to type handlers by @gbj in #521
  • Identify CSS to reload from the href by @akesson in #524
  • change: tweak API of Errors and implement IntoIter by @gbj in #522
  • fix: top-level SVG in view macro with new exports by @gbj in #525
  • feature: reintroduce limited template-node cloning w/ template macro by @gbj in #526
  • fix: hydration IDs for elements following <Suspense/> (closes #527) by @gbj in #531
  • feature: in-order streaming and async rendering by @gbj in #496
  • fix compile of leptos dom by @seanaye in #535
  • Signal traits by @jquesada2016 in #490
  • v0.2.0-alpha2 by @gbj in #539
  • fix: building leptos_reactive in release mode by @gbj in #540
  • 533 by @jquesada2016 in #538
  • fix(examples): hackernews_axum styles href by @ApplY3D in #536
  • revert PR #538 by @gbj in #544
  • fix: more work on hydration IDs with <Suspense/> by @gbj in #545
  • change: pass Scope into Resource::read() and Resource::with() by @gbj in #542
  • document typo by @chrislearn in #553
  • Fix typo in hydration.rs by @eltociear in #552
  • Fix issue with redirects in server fns creating multiple Location headers by @benwis in #550

New Contributors

Full Changelog: v0.2.0-alpha...v0.2.0-beta

`v0.2.0-alpha`

14 Feb 00:50
@gbj gbj
8a99623
Compare
Choose a tag to compare
`v0.2.0-alpha` Pre-release
Pre-release

v0.2.0-alpha

This release is a preview, and also serves to generate new docs on docs.rs, as the current ones are getting slightly out of sync with our main branch here.

I do not expect significant difficulties in migrating from 0.1.3 to 0.2.0. There are a few API tweaks here that necessitate a version bump but it's an order of magnitude smaller than the change from 0.0.x to 0.1.0 and will not touch most parts of your application.

Breaking Changes

  • The <For/> component view argument now takes a Scope as its first argument, i.e., a change from view=move |counter| { ... } to view=move |cx, counter| { ... }
  • The <ErrorBoundary/> component fallback argument now takes a Fn(Scope, RwSignal<Errors>) -> impl IntoView instead of Fn(Scope, Option<RwSignal<Errors>>) -> impl IntoView
  • NodeRef now takes NodeRef<T> instead of NodeRef<HtmlElement<T>>. We're also deprecating NodeRef::new(cx) in favor of create_node_ref(cx) to follow the same pattern as everything else in the framework.
  • We've finally achieved full consistency between cargo-leptos and the server integrations whether you're using cargo-leptos or not. The site_address field is now named site_addr; the compiler should actually prompt you correctly for this one.
  • The current Leptos global namespace is polluted with a huge number of types and reexports, making it harder to find things in docs and adding compile-time overhead. If you're used to use leptos::* you may need to manually import a few additional types. We're also no longer reexporting wasm-bindgen, web-sys, and js-sys so you may need to add them as dependencies to your Cargo.toml
  • APIs to modify status code and headers in HTTP responses are now synchronous, making them easier to set in components

Other Improvements

  • New <Html/> and <Body/> components in leptos_meta that let you change things like <html> lang and dir, and add a class to the <body>
  • Restoring on: event listeners on <Component/> nodes, e.g., <MyFancyButton on:click=.../> without needing to create an on_click prop
  • Adding a <Redirect/> component in the router that works during client-side navigation or server-side rendering
  • Children, AttributeValue, and other type aliases to make it easier to accept a variety of types in your components
  • Experimentation with new docs using CodeSandboxes and an expanding set of tutorials
  • So, so, so, so many bugfixes, typos, docs improvements, and small changes by many, many, many members of the community. Thanks to you all!

Complete Changelog

  • Add Children type alias by @gbj in #403
  • Fix boolean attributes in view macro fast-path SSR by @gbj in #408
  • Add <Html/> and <Body/> components in leptos_meta by @gbj in #407
  • Minor: Bump typed-builder from 0.11 to 0.12. by @martinfrances107 in #409
  • Escape and tokens in documentation markup. by @martinfrances107 in #410
  • fix: correct types for top-level <option> and <use> in SSR view macro by @gbj in #416
  • Switch RwLock to parking_lot so they are no longer async by @benwis in #414
  • Add leptos_routes functions for integrations by @b4-io in #415
  • Fix issues with attribute names in SSR by @gbj in #418
  • Implemented update_returning for StoredValue by @thestarmaker in #419
  • Various tweaks to ErrorBoundary by @benwis in #401
  • Fix some small issues in axum_errors example by @gbj in #424
  • fix: Make all fragment rendering lazy (closes #299 and #421) by @gbj in #425
  • fixes cx not found on components marked with #[component(transparent)] by @jquesada2016 in #423
  • Several Minor Updates on Examples by @Indrazar in #427
  • Make RouteDefinition public by @gbj in #430
  • docs: Document inner_html attribute by @gbj in #429
  • chore: switch examples to check instead of build (for CI) & add missing examples by @gbj in #437
  • Fix top-level SVG elements in SSR by @gbj in #435
  • fix: correct behavior of <Show/> by @gbj in #436
  • Dedup from_str implementations for Env by @g-re-g in #426
  • leptos-server: Removed unused dependency on log, linear-map and rmp-serde. by @martinfrances107 in #439
  • leptos_macro: Machete - Removed unused deps. by @martinfrances107 in #441
  • router: Machete - Removed unused deps. by @martinfrances107 in #442
  • use latest tokio in leptos_axum by @Gentle in #443
  • fix: successfully pass context to nested routes via <Outlet/> by @gbj in #447
  • feature: allow on: event listeners on <Component/> nodes by @gbj in #448
  • fix: update leptos dependencies paths to the workspace by @turbotobias in #449
  • fix: leptos_router hydration issues by @gbj in #450
  • Clippy: "{input} is not a supported environment." by @martinfrances107 in #451
  • fix: stack overflow in with nested outlet (closes #452) by @gbj in #453
  • fix: typo in leptos_config description by @odiseo0 in #455
  • docs: add new Children types to macro docs by @gbj in #454
  • Derive debug for params struct in server macro by @g-re-g in #458
  • perf: further reduce WASM binary size by ~5-7% by @gbj in #459
  • Fix #457 by @Threated in #460
  • docs: add note about optional fallback in <Show/> (closes #406) by @gbj in #463
  • impl Default for MaybeSignal by @ModProg in #464
  • feature: add isomorphic <Redirect/> component (closes #412) by @gbj in #466
  • Add simple icon logo by @underscorefunk in #468
  • error on non meta input for prop attribute by @ModProg in #469
  • fix: don't override element event listeners with component event listeners by @gbj in #470
  • fix: fix node_ref in SSR by @gbj in #471
  • Convert site_address to site_addr by @benwis in #462
  • impl From<&str> for MaybeSignal by @g-re-g in #472
  • fix: correct out-of-order streaming behavior (closes #473) by @gbj in #475
  • fix: cargo doc in projects using #[server] by @gbj in #476
  • fix: adding/removing errors from <ErrorBoundary/> by @gbj in #478
  • Experiments in new tutorial/guide format with integrated CodeSandboxes by @gbj in #375
  • remove unnecessary "openssl" feature from Actix examples by @gbj in #480
  • Better styling for router related components by @Threated in #477
  • fix: errors on 404 page in axum_errors example by @gbj in #485
  • Minor: Clippy router now uses types OnFormData and OnResponse. by @martinfrances107 in #484
  • fix: correct behavior for inner_html in SSR by @gbj in #487
  • fix: typed route params with #[derive(Params)] by @gbj in #488
  • Fix node ref generics by @jquesada2016 in #481
  • fix: fix debug_warn behavior in reactive crate and remove log dependency by @gbj in #491
  • change: add Scope to view function in <For/> to avoid memory "leak" by @gbj in #492
  • fix: error boundary hydration by @gbj in #494
  • Suspense: removed unused .clone() call. by @martinfrances107 in #486
  • examples: remove unused index.html by @gbj in #497
  • Allow literal string as class in view macro by @g-re-g in #500
  • fix: proper disposal of nested route scopes by @gbj in #499
  • workspace rustfmt by @jquesada2016 in #483
  • apply new formatting everywhere by @gbj in #502
  • Docs improvements by @gbj in #505
  • fix: <For/> in todomvc example by @gbj in #504
  • docs: add docs on testing (clos...
Read more

`v0.1.3`

28 Jan 17:44
@gbj gbj
Compare
Choose a tag to compare

The big changes here are the <ErrorBoundary/> and <Show/> components. Many thanks to @benwis for leading the work on these.

You should also see a very significant improvement in SSR performance, as well as small reductions in Wasm binary sizes, and some overall bugfixes and improvements.

Oh, and... 🎡🎢 We don't talk about 0.1.2. 🎢🎡

What's Changed

  • doc: add link for leptos watch by @imalexlab in #347
  • Reenable optimizations for SSR using the view! macro by @gbj in #344
  • Add SVG <script>, <style>, and <title> to set of ambiguous elements by @gbj in #350
  • Add support for class = ..., in view macro to support scoped styling by @gbj in #351
  • Update html.rs by @gbj in #352
  • ErrorBoundary Component by @benwis in #338
  • Fix query params behaviour difference between SSR and Hydrate by @killertux in #343
  • Allow snake case components by @jclmnop in #354
  • Clippy fixes: redundant clone and .to_string() issues. by @martinfrances107 in #353
  • leptos_reactive base64 bump version to 0.21. by @martinfrances107 in #358
  • Add methods to take Actix/Axum Extractors/Route Info/Stuff and pass it to Leptos by @benwis in #359
  • Reorganize snake-case #[component] docs and please clippy by @gbj in #362
  • Add component to avoid rerendering of closures and tweak ErrorBoundary by @benwis in #363
  • Replace urlencoding with percent-encoding by @flosse in #365
  • Fix CSR with Trunk on hackernews example, remove CSR option from isomorphic example by @Indrazar in #369
  • Make Errors Sync by @benwis in #372
  • Add a counter example that does not use macros by @flosse in #373
  • Fix context in outlets by @gbj in #374
  • refactor to eliminate duplicate code by @Gentle in #380
  • (micro optimization) cloning is not needed here by @Gentle in #381
  • added hgroup element by @ModProg in #379
  • leptos_axum::handle_server_fns was also duplicated by @Gentle in #383
  • implements From<Signal<T>> for MaybeSignal<T> by @gbj in #384
  • Allow unused cx in server fn arguments by @gbj in #385
  • Fix a large number of small issues in docs by @gbj in #386
  • Check uniqueness of server function names at registration time by @gbj in #388
  • Fix missing docs error by @gbj in #389
  • fix: Align <ActionForm/> behavior with Action by @gbj in #390
  • doc/book updated leptos version. by @martinfrances107 in #392
  • Remove gloo dependency in leptos_dom by @gbj in #391
  • Fix gtk example by @thomasqueirozb in #395
  • Reduce WASM binary sizes by 3-5% by @gbj in #393
  • Fix hydration issue related to WASM size reduction by @gbj in #396
  • v0.1.2 by @gbj in #397

New Contributors

Full Changelog: v0.1.1...v0.1.3

v0.1.1

20 Jan 18:48
@gbj gbj
Compare
Choose a tag to compare

0.1.1 is mostly a series of bugfixes to 0.1.0; see the 0.1.0 release notes for a list of new features in this series. Thanks to our new contributors, and to everyone who's helped find bugs.

What's Changed

  • Fix link to counters_stable in README by @dzfrias in #309
  • Doc fix + search & replace url by @akesson in #310
  • Update Generated API URL on Windows Attempt #2 by @Indrazar in #308
  • Use rust-cache in CI by @TaKO8Ki in #312
  • Fix doctest in create_slice and edit doc comment slightly by @gbj in #314
  • Create CODE_OF_CONDUCT.md by @gbj in #315
  • Death to suspense hydration mismatches by @gbj in #316
  • Switch get_configuration calls to None and add a note in the docs for get_configuration() by @benwis in #318
  • Fix <Router fallback> (signature and functionality) by @gbj in #324
  • Use comments instead of element markers for hydration by @gbj in #321
  • Make sure Axum returns a relative URI for http and https requests by @benwis in #326
  • Updated example code and README to use latest syntax for data binding by @ekanna in #327
  • Minor: For each sub crate the landing page should be the root README.md. by @martinfrances107 in #328
  • impl Debug on MetaContext by @gbj in #329
  • typed-builder inconsistent version. by @martinfrances107 in #330
  • Path and Query for Axum by @benwis in #331
  • Add programmatic navigation in router example by @gbj in #332
  • Fix MetaContext debug for wasm target by @gbj in #334
  • Minimize panics when runtime has already been disposed (e.g., in SSR) by @gbj in #333
  • Fix behavior of RouteContext in nested routes with different parameters by @gbj in #345
  • Change <Suspense/> to a specialized type that uses comments for SSR by @gbj in #346

New Contributors

Full Changelog: v0.1.0...v0.1.1

v0.1.0

12 Jan 21:49
@gbj gbj
08ec473
Compare
Choose a tag to compare

Finally, here's the release for version 0.1.0. Thanks to everyone who's been working with the alpha, beta, and bleeding-edge versions over the last few weeks to help get everything ready.

Most of the release notes below are copied from the 0.1.0-alpha release, but include a few updates. All these changes are relative to 0.0.22.

Features

More flexible rendering

You can now easily mix and match different types of node in a Fragment, which previously needed to be a Vec of all the same types (like a Vec<Fragment>).

view! { cx,
  <>
    "This is some text."
    <p>"Here's an element."</p>
    <ComponentA/>
  </>
}

In fact, the <> fragment itself is optional.

view! { cx,
  "This is some text."
  <p>"Here's an element."</p>
  <ComponentA/>
}

Typed HTML elements

HTML elements generated by the view! macro are now typed, and implement Deref to give a correctly-typed web_sys element.

// returns `HtmlElement<Input>`
// derefs to a `web_sys::HtmlInputElement`
view! { cx, <input type="text"/> }

store_value

You can now store non-reactive values in the reactive system to take advantage of the same Copy + 'static reference system without the overhead or abstraction leak of storing something in a signal. This is useful for objects you need to reference in multiple places throughout your application without cloning.

// this structure is neither `Copy` nor `Clone`
pub struct MyUncloneableData {
  pub value: String
}

// βœ… you can move the `StoredValue` into closures and access it with .with()
let data = store_value(cx, MyUncloneableData { value: "a".into() });
let callback_a = move || data.with(|data| data.value == "a");
let callback_b = move || data.with(|data| data.value == "b");

Signal<T> and SignalSetter<T> abstractions

These wrappers allow you to define APIs that can take any kind of signal. For example, Signal<T> can be a ReadSignal, RwSignal, Memo, or derived signal. This is especially useful when defining components interfaces. (There's even a MaybeSignal for types that may just be T or may be a Signal<T>.)

let (count, set_count) = create_signal(cx, 2);
let double_count = Signal::derive(cx, move || count() * 2);
let memoized_double_count = create_memo(cx, move |_| count() * 2);

// this function takes any kind of wrapped signal
fn above_3(arg: &Signal<i32>) -> bool {
  // βœ… calling the signal clones and returns the value
  //    it is a shorthand for arg.get()
  arg() > 3
}

assert_eq!(above_3(&count.into()), false);
assert_eq!(above_3(&double_count), true);
assert_eq!(above_3(&memoized_double_count.into()), true);

Massively improved Rust Analyzer support

DX with this new system is much better. You'll see hugely improved language-server integration for the view! macro, including features like doc comments for HTML elements, autocompletion for component properties, clicking to go to the definition of a component, type hints for component arguments, etc.

Inline documentation in the #[component] macro

You can now document components and their properties directly in the #[component] macro like this:

/// A simple counter component.
/// 
/// You can use doc comments like this to document your component.
#[component]
pub fn SimpleCounter(
  cx: Scope,
  /// The starting value for the counter
  #[prop(optional)]
  initial_value: i32,
  /// The change that should be applied each time the button is clicked.
  step: i32
) -> impl IntoView {
  // ...
}

The macro will automatically generate docs for the components and for each of its props.

#[prop] attributes for component props

You can use the #[prop] attribute macro to mark component props in several ways:

  • #[prop(into)]: This will call .into() on any value passed into the component prop. (For example,
    you could apply #[prop(into)] to a prop that takes Signal, which would
    allow users to pass a ReadSignal or RwSignal
    and automatically convert it.)
  • #[prop(optional)]: If the user does not specify this property when they use the component,
    it will be set to its default value. If the property type is Option<T>, values should be passed
    as name=T and will be received as Some(T).
  • #[prop(optional_no_strip)]: The same as optional, but requires values to be passed as None or
    Some(T) explicitly. This means that the optional property can be omitted (and be None), or explicitly
    specified as either None or Some(T).
  • #[prop(default = X)]: The property is optional, and will be set to the default value provided if it is not passed.

tracing support

We've added support for debugging using the tracing crate, integrated into both the renderer and the reactive system. This means that when an effect or an event listener fires, you can use trace!(...) to get an insight into the flow of your program. See leptos_dom/examples/test-bench for an example setup; a separate crate to make this tracing setup easier will be forthcoming.

cargo-leptos integration improvements

cargo-leptos 0.1.2 and the Actix/Axum integrations in 0.1.0 now work together seamlessly, allowing you to create full-stack applications with as little boilerplate as possible.

And much more!

  • Comments that mark component boundaries for easier debugging, when in debug mode
  • Removing the need to wrap things that <Router/> in a <div> for no obvious reason
  • builder API that allows you to crate a UI without using the view macro
  • and all sorts of things I'm forgetting!

Breaking Changes

Here are a few things to watch out for as you migrate:

  • If you're using cargo-leptos already and run into any issues (for example, with the path of a JS or Wasm file), be sure to check out the latest examples and the starter. The extra structures here have changed a bit over time as we've tried to figure out the best patterns. Cloning the starter and adding your existing application code should work fine.
  • All component functions should now return -> impl IntoView
  • The <For/> component now takes a view property, instead of you passing the view function as the child of the component
  • Likewise, the <Route/> component takes a view property instead of element for consistency
  • children properties are now typed Box<dyn Fn(Scope) -> Fragment>
  • The view! macro returns distinct structures, which are all different types. In other words, this code no longer compiles
// this won't work
if some_condition {
  view! { cx, <p>"P if true"</p> }
} else {
  view! { cx, <span>"SPAN if false"</span> }
}

because the first branch now returns HtmlElement<P> while the second returns HtmlElement<Span>.

In this case, simply add .into_any() to each to return HtmlElement<AnyElement> from both. In general, you can always call .into_view(cx) to return a wrapping View type instead.

// this works
if some_condition {
  view! { cx, <p>"P if true"</p> }.into_any()
} else if something_else {
  view! { cx, <span>"SPAN if false"</span> }.into_any()
}

v0.1.0-beta

03 Jan 00:58
@gbj gbj
Compare
Choose a tag to compare
v0.1.0-beta Pre-release
Pre-release

v0.1.0-beta

This release mostly (see crates.io) consists mainly of polishing the many changes described in the 0.1.0-alpha release notes.

Other significant improvements include:

  • New store_value() and StoredValue APIs that allow you to use the reactive system to store Copy and 'static handles to non-reactive values, just as you can with reactive signals.
  • Finally, complete integration with the cargo-leptos build tool, including transitioning most of the examples over to use cargo-leptos (except for the client-only examples, which use Trunk) (kudos and many thanks to @benwis and @akesson)
  • Restoring stable support for the new version (thanks to @jquesada2016)

... in addition to many small bug-fixes.

We're making very good progress toward a final 0.1.0 release. The only outstanding changes at this point involve improving and updating documentation, slightly loosening a couple APIs to make them easier to use (for example, allowing the path property on <Route/> to take T: impl std::fmt::Display rather than &'static str), and a few performance improvements (like optimized SSR) that will have absolutely no effect on the API exposed to users, but continue to ensure high performance and a good experience.

v0.1.0-alpha

26 Dec 04:18
@gbj gbj
Compare
Choose a tag to compare
v0.1.0-alpha Pre-release
Pre-release

A preview of v0.1.0

πŸŽ„ Merry Christmas!

I thought I'd offer this alpha release of the upcoming 0.1.0 so you can get a taste for some of what we've been working on. Shout out to @jquesada2016 for driving the work on the rewritten renderer that got us here, as well as huge improvements to the #[component] macro and many other details of the framework.

You can track the current state of this work in PR #119. You can download the alpha from crates.io.

There are a few known issues still (see below) but this release should be more or less usable, and the APIs are pretty much final. You can expect something closer to a final release in the next few weeks, but here's what to look forward to in the meantime.

Features

More flexible rendering

You can now easily mix and match different types of node in a Fragment, which previously needed to be a Vec of all the same types (like a Vec<Fragment>).

view! { cx,
  <>
    "This is some text."
    <p>"Here's an element."</p>
    <ComponentA/>
  </>
}

Typed HTML elements

HTML elements generated by the view! macro are now typed, and implement Deref to give a correctly-typed web_sys element.

// returns `HtmlElement<Input>`
// derefs to a `web_sys::HtmlInputElement`
view! { cx, <input type="text"/> }

Massively improved Rust Analyzer support

DX with this new system is much better. You'll see hugely improved language-server integration for the view! macro, including features like doc comments for HTML elements, autocompletion for component properties, clicking to go to the definition of a component, type hints for component arguments, etc.

Inline documentation in the #[component] macro

You can now document components and their properties directly in the #[component] macro like this:

/// A simple counter component.
/// 
/// You can use doc comments like this to document your component.
#[component]
pub fn SimpleCounter(
  cx: Scope,
  /// The starting value for the counter
  #[prop(optional)]
  initial_value: i32,
  /// The change that should be applied each time the button is clicked.
  step: i32
) -> impl IntoView {
  // ...
}

The macro will automatically generate docs for the components and for each of its props.

#[prop] attributes for component props

You can use the #[prop] attribute macro to mark component props in several ways:

  • #[prop(optional)]: this property is not required, and will default to Default::default() if you don't provide it in the view
  • #[prop(into)]: .into() will be called to convert the arguments provided in the view you can specify, to save you adding .into() in your views

And much more!

  • Comments that mark component boundaries for easier debugging, when in debug mode
  • Removing the need to wrap things that <Router/> in a <div> for no obvious reason
  • and all sorts of things I'm forgetting!

Breaking Changes

Here are a few things to watch out for as you migrate:

  • All component functions should now return -> impl IntoView
  • The <For/> component now takes a view property, instead of you passing the view function as the child of the component
  • Likewise, the <Route/> component takes a view property instead of element for consistency
  • children properties are now typed Box<dyn Fn(Scope) -> Fragment>
  • The view! macro returns distinct structures, which are all different types. In other words, this code no longer compiles
// this won't work
if some_condition {
  view! { cx, <p>"P if true"</p> }
} else {
  view! { cx, <span>"SPAN if false"</span> }
}

because the first branch now returns HtmlElement<P> while the second returns HtmlElement<Span>.

In this case, simply add .into_any() to each to return HtmlElement<AnyElement> from both. In general, you can always call .into_view(cx) to return a wrapping View type instead.

// this works
if some_condition {
  view! { cx, <p>"P if true"</p> }.into_any()
} else if something_else {
  view! { cx, <span>"SPAN if false"</span> }.into_any()
}

Outstanding Issues (in progress)

  • The <Transition/> component doesn't quite work properly yet.
  • SSR + hydration is slightly broken if you use create_resource and read it without using <Suspense/>
  • There may be some bugs in SSR + hydration in release mode, as this has not been fully tested yet
  • SSR is temporarily slower than the current version, as I haven't implemented the fast-path in the view! macro yet
  • Merge over stable support for leptos_router and leptos_meta