361 Commits

Author SHA1 Message Date
WorldSEnder
78d4204a9a
Introduce explicit internal datastructures modeling dom state (#2330)
* detach destructures now

* add failing keyed-list issue

* crude port to the new bundle infrastructure

* port over the infrastructure

the new bcomp is especially nice and lost a few unwraps owed to not having
to reserve space for a scope before rendering.
Note also that bsuspense has been slimmed a bit, storing the suspended flag
implicitly in the state.
some naming is not perfect yet and has to be adjusted still.

* mass rename: apply -> reconcile

* get rid of move_before in favor of shift

* generate id directly when creating a new scope

* bundle for text nodes

* work on naming: ancestor -> bundle

* slightly optimize list reconciler, add doccomments

* address review

* add internal documentation

* address review comments

rename fields in bsuspense
convert to gloo::events

* move even more stuff into dom_bundle to scope exports

- app_handle and layout_tests are now in there
- items are publically re-exported in crate::dom_bundle
- dom_bundle itself is private
- btag and bcomp get their own submodules
- bcomp now contains the lifecycle and scope impls

* move replace into Reconcilable

* move lifecycle and scope back into html as per review

* move back Value and InputFields into html

* actually only type-check format args in production

* fix documentation link

* move btag_impl up into containing module

* shift comps immediately

shifting the rendered Nodes does not tie into the lifecycle,
as such it can happen immediately

* use list-bundle in tag-bundle

* fix cargo make tests

* improve 05_swap benchmark

* fix a blunder where I swapped operands

* fix naming of BNode variants
2022-03-06 08:37:07 +05:00
Julius Lungys
221b4dfa51
fix clippy (#2492) 2022-03-05 20:53:19 +01:00
Aaron Erhardt
36058d455c
Improve AnyScope API (#2445)
* Improve AnyScope API

Signed-off-by: Aaron Erhardt <aaron.erhardt@t-online.de>

* Make find_parent_scope public

Signed-off-by: Aaron Erhardt <aaron.erhardt@t-online.de>
2022-02-26 13:00:44 +01: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
Cecile Tonglet
95fb5dc8fb
Remove probably unused impl ImplicitClone on Cow<str> (#2447)
* Remove probably unused impl ImplicitClone on Cow<str>

* Remove unused import

* Remove variant Owned for AttrValue for consistency

* Implement ImplicitClone on primitive types

Especially those that are Copy.
2022-02-12 01:09:49 +05:00
Kaede Hoshikawa
e56ff20b63
Automatic Message Batching (#2421)
* (○`дノ´)ノ┳┳・゚・┻┻・゚・。

* Recover docs as well.

* Make scheduler synchronous for now.

* Disable Component IDs as they are not useful at the moment.

* Minor fixing, amending messages and apply optimisation on batched messages.
2022-02-07 20:46:09 +05:00
Julius Lungys
636692507e
Convert components concept docs from SC to FC (#2434)
* Convert components concept docs from SC to FC
- moved struct components to advanced topics
- added docs about HOC for Suspense and Context
- added a ease-in topic before components that introduces
HTML/CSS/JS in yew
- edit components concept to use function components

* translations

* fix todo links

* fix tests

* spelling bee
2022-02-07 11:03:12 +02:00
Alexander Mescheryakov
d5cc4a3237
Add Other variant to the ListenerKind (#2417)
* Add other listener kind

* Remove Copy restriction

* Fix fmt
2022-01-31 09:57:08 +02:00
Kaede Hoshikawa
b7b28ba963
Do not detach child elements if parent element is about to be detached (#2420)
* 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.

* Do not detach child element if parent element is about to be detached as well.

* Fix tests.
2022-01-30 13:24:33 +02: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
Anuvrat Singh
4580d94c59
Add ContextHandle in yew::prelude (#2372)
* Adds ContextHandle in yew::prelude

* Adds ContextHandle in yew::prelude

Added ContextHandle in /yew/src/lib.rs and updated stderr with test-overwrite

* Formats code using cargo fmt

* Revert "Adds ContextHandle in yew::prelude"

This reverts commit abdf21f2d523ac2df56cca3d29f8860dbefc5cc5.
2022-01-25 14:51:16 +02:00
Kaede Hoshikawa
38021e31fe
Separate scheduler rendered call from create and render (#2374)
* Separate push_component_rendered from push_component_render and push_component_update.

* Fix pr-flow.

* Make first_render more reliable.
2022-01-22 20:04:12 +02:00
Alexander Mescheryakov
fac220fd64
Fix add a listener to VTag when the listeners is None (#2375)
* Fix add listener and remove unused listener code

* Format code
2022-01-20 20:30:36 +01:00
Shivam
01a259431d
resolve some dead links as mentioned in issue #2379 (#2380)
* resolve some dead links as mentioned in issue #2379

* done the required changes
2022-01-19 18:20:24 +02:00
Muhammad Hamza
62e3194d5f
Improve hosted API docs (#2373)
* build up redirects for API docs hosting

* build with all features and documenting config

* fix warnings

* can rustdoc please provide a way to modify the base url?

I want to host the docs at /next/:crate_name, not at /:crate_name ffs

* Don't clean URLs... what is rustdoc doing?

* now it wants to work???

* build a next index page

* unreleased docs banner

* show coverage

* remove ./ ???

* try 2?

* api-docs/ not api-docs-public/

* please
2022-01-15 19:57:35 +01: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
Kaede Hoshikawa
d8c2550fc7
Server-side Rendering (without hydration) (#2335)
* Basic render to html implementation.

* Remove HtmlWriter.

* Escape html content.

* Add non-suspense tests.

* Add Suspense tests.

* Gated "ssr" feature.

* Add example.

* Fix tests.

* Fix docs.

* Fix heading size.

* Remove the unused YewRenderer.

* Remove extra comment.

* unify naming.

* Update docs.

* Update docs.

* Update docs.

* Isolate spawn_local.

* Add doc flags.

* Add ssr feature to docs.

* Move ServerRenderer into their own file.

* Fix docs.

* Update features and docs.

* Fix example.

* Adjust comment position.

* Fix effects being wrongly called when a component is suspended.

* Fix clippy.

* Uuid & no double boxing.

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>
2022-01-12 18:43:09 +05:00
Julius Lungys
99f949da9a
Remove important note from API docs (#2363) 2022-01-12 18:30:11 +05:00
Jonathan Bailey
923f6434df
Support named wildcards when deriving Routable. (#2345) 2022-01-12 18:27:14 +05:00
Kaede Hoshikawa
5dd8b7635c
Make BaseComponent Sealed. (#2359) 2022-01-11 17:00:41 +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
Kaede Hoshikawa
1c367a7b6f
Remove start_app_as_body. (#2346)
* Remove start_app_as_body.

* Add migration guide.

* Update website/docs/migration-guides/yew/from-0_19_0-to-0_20_0.mdx

Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>

Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>
2022-01-10 22:12:22 +05:00
Allan
b3f8ca1920
Replace Model with App or MyComponent (#2336)
`Model` is ambiguous and not a user-friendly name.
Some of the newer docs are already referring to the root component as
`App`.

This PR follows this naming scheme:
 - `App` for a root component
 - `MyComponent` for an arbitrary component

This naming is inspired by the React docs.

i18n references were not changed. They need a larger rewrite which will
go in a separate PR.
2022-01-07 20:50:21 +05:00
Muhammad Hamza
b456636111
Bump minimal supported rust version (MSRV) to 1.56 (#2334)
* Bump MSRV to 1.54

* add rust version to Cargo.toml

* update macro test stderr

* 1.56 go brrrr

* 1.56 go brrrr: part 2 electric boogaloo
2022-01-06 19:32:48 +02:00
Muhammad Hamza
3ca7c0f90a
Move yew-agent to gloo (#2326)
* move agent to gloo

* rename: agent -> worker

* make it compile

* use gloo-worker from crates.io & fmt
2022-01-05 19:40:27 +05:00
Kaede Hoshikawa
ac3af0a9bc
Suspense Support (#2212)
* Make Html a Result.

* Fix tests.

* Implement Suspense.

* Schedule render when suspension is resumed.

* Shift children into a detached node.

* styled example.

* Update wording a little bit.

* Move hint to hint.

* Add some tests.

* Fix clippy.

* Add docs.

* Add to sidebar.

* Fix syntax highlight.

* Component -> BaseComponent.

* Html -> VNode, HtmlResult = RenderResult<Html>.

* Suspendible Function Component.

* Add a method to create suspension from futures.

* Revert extra changes.

* Fix tests.

* Update documentation.

* Switch to custom trait to make test reliable.

* Fix file permission.

* Fix docs.

* Remove log.

* Fix file permission.

* Fix component name error.

* Make Suspension a future.
2022-01-05 18:16:34 +05:00
Kaede Hoshikawa
6f6519dab4
Implement PrivateAgent (#2318)
* Implement PrivateAgent, Separate Threaded into PublicAgent & PrivateAgent.

* Add migration docs.

* Update docs.
2022-01-01 19:45:11 +01:00
WorldSEnder
c46cda1e6f
remove some unsafes by using atomics (#2186) 2021-12-31 20:36:26 +01:00
Kaede Hoshikawa
a36ccfc843
Remove unused yew-router dependencies. (#2320) 2021-12-31 15:50:52 +02:00
Kaede Hoshikawa
7d52858d01
Remove context & job agent (#2295)
* Remove context and job agent.

* Revert "Remove context and job agent."

This reverts commit 408f6fcdf062800c9e9852e6662a55ff3eef4533.

* Revert "Revert "Remove context and job agent.""

This reverts commit 44a42dfb313c111ceaa654163c8aa610a88e6a95.

* Update example.

* Fix docs.

* Fix test.

* Rename examples.

* Fix examples & docs.

* Update website/docs/concepts/function-components/custom-hooks.mdx

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

* Examples in alphabetical order.

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>
2021-12-29 17:15:26 +05:00
Tiziano Santoro
b761487bac
Fix typo (#2315) 2021-12-29 17:09:05 +05:00
Muhammad Hamza
c91364b5c6
make layout testing code public (#2310) 2021-12-28 22:38:56 +02:00
Muhammad Hamza
3758e6d077
Refactor and simplify Callback (#2301)
* yeet Callback::once

* yeet Callback::reform

* remove passive overrides

Event's passive state will be determined by sane defaults set by Yew

* clippy

* docs

* make CI happy

* Revert "yeet Callback::reform"

This reverts commit 33e7770d

* why?

I literally tick-marked reformat before commit. Does it not use rustfmt???

* Update packages/yew/src/callback.rs

Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>

Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>
2021-12-28 21:27:31 +02:00
Alexander Mescheryakov
f0fb40650e
Add pending event listener on the VTag (#2300)
* Add pending event listener on the VTag

* Remove deprecated set_listener and rename add_listener

* Add return value comment
2021-12-28 21:01:33 +05:00
Muhammad Hamza
5181e1aca7
Fix basename handling in router (#2297) 2021-12-26 21:38:05 +02:00
Alexander Mescheryakov
61efc8042e
constify VList::new (#2293)
* Use const constructor for VList and fix EMPTY VList access

* Add comment
2021-12-23 20:57:50 +01:00
Muhammad Hamza
73b5f6b4c1
Allow function_component creation based on function name (#2292)
* function_component without name

* fmt

* fc

* update docs

* remove fc
2021-12-23 13:30:17 +01:00
Matt
ac891de426
Bump Docusaurus to beta 14 (#2288)
* fix docs.rs logo url

* fix formatting

* bump docusaurus to beta14

* bring back the semicolon
2021-12-22 23:29:53 +05:00
Zachary Stewart
a166815b88
Implement IntoPropValue for Rc<str> (#2285)
* add IntoPropValue implementations for Rc<str>

* add test

* update test logs which record the new impls
2021-12-22 01:42:26 +05:00
WorldSEnder
47364b667a
Fix a problem with NodeRefs and vtags, ref (#2279)
* fix #2206
2021-12-20 14:45:39 +05:00
Kaede Hoshikawa
d8ec50150e
Add HashRouter, basename and use gloo-history (#2239)
* Migrate to gloo-history.

* Fix docs wording.

* Add basename handling to navigator.

* Fix basename handling.

* Add lints and tests.

* Fix wording.

* Fix docs.

* Fix pr-flow.

* Fix some documentation.

* Add Navigator Kind.

* Remove history.rs

* Add documentation for navigator & Concrete Router Props.

* Update website/docs/concepts/router.md

Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>

* Add docs about basename.

* Update documentation.

* Fix docs.

Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>
2021-12-19 20:38:33 +05:00
Kaede Hoshikawa
5b0bbd55c9
Fix defaulted type parameter. (#2284)
* Fix defaulted type parameter.

* Add test.
2021-12-19 16:46:32 +05:00
WorldSEnder
f5b921984a
Silence some warnings from derive(Properties) (#2266)
* silence some warnings from derive(Properties)

* for consistency preserve [#deny(..)]

* preserve some attributes on the struct def

adds a test case to check for several warnings

* add #[deny] in test cases to error instead of warning on failure

Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>
2021-12-16 14:38:53 +05:00
Matt
1ef364ffda
Add braces when html_nested used on html element (#2270)
* add braces when html_nested used on html element

* run rustfmt
2021-12-15 22:56:24 +01:00
WorldSEnder
c2d39d7d48
Raw field names in property structs (#2273)
* raw property names

* add component test
2021-12-15 22:55:34 +01:00
Matt
2e0fa8eae4
simplfy the readme for yew-router (#2272) 2021-12-15 22:54:54 +01:00
Julius Lungys
f749ca3c83
Move/Remove tools (#2274)
* move tools

* delete yew-validation

* update paths

* fix cargo.toml
2021-12-15 22:53:01 +01:00
Julius Lungys
cf0f59af55
Add paths for yew dependencies (#2265) 2021-12-12 21:19:38 +01:00
GitHub Action
8246827030 (cargo-release) version yew-agent-v0.1.0 2021-12-11 20:12:22 +00:00
Julius Lungys
39724c6d5d
fix yew-agent for release (#2264)
* add mising metadata

* lover version to make it bumpable
2021-12-11 22:09:38 +02:00