-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Rust crate leptos to v0.7.2 #77
base: main
Are you sure you want to change the base?
Conversation
870317b
to
a271c7a
Compare
a271c7a
to
9f78c49
Compare
⚠ Artifact update problemRenovate failed to update artifacts related to this branch. You probably do not want to merge this PR as-is. ♻ Renovate will retry this branch, including artifacts, only when one of the following happens:
The artifact failure details are included below: File name: sources/web-gen/Cargo.lock
File name: sources/web-gen-api/Cargo.lock
|
9f78c49
to
5b42fef
Compare
5b42fef
to
5855aa9
Compare
5855aa9
to
0127136
Compare
0127136
to
84f9fac
Compare
84f9fac
to
8850635
Compare
8850635
to
c30000f
Compare
c30000f
to
f76325e
Compare
f76325e
to
7061aa2
Compare
7061aa2
to
e8f09a8
Compare
e8f09a8
to
83c35ca
Compare
cb00f56
to
462a05e
Compare
83c35ca
to
d68893d
Compare
d68893d
to
60c05fb
Compare
60c05fb
to
1c928f8
Compare
1c928f8
to
18e9e09
Compare
|
18e9e09
to
4042406
Compare
4042406
to
61706c2
Compare
This PR contains the following updates:
0.4.5
->0.7.0
0.4
->0.7
Release Notes
leptos-rs/leptos (leptos)
v0.7.2
Compare Source
If you're migrating from 0.6 to 0.7, please see the 0.7.0 release notes here.
This is a small patch release including a couple of bugfixes, importantly to the hydration of static text nodes on
nightly
.What's Changed
popovertarget
andpopovertargetaction
for the<button>
element by @Figments in https://github.com/leptos-rs/leptos/pull/3379From<ArcStore<T>>
forStore<T, S>
by @mscofield0 in https://github.com/leptos-rs/leptos/pull/3389let:
syntax (closes #3387) by @gbj in https://github.com/leptos-rs/leptos/pull/3391nightly
(closes #3395) by @gbj in https://github.com/leptos-rs/leptos/pull/3396New Contributors
Full Changelog: leptos-rs/leptos@v0.7.1...v0.7.2
v0.7.1
Compare Source
If you're migrating from 0.6 to 0.7, please see the 0.7.0 release notes here.
This is just a small patch release, two weeks after the 0.7.0 release, geared toward fixing in bugs and filling in API holes since then.
What's Changed
Vec<_>
in the DOM (closes #3321) by @gbj in https://github.com/leptos-rs/leptos/pull/3324!Send
Actix APIs in server functions by @gbj in https://github.com/leptos-rs/leptos/pull/3326scroll
prop to<A/>
component to control scrolling behavior (closes #2666) by @gbj in https://github.com/leptos-rs/leptos/pull/3333either!
macro by @bicarlsen in https://github.com/leptos-rs/leptos/pull/3337<noscript>
(closes #3360) by @gbj in https://github.com/leptos-rs/leptos/pull/3363ToChildren::to_children
docs. by @bicarlsen in https://github.com/leptos-rs/leptos/pull/3352usize
by @marcuswhybrow in https://github.com/leptos-rs/leptos/pull/3346Signal::derive()
behavior by @gbj in https://github.com/leptos-rs/leptos/pull/3351InertElement
(closes #3368) by @gbj in https://github.com/leptos-rs/leptos/pull/3370cargo-semver-checks
on PRs by @gbj in https://github.com/leptos-rs/leptos/pull/3375New Contributors
Full Changelog: leptos-rs/leptos@v0.7.0...v0.7.1
v0.7.0
Compare Source
At long last, as the culmination of more than a year of work, the 0.7 release has arrived!
0.7 is a nearly-complete rewrite of the internals of the framework, with the following goals:
Getting Started
0.7 works with the current
cargo-leptos
version. If you want to start exploring, there are starter templates for Axum and Actix. Each template is only three files. They show some of the boilerplate differences; for more details, see below.Axum:
cargo leptos new --git https://github.com/leptos-rs/start-axum
(repo)Actix:
cargo leptos new --git https://github.com/leptos-rs/start-actix
(repo)New Features
.await
on resources andasync
in<Suspense/>
Currently,
create_resource
allows you to synchronously access the value of some async data as eitherNone
orSome(_)
. However, it requires that you always access it this way. This has some drawbacks:Now, you can
.await
a resource, and you can useasync
blocks within a<Suspense/>
via theSuspend
wrapper, which makes it easier to chain two resources:Reference-counted signal types
One of the awkward edge cases of current Leptos is that our
Copy
arena for signals makes it possible to leak memory if you have a collection of nested signals and do not dispose them. (See 0.6 example.) 0.7 exposesArcRwSignal
,ArcReadSignal
, etc., which areClone
but notCopy
and manage their memory via reference counting, but can easily be converted into the copyableRwSignal
etc. This makes working with nested signal correctly much easier, without sacrificing ergonomics meaningfully. See the 0.7counters
example for more..read()
and.write()
on signalsYou can now use
.read()
and.write()
to get immutable and mutable guards for the value of a signal, which will track/update appropriately: these work like.with()
and.update()
but without the extra closure, or like.get()
but without cloning.Custom HTML shell
The HTML document "shell" for server rendering is currently hardcoded as part of the server integrations, limiting your ability to customize it. Now you simply include it as part of your application, which also means that you can customize things like teh
<title>
without needing to useleptos_meta
.Enhanced attribute spreading
Any valid attribute can now be spread onto any component, allowing you to extend the UI created by a component however you want. This works through multiple components: for example, if you spread attributes onto a
Suspense
they will be passed through to whatever it returns.Improved
<ProtectedRoute/>
The current
ProtectedRoute
component is not great: it checks the condition once, synchronously, on navigation, and so it doesn't respond to changes and can't easily be used with async data. The newProtectedRoute
is reactive and uses Suspense so you can use resources or reactive data. There are examples of this now inrouter
andssr_modes_axum
.Two-way binding with
bind:
syntaxTwo-way binding allows you to pass signals directly to inputs, rather than separately managing
prop:value
andon:input
to sync the signals to the inputs.Reactive Stores
Stores are a new reactive primitive that allow you to reactively access deeply-nested fields in a struct without needing to create signals inside signals; rather, you can use plain data types, annotated with
#[derive(Store)]
, and then access fields with reactive getters/setters.Updating one subfield of a
Store
does not trigger effects only listening to a sibling field; listening to one field of a store does not track the sibling fields.Stores are most useful for nested data structures, so a succinct example is difficult, but the
stores
example shows a complete use case.Support the View Transition API for router animations
The
Routes
/FlatRoutes
component now have atransition
prop. Setting this totrue
will cause the router to use the browser's View Transition API during navigation. You can control animations during navigation using CSS classes. Which animations are used can be controlled using classes that the router will set on the<html>
element:.routing-progress
while navigating,.router-back
during a back navigation, and.router-outlet-{n}
for the depth of the outlet that is being changed (0
for the root page changing,1
for the firstOutlet
, etc.) Therouter
example uses this API.Breaking Changes
Imports
I'm reorganizing the module structure to improve docs and discoverability. We will still have a prelude that can be used for glob imports of almost everything that's currently exported from the root.
Likewise, the router exposes things via
leptos_router::components
andleptos_router::hooks
. rust-analyzer can help fix imports fairly well.I'm hoping for feedback on the new module structure, whether it makes sense, and any improvements. I have not done too much work to sort through the reexports, look at how docs look, etc. yet.
Naming
We're migrating away from
create_
naming toward more idiomatic Rust naming patterns:create_signal
tosignal
(likechannel
)create_rw_signal
toRwSignal::new()
I've left some of the current functions in, marked deprecated; others may have been missed, but should be easy to find via docs.rs.
Type erasure and view types
One of the major changes in this release is replacing the
View
enum with statically-typed views, which is where most of the binary size savings come from. If you need to branch and return one of several types, you can either use one of theEither
enums inleptos::either
, or you can use.into_any()
to erase the type. Generally speaking the compiler can do its job better if you maintain more type information so theEither
types should be preferred, butAnyView
is not bad to use when needed.Boilerplate
There have been changes to the SSR and hydration boilerplate, which include (but aren't limited to)
get_configuration
is sync (remove the.await
).leptos_routes
no longer takesLeptosOptions
as an argumentleptos::mount::hydrate_body
(hydration) instead ofleptos::mount::mount_to_body
(which is now CSR-specific)Check the starter templates for a good setup.
Route definitions
The patterns for route definition have changed in several ways.
fallback
is now a required prop on<Routes/>
, rather than an optional prop on<Router/>
<FlatRoutes/>
component that optimizes for this case<ParentRoute/>
path="foo"
becomespath=StaticSegment("foo")
, and there arepath=":id"
becomespath=ParamSegment("id")
,path="posts/:id"
becomespath=(StaticSegment("posts"), ParamSegment("id"))
, and so on. There is apath!()
macro that will do this for you: i.e., it will expandpath!("/foo/:id")
topath=(StaticSegment("foo"), ParamSegment("id"))
.See the
router
andhackernews
examples.Send
/Sync
signalsBy default, the data held in reactive primitives (signals, memos, effects) must be safe to send across threads. For non-threadsafe types, there is a "storage" generic on signal types. This defaults to
SyncStorage
, but you can optionally specifyLocalStorage
instead. Many APIs have_local()
alternatives to enable this.Custom
IntoView
andIntoAttribute
implementationsIf you currently have implementations of
IntoView
orIntoAttribute
for custom data types, in a way that allows you to use them directly in the view, you should replace those with implementations ofIntoRender
andIntoAttributeValue
, respectively. See this PR for examples.Minor Breaking Changes
Await
component now takes a plainFuture
for itsfuture
prop rather than aFn() -> Future
, because it uses an optimized resource implementationIntoRender
rather thanIntoView
(see discussion in #3062)ParamsMap
supports multiple values per key (which is supported by query strings), so the API now differentiates between inserting a new value for the same key and replacing the value, and between getting one value and getting all values for a keyStylesheet
component no longer automatically works with the file hashing feature ofcargo-leptos
. You can useHashedStylesheet
and pass it the appropriate props instead.<A>
component with aclass
prop that set theclass
on the<a>
element.) These have been replaced by the new attribute-spreading API, to reduce complexity of the components themselves.LeptosOptions
now usesArc<str>
for its fields that were formerlyString
, so that it is less expensive to clone. In practice, this usually only means using&field
orfield.as_ref()
in a few places that require&str
, and so on.experimental-islands
feature renamed toislands
batch
function no longer exists: all updates now exhibit the batching behavior that was previously opt-in viabatch
.into_any()
at the end of the component that you are going to use recursively.Signal<T>
no longer directly implementsFrom<Fn() -> T>
, which allows it to implementFrom<T>
and therefore to be a more useful replacement forMaybeSignal<T>
, for a prop that is "someT
or any signal that returnsT
." To convert a closure into aSignal<_>
you can callSignal::derive()
explicitly. I know this makes the ergonomics of using theSignal<_>
wrapper slightly worse, but it adds additional expressiveness by supporting plainT
. (If you want to keep the old behavior, consider takingimpl Fn() -> T
as a prop if you are using nightly, where all the signals as well as closures implement this trait.)Miscellaneous
I'm sure there are a bunch of small and larger changes I have not mentioned above. By the time of final release, help compiling a total list of breaking changes/migration guide would be much appreciated. At present, the starter templates and the
examples
directory in the PR can provide a pretty comprehensive set of changes.On storing views in signals...
There's a pattern I've seen many use that I do not particularly like, but accidentally enabled through the way APIs happened to be (or needed to be) designed in Leptos 0.1-0.6, in which a user stores some view in a signal and then reads it somewhere else. This was possible because
View
needed to beClone
for internal reasons. Some users used this to create custom control flow: for example, you could create a global "header view" signal, and then update it from leaf components by storing a new view in it.I'd consider this a bit of an antipattern, for a couple reasons:
Clone
but in a surprising way: you can clone the reference to a DOM node, but that is a shallow, not a deep clone, and if you use it in multiple places by.get()
ing the signal more than once, it will only appear in the last locationIn the statically-typed view tree, views are not necessarily cloneable (including the
AnyView
type), so they can't easily be stored in a signal.However, it is possible to achieve a similar goal by using a "reactive channel" pattern instead:
Send the views through a channel means they do not need to be cloned, and won't be used in more than once place (avoiding the edge cases of 2 above.) Each time you send a view through the channel, simply trigger the trigger.
v0.6.15
Compare Source
Belated release notes for 0.6.15. This was a quick patch release to incorporate two changes, one to improve rust-analyzer support and the other to switch from the unmaintained
proc-macro-error
toproc-macro-error2
per RUSTSEC.What's Changed
proc-macro-error2
to address unmaintained security advisory. by @azriel91 in https://github.com/leptos-rs/leptos/pull/2935Full Changelog: leptos-rs/leptos@v0.6.14...v0.6.15
v0.6.14
Compare Source
Hello everyone, The biggest change in this update is to handle wasm-bindgen 0.2.93 and web_sys 0.3.70 Thanks to @sabify and @maccesch for those PRs. As always, let us know if there's issues.
What's Changed
wasm-bindgen
andweb-sys
for leptos 0.6 by @sabify in https://github.com/leptos-rs/leptos/pull/2830New Contributors
Full Changelog: leptos-rs/leptos@v0.6.13...v0.6.14
v0.6.13
Compare Source
This release mostly includes a series of small bugfixes (see below), but also includes a fix for the annoying issues we'd been having with rust-analyzer (#2527).
What's Changed
rkyv
feature interaction with Axum integration by @gbj in https://github.com/leptos-rs/leptos/pull/2631ToChildren
by @spencewenski in https://github.com/leptos-rs/leptos/pull/2643New Contributors
Full Changelog: leptos-rs/leptos@v0.6.12...v0.6.13
v0.6.12
Compare Source
This is mainly a maintenance release, but includes a couple new features that I want to point out:
impl Trait
in Component PropsYou can now use
impl Trait
syntax directly in component props, rather than explicitly specifying a generic and awhere
clausebefore
after
Support spreading dynamic attributes from one component to another
In the following code
Bar
doesn't currently inherit attributes fromFoo
when it spreads its attributes. PR #2534 fixes this.Complete Changelog
<ActionForm>
onformmethod="dialog"
submission (closes #2523) by @gbj in https://github.com/leptos-rs/leptos/pull/2531Oco
separately asoco_ref
crate so that it can be used elsewhere by @gbj in https://github.com/leptos-rs/leptos/pull/2536input_derive
parameter to#[server]
macro (closes #2544) by @luxalpa in https://github.com/leptos-rs/leptos/pull/2545empty_docs
warnings in#[component]
macro by @abusch in https://github.com/leptos-rs/leptos/pull/2574--release
) by @gbj in https://github.com/leptos-rs/leptos/pull/2587#[component]
now handlesimpl Trait
by converting to generic type params, fix #2274 by @MingweiSamuel in https://github.com/leptos-rs/leptos/pull/2599New Contributors
Full Changelog: leptos-rs/leptos@v0.6.11...v0.6.12
v0.6.11
Compare Source
The primary purpose of this release is that it includes a fix for an unfortunate memory leak when using
leptos_router
on the server.Also included are
spread
example for the full set of possibilities)IntoView
directly forRc<str>
view
macroIt's important to me to say that all three of the new features above were implemented by community members. This release brings us to over 250 total contributors over time, not to mention everyone who's done work on docs, templates, or libraries that exist outside this repo. Thank you to everyone who's been involved in this project so far.
What's Changed
Location
header when usingleptos_actix::redirect()
without JS/WASM (closes #2506) by @gbj in https://github.com/leptos-rs/leptos/pull/2507counter_isomorphic
by @gbj in https://github.com/leptos-rs/leptos/pull/2510New Contributors
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about these updates again.
This PR was generated by Mend Renovate. View the repository job log.