112 Commits

Author SHA1 Message Date
Muhammad Hamza
cc9dd0271e
Update dependencies (#3171)
* Update to syn 2

* bless macro outputs

* update prettyplease

* fix review + update lockfile
2023-03-28 19:41:55 +09:00
Vlad Beskrovny
c7b7e45e4c
Implement component name completion in html! for IntelliJ Rust plugin (#2972) 2023-02-02 22:36:51 +09:00
Cecile Tonglet
bff497e002
Pass string types to Html props (#2872)
* Pass string types to Html props

* Not sure why passing None explicitly here...

* Update test stderr
2023-02-02 20:00:51 +09:00
Kaede Hoshikawa
456a05ba40
Fix clippy for 1.67 (#3100)
* Fix clippy for 1.67

* Fix trybuild.
2023-02-01 21:57:05 +05:00
Cecile Tonglet
772763c2e2
Make Classes cheap to clone (#3021)
* Use AttrValue instead of Cow in Classes

* Wrap indexset into Rc

* Impl ImplicitClone for Classes

* clippy

* Trigger CI

* Update macro stderr

* Copy optimization made for String to AttrValue

* Update macro stderr again
2022-12-10 18:02:36 +05:00
WorldSEnder
9e980a36b4
Fix clippy::let_unit_value lint in propless components (#2970) 2022-12-09 00:10:22 +05:00
IchHabeKeineNamen
77b0d40455
fix: dead links (#3013) 2022-12-06 06:31:35 +00:00
GitHub Action
1bbe75ec9b (cargo-release) version {{crate_name}}-v{{version}} 2022-11-25 18:28:11 +05:00
Christopher Schramm
b649e9dacd
Avoid clippy::let-underscore-drop (#2952)
The following main.rs replicates the clippy warning:

```
use yew::prelude::*;

struct Props {
    droppable: Vec<()>,
}

fn component(props: &Props) -> Html {
    let props = Props { droppable: Vec::new() };
    html! { <Component ..props /> }
}

fn main() {}
```

If I'm not mistaken this happens when using the `..` on any `Properties` with a field that implements `Drop`.
2022-11-08 21:21:06 +05:00
Muhammad Hamza
7ada3447bb
Fix issues with tuples in closing tag (#2886)
* Add test case for #2225

* Fix issues with tuples in closing tag

* Improve diagnostics

* fmt

* better diagnostics
2022-10-08 20:59:08 +05:00
WorldSEnder
bb71b5db61
Fix checked property being reset (#2907)
if the value is uncontrolled, do not touch it. Only if it is explicitly given
2022-10-08 20:50:19 +05:00
Muhammad Hamza
426a1fd81d
Evaluate props in the order they're defined (#2887)
* don't change order of props

* rename `SortedPropList` to `PropList`

* docs + test

* remove dead code

* fmt
2022-10-08 10:40:55 +02:00
Muhammad Hamza
9e0d7966bc
Make Yew lints opt-in (#2882)
* Add compiler flag for Yew lints

* Use --cfg yew_lints in CI

* Remove lints feature

* bless the fail.stderr

* Fix CI
2022-09-25 21:54:24 +09:00
Muhammad Hamza
7e24fb3c58
Clippy fixes (#2881)
* Clippy in root

* Clippy in examples

* didn't mean to commit this file
2022-09-25 21:25:23 +09:00
Cecile Tonglet
81f7ea482b
implement html from Option<VNode> (#2792)
Co-authored-by: Martin Molzer <WorldSEnder@users.noreply.github.com>
2022-09-14 18:04:12 +05:00
WorldSEnder
8eb9b5a4dc
Error on refs on components (#2863)
* error on `ref` with components

r#ref is still allowed, so we reserve the right to reintroduce
the syntax

* fix node_refs example
2022-09-13 16:50:33 +02:00
Cecile Tonglet
c7b4029e1b
Add old props to fn changed() (#2851)
* Adding old_props to fn changed()

* Change old_props type to &Self::Properties

* Update examples that use fn changed() and want old_props

* Fix tests

* Fix invalid test flags

* cargo fmt

* Oops wrong regex

* Revert change for older version

* Remove unnecessary clone

* Add migration guide

* Oh wow the test was not running xD
2022-08-31 17:10:45 +05:00
Muhammad Hamza
4c35f95350
Bind to properties instead of attributes by default (#2819)
* Set to properties, not attributes

* fix tests

* Add tests

* enable disabled test, fmt

* Introduce @key syntax to forcefully set as attribute

* Everything compiles

* More tests

* id as property

* This was not meant to be committed

* Make test pass, fmt + clippy

* fucking rustfmt

* is this enough formatting

* that was not supposed to be commited

* apply review

* fmt

* fix CI

* will you be happy now, clippy?
2022-08-14 21:41:04 +02:00
Muhammad Hamza
a4e70914ac
Convert nightly from a feature flag to a compiler flag (#2827)
* `nightly_yew` compiler flag instead of `nightly` feature

* update ci

* update ci: 2

* fmt & nightly_yew for examples

* update size-cmp too
2022-08-15 04:03:45 +09:00
Kaede Hoshikawa
989d804947
Fix Clippy for 1.63 (#2825) 2022-08-12 22:16:05 +09:00
Muhammad Hamza
f640fc7c18
Allow keywords after dash in element and attribute names (#2820) 2022-08-08 23:36:10 +02:00
Muhammad Hamza
544990a6b4
Remove component NodeRef (#2783)
* don't attach noderef to components, add test case

* remove node_ref from VNode and VComp

* fmt & macro tests

* remove uneeded test & todo

this test is done at compile time. there's no node_ref field so it can't be set

* feature soundness & clippy

* add marker field, in an attempt to reduce bundle size

* Update migration guide
2022-07-21 01:32:26 +09:00
Kaede Hoshikawa
9d94f24a11
Prepared States dependency should be Reference Counted (#2769)
* Makes Prepared States to be Rc'ed.

* Update example.

* Make prepared states work on none runtime as well.

* Remove more feature flags.

* Users always have to manually construct dependency into Rc.

* Import Rc.

* Revert "Users always have to manually construct dependency into Rc."

This reverts commit 9eee1da3e9a46e69a7b07e6064eb163e06261bfb.

* Revert "Import Rc."

This reverts commit d6bb90dc155d2bf87fd18eec4b78b8e07a9cc7a7.
2022-07-19 22:59:39 +09:00
wdcocq
5570710cdf
Fixed NodeRef not being implicitly cloned with components (#2775)
* Use IntoPropValue for node refs in html component

* Add NodeRef ImplicitClone test for html element

* Change node_refs example to use ImplicitClone

* Reuse key and ref attribute wrapping
2022-07-07 21:00:27 +05:00
Kaede Hoshikawa
7f5eb3890c
Streamed SSR Response (#2697)
* yew::platform?

* Stream Response.

* Migrate example

* Remove old implementation.

* Remove extra implementation.

* Prefer String instead of Cow.

* Fix MSRV.

* Fix trybuild.

* Optimise Memory Allocation.

* More optimisation.

* BufWriter.

* Fix tests.

* Optimise BufWriter.

* Remove more allocations.

* Allow setting of buffer capacity.

* Fix capacity size.

* Fix capacity size.

* Remove unneeded const notation.

* Fix macro tests.

* Slightly optimises BufWriter committing logic.

* Optimise Implementation.

* Move BufWriter to a separate file.

* Additional Implementation Note.

* Adjust API so it matches `std::channel::mpsc::channel`.

* Fix feature soundness.

* Make a compatibility layer on channels.

* Fix clippy.

* Fix feature soundness.

* Fix CI.

* Inlining.

* Add documentation.

* Punctuation.

* Switch to tokio channel.

* Remvoe pin-project.

* Fix feature soundness.

* Typo.

* Move io to platform.

* Tokio does not compile.

* Fix workflow.

* Restore wrongly removed docs.

* Does tokio work?

* Switch back to tokio.

* Remove pin-project.

* Use cargo resolver 2.

* Add panic notice.

* Update documentation.

* Properties does not have to be send.

* Fix capacity checking as pointed in the review.

* Implementation order.

* Update note.
2022-07-01 14:26:12 +05:00
Cecile Tonglet
7ddf26752f
Introduce immutable string, array and map (#2563) 2022-06-24 16:58:20 +01:00
Kaede Hoshikawa
6b89e21034
Migrate to once_cell (#2750)
* Replace lazy_static with once_cell.

* Migrate to clap v3, so 1 less lazy_static.

* Convert with `.into()`.
2022-06-24 19:32:00 +05:00
Muhammad Hamza
54de041981
Nightly features (#2743)
* Nightly features

* Tests

* Fix tests

* Don't invent new syntax

* Do not impl Fn for UseReducerHandle

* Simplify UseForceUpdateHandle

* Manually specify clippy features

* Revert "Simplify UseForceUpdateHandle"

This reverts commit 761dbb0f8bb7c280054d55dcc724f08604ee4ece.

* `UseForceUpdateHandle`

* fmt
2022-06-24 19:21:02 +05:00
Kaede Hoshikawa
a5973bdca6
Allow VNode props to be converted to Children. (#2749)
* Allow VNode props to be converted to Children.

* Also implement ChildrenWithProps as well.

* Update macro tests.
2022-06-24 19:06:09 +05:00
WorldSEnder
cda74c464b
Fix generic props structs (#2746)
* fixup of generic props structs

* fix build errors from msrv 1.57 on time crate

* build wasm-bindgen-cli with cargo +stable
2022-06-23 11:21:52 +02:00
WorldSEnder
75bb9031cd
Redo derive(Properties), take 2 (#2729)
* remove props checking, but take builder by mut ref

* allow property name `build`

* add rough state token machinery

* first working impl, readd props checking

* improve error message

* add documentation and last adjustements

* address review
2022-06-21 22:33:57 +02:00
Muhammad Hamza
526ecb975e
Increase MSRV to 1.56.1 (#2740) 2022-06-19 18:45:52 +05:00
WorldSEnder
e68060afa7
Span hygene and editor UX (#2702)
* add span for closing tag to macro expansion

* decouple name resolution from locations

* commit to new macro errors
2022-05-25 13:01:10 +02:00
Kaede Hoshikawa
b29b4535b7
use_prepared_state & use_transitive_state (#2650)
* Some initial implementation.

* Read prepared state during hydration.

* Decode each state with bincode.

* Feature gate prepared state.

* Update documentation.

* Switch from base64 to String.

* cargo +nightly fmt.

* Fix test.

* Add some tests.

* Minor adjustments.

* Remove unused marker.

* Update example.

* Add use_transitive_state.

* Remove unused dead code notation.

* Opt for better code size.

* Add tests for use_transitive_state.

* Fix cargo fmt.

* Fix rustdoc.

* Asynchronously decode data during hydration.

* Fix feature flags.

* Fix docs.

* Feature flags on ssr_router.

* Adjust workflow to reflect feature flags.

* Fix features.

* Restore wasm-bindgen-futures to be wasm32 only.

* Revert wasm-bindgen-futures.

* Second attempt to remove wasm-bindgen-futures.

* Remove spaces as well.

* Address reviews.

* Better diagnostic message.

* Update diagnostic messages.
2022-05-24 13:35:16 +09:00
WorldSEnder
6f6c61b975
Allow macro invocations as prop values (#2687)
* fix: macro invocations in props #2267

convert macro invocation Item statements to Exprs

* remove now useless braces in docs
2022-05-18 07:58:46 +02:00
WorldSEnder
1d579a8bf4
Rework a bunch of cfg(feature) flags to be more principled (#2666)
* rework a bunch of feature flags to be more principled

* fixup of Collectable

* silence clippy

* unfix Mountable trait

leads to bundle size increase, so stick to the optimized version

* use required-features for function_router

* use --all-features in various places

* disable tokio dependency on wasm tests again

* add some #[inline] annotations

* merge one more feature annotations

* fixup: remove a line connected to trace_hydration
2022-05-07 21:17:47 +05:00
Muhammad Hamza
18f004bc57
Fix cargo make config and tests (#2640)
* remove pr-flow, run all the tests when asked

* make tests that were never run pass

* run tests cargo make properly

* use wasm-pack-base test for running wasm tests

* cargo make config should be good

* update CI
2022-04-28 21:04:55 +05:00
Muhammad Hamza
c28a71e78e
Use nightly for Rustfmt (#2630)
* add rustfmt.toml, use nightly in CI, update contributing docs

* run `cargo +nightly fmt`
2022-04-21 23:21:15 +05:00
Kaede Hoshikawa
c5b7790949
Remove IntoComponent (#2579)
* Make Function Component to Implement BaseComponent.

* Remove IntoComponent.

* Inline some methods.

* Move some logic out of proc macro.

* Move position of the self generics.

* Discourage direct implementation `FunctionComponent` & `#[doc(hidden)]`.
2022-04-16 00:44:39 +02:00
Kaede Hoshikawa
6fb547339f
Fix some Hook edge cases (#2592)
* Fix a couple edge cases.

* no implicit prelude.
2022-04-16 01:47:04 +05:00
Kaede Hoshikawa
6d07ba3b90
Fix generic with impl trait. (#2589) 2022-04-07 19:45:26 +05:00
Muhammad Hamza
2f3b90ce2c
Fix macro hygine issues (#2585)
* no_implicit_prelude in macro tests

* #[automatically_derived] and #[doc(hidden)]

* Span::call_site() -> Span::mixed_site()
2022-04-07 01:14:00 +05:00
WorldSEnder
8978baa45d
Fix casing of dynamic tags (#2578)
* fix casing of dynamic tags
* add test case for unknown tag names
* add lint for non-normalized tags
2022-04-05 19:07:31 +02:00
Finn Bear
ea8a530454
Fix #2553 - automatically convert closure to callback for component properties (#2554)
* Fix #2553 - automatically convert closure to callback for component properties.

* Support F -> Option<Callback<_>> too.

* test stderr.
2022-03-28 00:43:53 +02:00
Kaede Hoshikawa
8bc2212716
#[cfg(feature = "render")] and yew::Renderer (#2498)
* Bring changes to this branch.

* Bring changes to this branch.

* Add feature render and renderer.

* Bring changes to this branch.

* Migrate examples to Renderer.

* Satisfy no any render.

* Satisfy ssr.

* Satisfy feature render.

* Lint feature soundness.

* Suppress tests.

* Fix pr-flow, update docs.

* Add a notice.

* Adjust visibility.

* Correctly feature gate tests.

* make test scope available under feature render.

* Fix CI.

* Fix CI.

* Restore tests module to its original place as well.

* Make bundles crate private.

* Make most bundle APIs private.

* Adjust docs.

* Adjust debug implementation.

* Replace start_app with Renderer.

* Adjust documentation.

* Remove unused lint.

* Remove start_app from docs.

* DomBundle -> ReconcileTarget.

* Adjust documentation.

* Once render, now csr.

* Fix docs as well.
2022-03-20 00:48:47 +09:00
Kaede Hoshikawa
51238fb0e3
Better Function Component in docs + Macro-based Hooks (#2478)
* Fix const function component.

* Show Properties on the function definition.

* Filter certain doc attributes to be applied to type alias. More precise warnings.

* Implement macro-based hook.

* Add fail case.

* Function Component no longer a type alias.

* Clippy!

* Force 'static on generics.

* Fix clippy!

* Fix clippy and trybuild.

* Fix clippy and trybuild.

* Fix clippy.

* BaseComponent was not sealed properly.

* Adjust prelude.

* Public API should use IntoComponent for better ergonomics.

* Fix race condition.

* Fix trybuild.
2022-03-08 18:03:40 +05:00
Kaede Hoshikawa
fc067ab56c
Fix Call Generics & FnOnce macro hygiene (#2437)
* Fix Call Generics & FnOnce macro hygiene.

* Add a failure case as well.

* Remove a unused struct in test case.

* Update packages/yew-macro/tests/hook_attr/hook-const-generic-pass.rs

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>
2022-02-12 18:26:23 +05:00
Kaede Hoshikawa
485a1b8c4a
Function Components & Hooks V2 (#2401)
* Make a use_hook hook with the new Hook trait.

* Implement Lifetime.

* Rewrites function signature.

* Only apply lifetime if there're other lifetimes.

* Cleanup signature rewrite logic.

* Rewrite hook body.

* Port some built-in hooks.

* Finish porting all built-in hooks.

* Port tests.

* Fix tests.

* Migrate to macro-based hooks.

* Fix HookContext, add tests on non-possible locations.

* Fix stderr for trybuild.

* Add 1 more test case.

* Adjust doc location.

* Pretty print hook signature.

* Fix Items & std::ops::Fn*.

* Add use_memo.

* Optimise Implementation of hooks.

* Use Box to capture function value only.

* Detect whether needs boxing.

* Add args if boxing not needed.

* Enforce hook number.

* Deduplicate use_effect.

* Optimise Implementation.

* Update documentation.

* Fix website test. Strip BoxedHook implementation from it.

* Allow doc string.

* Workaround doc tests.

* Optimise codebase & documentation.

* Fix website test.

* Reduce implementation complexity.

* Destructor is no more.

* Documentation and macros.

* Reduce heap allocation and hook complexity.

* Remove Queue as well.

* Prefer Generics.

* Fix typo.

* Remove more allocations.

* Add comments.

* Remove outdated comment.

* Bare Function Pointer for better code size.
2022-01-28 11:51:37 +02:00
Muhammad Hamza
f05ba4152c
Update to edition 2021 (#2354)
* cargo fix --edition

* change edition="2018" to edition="2021" in Cargo.toml
2022-01-12 16:22:00 +02:00
dependabot[bot]
3677930fc4
Update gloo requirement from 0.4 to 0.6 (#2337)
* Update gloo requirement from 0.4 to 0.6

Updates the requirements on [gloo](https://github.com/rustwasm/gloo) to permit the latest version.
- [Release notes](https://github.com/rustwasm/gloo/releases)
- [Commits](https://github.com/rustwasm/gloo/commits)

---
updated-dependencies:
- dependency-name: gloo
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix ci

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: voidpumpkin <32368314+voidpumpkin@users.noreply.github.com>
2022-01-10 23:17:13 +02:00