Skip to content
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

Experiment with a structless variant of Yew #2957

Closed
wants to merge 48 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
8ea2cb6
Allow functions to be pushed to scheduler.
futursolo Nov 7, 2022
14705f6
Remove component type.
futursolo Nov 7, 2022
0d42e3a
Remove update lifecycle.
futursolo Nov 7, 2022
b6d8da7
Remove changed lifecycle.
futursolo Nov 7, 2022
ec7e47d
Remove props update queue.
futursolo Nov 7, 2022
889d22c
Remove priority rendering.
futursolo Nov 7, 2022
7abacb1
Remove generics on components.
futursolo Nov 7, 2022
0b73e2b
Remove generics from FunctionComponent.
futursolo Nov 8, 2022
8c47f0d
Rewrite context provider in function component.
futursolo Nov 8, 2022
73103e2
Remove delegated lifecycle on components.
futursolo Nov 8, 2022
3f7fc52
Add props check.
futursolo Nov 8, 2022
7f7f208
Remove more lifecycles.
futursolo Nov 8, 2022
f3db00d
Remove extra render cycles.
futursolo Nov 8, 2022
bc08fb8
Remove all runners.
futursolo Nov 8, 2022
6ab3edd
Ssr no longer needs any lifecycle.
futursolo Nov 8, 2022
159cbd8
Remove has_rendered.
futursolo Nov 8, 2022
a5e31fc
Remove duplication.
futursolo Nov 8, 2022
2319f4e
Fix feature soundness.
futursolo Nov 8, 2022
01e56a3
Remove typed scope.
futursolo Nov 9, 2022
eb989fe
Remove boxed scoped.
futursolo Nov 9, 2022
cf035aa
Make ComponentIntriustic.
futursolo Nov 9, 2022
162c223
Remove more allocations.
futursolo Nov 9, 2022
f374bc2
Fix naming.
futursolo Nov 9, 2022
0923dce
Fix naming.
futursolo Nov 9, 2022
d5f680f
Remove unused code.
futursolo Nov 9, 2022
01d37b6
Remove redundant lints.
futursolo Nov 9, 2022
e0e9468
Features should now sound.
futursolo Nov 9, 2022
5d86d16
Merge branch 'master' into structless
futursolo Nov 9, 2022
6818538
Fix new features.
futursolo Nov 9, 2022
4c4935d
Remove RefCell from HookContext.
futursolo Nov 9, 2022
c440f14
Hope we no longer have to deal with feature soundness.
futursolo Nov 9, 2022
ce5890e
Move props_eq to ComponentIntrinsic.
futursolo Nov 9, 2022
54ec5a0
Remove AnyFunctionProvider.
futursolo Nov 9, 2022
b2c1e04
Remove boxing on schedule render as well.
futursolo Nov 10, 2022
7cbdc02
Remove scheduler.
futursolo Nov 10, 2022
ecfb115
Remove scheduler start as well.
futursolo Nov 10, 2022
6d044dc
Merge FunctionProvider and Component traits.
futursolo Nov 10, 2022
4892fe2
Remove FunctionComponent.
futursolo Nov 10, 2022
c67d1c9
Merge BaseComponent and Component.
futursolo Nov 10, 2022
581aa16
Remove Context.
futursolo Nov 10, 2022
e32bff0
Fix features.
futursolo Nov 10, 2022
2c9083a
Fix variable names.
futursolo Nov 10, 2022
ff9f118
Remove renderable as well.
futursolo Nov 10, 2022
70574ab
Remove reuse as well.
futursolo Nov 10, 2022
8aa970a
Remove unused labels.
futursolo Nov 10, 2022
2938db1
Remove tests as they no longer works.
futursolo Nov 10, 2022
e9b60b3
Break reference cycle.
futursolo Nov 11, 2022
c31c47b
Prevent unnecessary rendering.
futursolo Nov 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions examples/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/ssr_router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ env_logger = "0.9"
clap = { version = "3.1.7", features = ["derive"] }
hyper = { version = "0.14", features = ["server", "http1"] }
jemallocator = "0.5"
tracing = { version = "0.1", features = ["log-always"] }

[features]
ssr = ["yew/ssr"]
Expand Down
66 changes: 3 additions & 63 deletions packages/yew-macro/src/function_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,64 +270,6 @@ impl FunctionComponent {
}
}

fn print_base_component_impl(&self) -> TokenStream {
let component_name = self.component_name();
let props_type = &self.props_type;
let static_comp_generics = self.create_static_component_generics();

let (impl_generics, ty_generics, where_clause) = static_comp_generics.split_for_impl();

// TODO: replace with blanket implementation when specialisation becomes stable.
quote! {
#[automatically_derived]
impl #impl_generics ::yew::html::BaseComponent for #component_name #ty_generics #where_clause {
type Message = ();
type Properties = #props_type;

#[inline]
fn create(ctx: &::yew::html::Context<Self>) -> Self {
Self {
_marker: ::std::marker::PhantomData,
function_component: ::yew::functional::FunctionComponent::<Self>::new(ctx),
}
}

#[inline]
fn update(&mut self, _ctx: &::yew::html::Context<Self>, _msg: Self::Message) -> ::std::primitive::bool {
true
}

#[inline]
fn changed(&mut self, _ctx: &::yew::html::Context<Self>, _old_props: &Self::Properties) -> ::std::primitive::bool {
true
}

#[inline]
fn view(&self, ctx: &::yew::html::Context<Self>) -> ::yew::html::HtmlResult {
::yew::functional::FunctionComponent::<Self>::render(
&self.function_component,
::yew::html::Context::<Self>::props(ctx)
)
}

#[inline]
fn rendered(&mut self, _ctx: &::yew::html::Context<Self>, _first_render: ::std::primitive::bool) {
::yew::functional::FunctionComponent::<Self>::rendered(&self.function_component)
}

#[inline]
fn destroy(&mut self, _ctx: &::yew::html::Context<Self>) {
::yew::functional::FunctionComponent::<Self>::destroy(&self.function_component)
}

#[inline]
fn prepare_state(&self) -> ::std::option::Option<::std::string::String> {
::yew::functional::FunctionComponent::<Self>::prepare_state(&self.function_component)
}
}
}
}

fn print_debug_impl(&self) -> TokenStream {
let component_name = self.component_name();
let (impl_generics, ty_generics, where_clause) = self.generics.split_for_impl();
Expand All @@ -349,7 +291,8 @@ impl FunctionComponent {
let component_impl_attrs = self.filter_attrs_for_component_impl();
let component_name = self.component_name();
let fn_name = self.inner_fn_ident();
let (impl_generics, ty_generics, where_clause) = self.generics.split_for_impl();
let static_ty_generics = self.create_static_component_generics();
let (impl_generics, ty_generics, where_clause) = static_ty_generics.split_for_impl();
let props_type = &self.props_type;
let fn_generics = ty_generics.as_turbofish();

Expand All @@ -360,7 +303,7 @@ impl FunctionComponent {
// we cannot disable any lints here because it will be applied to the function body
// as well.
#(#component_impl_attrs)*
impl #impl_generics ::yew::functional::FunctionProvider for #component_name #ty_generics #where_clause {
impl #impl_generics ::yew::html::Component for #component_name #ty_generics #where_clause {
type Properties = #props_type;

fn run(#ctx_ident: &mut ::yew::functional::HookContext, #component_props: &Self::Properties) -> ::yew::html::HtmlResult {
Expand All @@ -386,7 +329,6 @@ impl FunctionComponent {
#[allow(unused_parens)]
#vis struct #component_name #generics #where_clause {
_marker: ::std::marker::PhantomData<(#phantom_generics)>,
function_component: ::yew::functional::FunctionComponent<Self>,
}
}
}
Expand Down Expand Up @@ -418,7 +360,6 @@ pub fn function_component_impl(
) -> syn::Result<TokenStream> {
component.merge_component_name(name)?;

let base_comp_impl = component.print_base_component_impl();
let debug_impl = component.print_debug_impl();
let provider_fn_impl = component.print_fn_provider_impl();
let struct_def = component.print_struct_def();
Expand All @@ -428,7 +369,6 @@ pub fn function_component_impl(

#provider_fn_impl
#debug_impl
#base_comp_impl
};

Ok(quoted)
Expand Down
2 changes: 1 addition & 1 deletion packages/yew-macro/src/html_tree/html_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl ToTokens for HtmlComponent {
} = self;

let ty_span = ty.span().resolved_at(Span::call_site());
let props_ty = quote_spanned!(ty_span=> <#ty as ::yew::html::BaseComponent>::Properties);
let props_ty = quote_spanned!(ty_span=> <#ty as ::yew::html::Component>::Properties);
let children_renderer = if children.is_empty() {
None
} else {
Expand Down
2 changes: 0 additions & 2 deletions packages/yew-router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ pub mod hooks;
pub mod navigator;
mod routable;
pub mod router;
pub mod scope_ext;
pub mod switch;
pub mod utils;

Expand All @@ -99,7 +98,6 @@ pub mod prelude {
pub use crate::history::Location;
pub use crate::hooks::*;
pub use crate::navigator::{NavigationError, NavigationResult, Navigator};
pub use crate::scope_ext::{LocationHandle, NavigatorHandle, RouterScopeExt};
#[doc(no_inline)]
pub use crate::Routable;
pub use crate::{BrowserRouter, HashRouter, Router, Switch};
Expand Down
145 changes: 0 additions & 145 deletions packages/yew-router/src/scope_ext.rs

This file was deleted.

1 change: 1 addition & 0 deletions packages/yew/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ serde = { version = "1", features = ["derive"] }
tracing = "0.1.36"
prokio = "0.1.0"
rustversion = "1"
typed-builder = "0.11.0"

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen-futures = "0.4"
Expand Down
Loading