301 Commits

Author SHA1 Message Date
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
Nathan West
6751946477
Various improvements to Classes, oriented around reducing allocations (#2870)
* Various improvements to Classes, oriented around reducing allocations

- `push` no longer performs unnecessary allocations if `self` is empty.
    - Most constructors (FromIterator, From, Extend) are now oriented around push, to take advantage of this
- `to_string` and `into_prop_value`:
  - No longer allocate an unnecessary `Vec`; they instead preallocate a string of the correct length and push into it directly.
  - No longer use a length check + `unsafe`; they instead match over a fallible .next() and proceed from there.
  - Additionally, `into_prop_value` no longer builds a `String` or `Rc` if `Classes` contains a single `&'static str` or is empty.
- `From<String>` no longer clones the string if it contains a single class.
- `impl Eq for Classes`

* Fix duplicated is_empty test
2022-09-21 13:41:10 +09:00
Athan Clark
89dd3b3e7f
Simple NodeRef passing to <Link> for yew-router (#2877)
* simple NodeRef passing

* using `anchor_ref` opposed to `a_ref` per @futursolo's review
2022-09-19 03:05:23 +02:00
Kaede Hoshikawa
ce70e4c1fb
Resume Suspension upon unmount (#2874)
* Restore a behaviour of destroy upon unmount.

* Add a test.

* Fix CI.

* Fix CI.
2022-09-15 16:26:45 +03:00
Jens Reimann
beb0157c48
Allow skipping a callback when reforming (#2864)
* Allow skipping a callback when reforming

This adds a method to the callback, similar to Rust's filter_map, which
allows to reform a callback, but also suppress the emit in case
the reform function returns `None`.

* Update packages/yew/src/callback.rs

Co-authored-by: WorldSEnder <WorldSEnder@users.noreply.github.com>

* Implement filter_reform for all Callback output types

As suggested in the PR, this implements filter_reform for all output
types of callbacks by mapping to `Option<OUT>`.

* Fix clippy error

Although I believe that the code is more readable/understandable with
an explicit map, I am not sure adding a clippy exception just for that
is justified. So I applied the clippy suggestion.

Co-authored-by: WorldSEnder <WorldSEnder@users.noreply.github.com>
2022-09-15 01:14:58 +02: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
Kaede Hoshikawa
5f7dd1d972
Upgrade tokio to v1.21.1 (#2869)
* Remove tokio-util.

* Unpin tokio.

* Revert test workaround.
2022-09-13 16:49:39 +02:00
Muhammad Hamza
a489690d99
Pin tokio to 1.20.1 to fix CI (#2866) 2022-09-11 08:00:25 +09:00
Kaede Hoshikawa
278d2ce08e
Polled SSR Stream (#2824)
* Switch to pinned channels.

* Fix ServerRenderer so it's not blocked until the result is resolved.

* Fix tests.

* Remove unused SendError.

* Implement a stream to be polled alongside rendering.

* Update Buffer Size.

* Make Send renderer work.

* Remove pinned channels.

* Unified Naming.

* Optimise code.

* Restore capacity.

* Remove unused profile.

* Default to separate resolver.

* Reduce allocations on string.

* Adjust API.

* Remove duplicate trait bound.

* Update docs.

* Remove capacity setting.

* Unsafe?

* Separate files.

* Adjust inlining.

* Fix test.

* Update notice.

* Update documentation.

* Fix tests.
2022-09-11 01:25:00 +05: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
laizy
fc965435e8
Add send_stream method for Scope (#2619)
* add send_stream method for Scope

* add eof stream note

* map stream item type

* No need for nightly, fmt, updates

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>
2022-08-29 08:36:35 +09:00
Muhammad Hamza
0e0d6949f6
Allow functions returning unit in use_effect (#2849)
* Use TearDown trait as destructor for use_effect

* Docs

* no default tear_down
2022-08-28 19:33:42 +05:00
Kaede Hoshikawa
cffb7c5e7e
Configurable Runtime (#2772)
* Adds Runtime.

* A LocalRuntime.

* Add note.

* Add SSR benchmark.

* Only create default runtime if no custom runtime is set.

* Use jemalloc for benchmarking.

* Remove once_cell for web assembly.

* Add time.

* Fix wasm_bindgen.

* Adjust inlining.

* Optimise benchmark output.

* Optimise BufWriter.

* Add json output.

* Add Benchmark Workflow.

* Remove local set from tests.

* Fix Workflow syntax.

* Exclude benchmark from doc tests.

* Adjust feature flags.

* Adds a pinned channel implementation.

* Make Send bound explicit.

* Implement on immutable reference.

* Fix Sink close.

* run_pinned -> spawn_pinned.

* Add tests.

* Adjusts worker threads.

* Fix workflow.

* Remove futures-executor.

* Cargo update.

* Fix docs.

* Update notice.

* Fix docs.

* Fix docs.

* Switch to task spawning.

* Use futures unordered instead of spawn_local.

* Switch to join_all.

* Remove LocalPoolHandle.

* Fix docs.

* Spawn a single task.

* Fix merge failure.

* Remove LocalRuntime.

* Update documentation.

* Merge local-runtime-handle into local-runtime.

* Add some tests.

* Fix clippy notice.

* Fix comment.

* Address various review comments.

* Remove unused type.

* Fix clippy.

* Fix clippy.
2022-08-28 23:31:11 +09:00
Kaede Hoshikawa
5079885d9f
Pinned Channels (#2811)
* Switch to pinned channels.

* Fix ServerRenderer so it's not blocked until the result is resolved.

* Fix tests.

* Remove unused SendError.

* Revert channel-based BufWriter.

* Removed unused fmt module.

* Update docs.

* Add safety comments, adjust borrowing designs.

* Adjust oneshot as well.

* Fix workflow temporarily.

* Cell or UnsafeCell?

* Update safety notice.

* Should be sync.

* Actually should be both.

* Update packages/yew/src/platform/pinned/mpsc.rs

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>
2022-08-16 13:36:43 +09: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
9e602b94ff
Reduce SSR Buffers in VList (#2826) 2022-08-14 23:38:36 +05: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
d422b533ea
onsubmit should be a SubmitEvent (#2816)
* onsubmit should be a SubmitEvent

* At least v0.3.59

* Enable feature, add re-export

* fmt
2022-08-08 02:10:38 +05:00
WorldSEnder
4206da7c41
Replace custom logging by tracing (#2814)
* use tracing for logging

* embed spans in the scheduler for tracing

* fix feature soundness

* remove spans from scheduler for now

* feature soundness take 2

* use tracing::* throughout lib code

not yet in testing, and for some errors!
2022-08-07 21:06:01 +02:00
Kaede Hoshikawa
f0b0df33e6
Fix VList Stream in SSR (#2801)
* Fix rendering stream.

* Update naming.

* Resolve first, then transfer.

* Use slice pattern.

* Update workflow paths.

* Use join_all.

* Do not map.

* Remove map.

* Fix rustfmt.
2022-08-07 11:59:54 +09:00
Cecile Tonglet
c802167419
Make fn update() re-render the component by default (#2786) 2022-08-01 11:07:19 +01:00
Kaede Hoshikawa
de613fa832
Implement sleep and interval for Yew Platform (#2784)
* Rename runtime.

* Implement sleep and interval.

* Replace sleep usage with one provided by the platform.

* Fix imports.

* Fix tests.

* Enable futures on gloo.

* Always inline sleep.

* Fix tests.

* Implement sleep in house.

* Remove futures feature.

* Oops.

* Prevent Excessive Polling.
2022-07-31 23:17:34 +09:00
Raphaël Duhen
8f269bbd61
docs: remove repeated word (#2788) 2022-07-23 21:20:40 +09: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
924792c002
Enable Dependabot for Examples and Tools (#2785)
* Enable dependabot for examples and tools.

* Make everything to use Gloo.

* Require features for binaries.

* Update every Friday.
2022-07-21 01:23:22 +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
Kaede Hoshikawa
6f53a4e677
Document features automatically. (#2780)
* document features automatically.

* Document with `#[cfg(...)]`.

* Fix Clippy.

* Adjust unreleased docs header.

* Adapt dark mode as well.
2022-07-18 20:10:14 +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
WorldSEnder
11424bd840
Fix: prevent bubbling of !bubbles() events (#2768)
* fix: prevent bubbling of !bubbles() events

* fmt: cargo fmt
2022-07-01 19:56:31 +02:00
dependabot[bot]
0af7a4d038
Update implicit-clone requirement from 0.2 to 0.3 (#2763)
Updates the requirements on [implicit-clone](https://github.com/rustminded/implicit-clone) to permit the latest version.
- [Release notes](https://github.com/rustminded/implicit-clone/releases)
- [Commits](https://github.com/rustminded/implicit-clone/compare/v0.2.0...v0.3.1)

---
updated-dependencies:
- dependency-name: implicit-clone
  dependency-type: direct:production
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-01 21:41:45 +09:00
dependabot[bot]
814e52daac
Update gloo requirement from 0.7 to 0.8 (#2766)
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/compare/0.7.0...0.8.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-01 21:32:32 +09:00
Kaede Hoshikawa
8013724b5d
Fix Workflow (#2767)
* Fix clippy.

* Fix cargo version as well.

* Fix changed pkgid syntax.
2022-07-01 21:08:11 +09: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
Shrey Sudhir
f82af86c66
add use_bridge docs (#2722)
* init use_bridge content

* cargo fmt

* cargo +nightly fmt --all

* more sensible code

* make example compile

* make example compile (for real this time)

* update docs

* oops

* oops

* make super work

* this is rust, not C
2022-06-24 20:17:58 +02: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
orzogc
7221933f8c
Callback::reform() should return Callback<T, OUT> (#2719) 2022-06-05 23:31:17 +02:00
WorldSEnder
cb5a609e08
Dont shift on normal props updates (#2705)
* don't shift on normal props updates

would remove focus from elements and fire other
dom mutation events we don't need or want

* rename mode -> creation_mode

it's not updated when the component finishes hydration

* rename node_ref to internal_ref for consistency

* fix the bug, should return internal_ref as node_ref gets unset during reconciliation

* also no need to shift during hydration props update

* debug: encode hydration invariant

* fix: next_sibling of descendents not updated

* add test case for regression

* address review and add one more test
2022-05-30 07:47:19 +02: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
WorldSEnder
b90c99af0c
Partially undo #2673, different approach for the DerefMut impl of VList (#2692)
* partially undo #2673

VList again has a DerefMut implementation
the internal fully_keyed state now has an "indeterminate" variant
instead of being a bool, this recomputes it during reconciliation

* add Copy impl to FullyKeyedState
2022-05-24 23:05:37 +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
Kaede Hoshikawa
027ab6af8b
Block props update during hydration (#2665)
* Delay props.

* Fix next sibling change not synced.

* Use shifting instead.

* Update docs, minor adjustments.

* More predictable props update.

* Delay longer.

* Only delay props during hydration.
2022-05-24 08:29:13 +09:00