2138 Commits

Author SHA1 Message Date
Kaede Hoshikawa
2576372e26
Delay Hydration second render until all assistive nodes have been removed (#2629)
* Separate hydration and render queue.

* Revert "Fix issue with node refs and hydration (#2597)"

This reverts commit 469cc341c340bd0093d9233847f523b66a18fd90.

* Priority Render.

* Add some tests.

* Add more tests.

* Add test result after click.

* Fix test comment.

* Fix test timing.

* Restore test.

* Once AtomicBool, now a Cell.

* Prefer use_future.

* Revealing of Suspense always happen after the component has re-rendered itself.

* Shifting should register correct next_sibling.

* Revert to HashMap.

* cargo +nightly fmt.

* Fix comment.

* Optimise Code size?

* Add comment if assertion fails.

* Revert "Merge branch 'hydration-4' into fc-prepared-state"

This reverts commit 427b087d4db6b2e497ad618273655bd18ba9bd01, reversing
changes made to 109fcfaa127aefc5fa3c697e254fe2c049292be2.

* Revert "Revert "Merge branch 'hydration-4' into fc-prepared-state""

This reverts commit f1e408958d94cb13813ce75aa6f0aad06c9fa3e8.

* Redo #2957.
2022-04-25 07:35:55 +09:00
Lucille Blumire
2db4c81ad6
Add VTag::into_children (#2638)
* Add `VTag::into_children`

Currently, VTag supports `children` and `children_mut`, but not `into_children` to complete the pattern. This is useful if someone wishes to destructively acquire the children of a VTag to reparent them to a different VTag.

* Repair broken doc comment on `VTag::children_mut`

* Remove spaces between functions
2022-04-23 21:06:41 +09:00
WorldSEnder
1794dd01bc
Fix cargo fmt from merge changes (#2636)
Fixup #2630
2022-04-22 17:26:41 +02:00
dependabot[bot]
1a9ae3cc86
Update uuid requirement from 0.8.2 to 1.0.0 (#2633)
Updates the requirements on [uuid](https://github.com/uuid-rs/uuid) to permit the latest version.
- [Release notes](https://github.com/uuid-rs/uuid/releases)
- [Commits](https://github.com/uuid-rs/uuid/compare/0.8.2...1.0.0)

---
updated-dependencies:
- dependency-name: uuid
  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-04-22 16:47: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
Muhammad Hamza
12c9ebb0ea
Move hook API docs to Rustdoc (#2628)
* Move hook API docs to Rustdoc

* npm update, fix links and doc tests and callback docs

* make doc tests pass

* Update packages/yew/src/functional/hooks/use_ref.rs

* Update packages/yew/src/functional/hooks/use_ref.rs

* Update use_ref.rs
2022-04-21 15:28:09 +05:00
WorldSEnder
cd5b8a520c
Improve grammar and paragraph structure in documentation (#2620)
* Read through the docs and correct spelling and grammar

* Run prettier

* Apply review suggestions

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

* adjust translation messages

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>
2022-04-20 16:41:42 +05:00
WorldSEnder
c2b2f2cf2d
fixes bubbling of events originating in shadow dom (#2627)
when we not explicitly portaling into the shadow, we
should bubble up to the host element and continue.
This fixes custom elements internally using open SD
2022-04-20 16:33:52 +05:00
Muhammad Hamza
59e2f82766
Improve js_callback example (#2611)
* improve js_callback example

it now loads two modules:
1. imp.js
2. unimp.js

imp.js is loaded at page load whereas unimp.js is loaded when requested. A fallback is displayed during loading using Suspense

* Hash is not hardcoded anymore

* pre_build hook to build the post build hook binary

* fmt

* add .gitignore for trunk_post_build executable

* move js imports to bindings module, upadte README
2022-04-19 01:42:46 +05:00
WorldSEnder
504693ff30
Introduce use_future_with_deps (#2615)
* introduce use_future_with_deps

* add documentation to use_future

* use_future_with_deps now uses Rc<D> instead of &D

* fix expansion and simplify use_future
2022-04-17 21:07:26 +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
Jet Li
58db53a026
Allow to consume deps in use_callback (#2617) 2022-04-16 01:43:13 +05:00
dependabot[bot]
d2c3685521
Update gloo requirement from 0.6 to 0.7 (#2613)
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.6.0...0.7.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-04-15 12:16:04 +02:00
Muhammad Hamza
edeb59d777
Add use_future hook to make consuming futures as suspense easier (#2609)
* Add `use_suspending_future` hook to make consuming futures as suspense easier

* Add test

* fmt

* use_suspending_future -> use_future

* use_future takes a closure
2022-04-14 23:10:32 +05:00
WorldSEnder
b580bd4c2f
Code Size: Document and use additional nightly features (#2604)
* code size: doc and use additional nightly features

* add ci paths to run condition

* undo unrelated edit to benchmark workflow

* Add links to nightly feature docs
2022-04-13 13:30:33 +05:00
WorldSEnder
469cc341c3
Fix issue with node refs and hydration (#2597)
* Fix issue with node refs and hydration

When a component is contained in a component, the
inner reconciles, which used to replace the NodeRef,
which left a badly linked one in the outer Hydration render state.

Now, keep a stable internal_ref besides the user-passed node_ref.
The internal_ref never gets replaced as long as the BComp lives.
2022-04-13 00:31:48 +02:00
Muhammad Hamza
e9b64e0a45
Add the ability to use non-literal string as attribute names (#2593)
* Use AttrValue instead of &'static str in Attributes::IndexMap

* avoid monomorphization to reduce binary size

* fmt & `#[inline(always)]`s

* more attempts to reduce the code size

* make clippy happy
2022-04-13 03:27:22 +05:00
zahash
73771562c2
simple counter application with functional components (#2603)
* simple counter application with functional components

* clean up some comments

* use the word 'function' instead of 'functional'

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

* add the counter functional example package to workspace root cargo toml

* add data-trunk link tag in index html

* include counter functional into the examples readme file

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>
2022-04-12 15:54:15 +05:00
WorldSEnder
daf6ec0152
Reduce size of examples (#2601)
* Reduce size of examples with this one weird trick

* oops, fixup function_router
2022-04-11 17:02:59 +05:00
WorldSEnder
dc60d6099e
Fix links and add CI checks in documentation (#2595)
* Docs overhaul part2

* fix links and require them for CI
* remove translations for 0.17

* remove a bunch of unused documentation

* run prettier

* fixup links and locations of some translations
2022-04-10 21:01:18 +00:00
WorldSEnder
6992a454e3
Introduce a dedicated use_force_update hook (#2586)
* introduce a dedicated use_force_update hook

* fix doc links
2022-04-09 16:54:39 +05:00
Nano
ae26885589
Impl ImplicitClone for Rc<T> where T: Sized (#2594) 2022-04-09 13:33:16 +02:00
WorldSEnder
e2405298c6
update zxcvbn to 2.2.1 (#2568)
* update zxcvbn to 2.2.1

* fix clippy issues

* Upgrade to wasm_bindgen 0.2.80

* resolve TODO, linked pr now merged
2022-04-08 13:03:45 +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
Kai Jellinghaus
8ca7ceb34f
Ignore website/** changes when benchmarking (#2581) 2022-04-06 23:10:04 +05:00
Muhammad Hamza
3ad4dbe837
Format website with prettier (#2536)
* add prettier

* ci

* run prettier

* run prettier in CI

* run prettier --write

* ignore README.md

* specify googleAnalytics

* fmt

* npm run write-translations

* fmt

* ignore i18n json files

they're autogenerated and don't like being formatted

* post merge fixes & some updates

* post merge fixes
2022-04-06 22:52:15 +05:00
Kai Jellinghaus
ec1f43aa24
Fix typo(s) in use_callback docs (#2580)
* Fix typo in use-callback.mdx

* Fix the same typo in two more places 🤔

* Fix rest of typos
2022-04-06 16:48:51 +02: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
Muhammad Hamza
4bc61b8da9
Update context docs (#2570)
* update context docs

* fix doc test
2022-04-03 12:52:20 +05:00
Muhammad Hamza
b433074ef5
Add deployment section in docs (#2569)
* Add deployment section in docs

* ignore non-rust code block

* Apply suggestions from code review

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

Co-authored-by: WorldSEnder <WorldSEnder@users.noreply.github.com>
2022-04-03 10:03:19 +05:00
Kaede Hoshikawa
e46ae55cab
SSR Hydration (#2552)
* Bring changes to this branch.

* Add feature hydration.

* Hydrate text.

* Hydrate tag.

* Hydrate node.

* Hydrate List.

* Hydrate Suspense.

* Hydrate component.

* Renderer::hydrate.

* Add example and tests.

* Fix comp_id.

* Move some code away from generics.

* Fix everything.

* trybuild?

* Collectable!

* Phantom component.

* Migrate docs as well.

* Update example.

* Fix docs and improve debug message.

* Minor fixing.

* Add hydration to feature soundness check.

* Fix name in debug.

* Remove Shift.

* Remove comment.

* Adjust readme.

* Update website/docs/advanced-topics/server-side-rendering.md

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

* Update packages/yew/src/dom_bundle/bnode.rs

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

* Update packages/yew/src/dom_bundle/bnode.rs

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

* Once via structopt, now direct clap.

* Fix docs and empty fragment.

* Remove struct component warning.

* Move function router into a separate binary.

* Optimise Code Logic.

* Fix condition.

* Fix rendering behaviour.

* Fix comment.

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>
2022-04-03 08:00:16 +09:00
dependabot[bot]
2db42841a1
Bump minimist from 1.2.5 to 1.2.6 in /tools/benchmark-struct (#2548)
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-03 00:47:06 +05:00
dependabot[bot]
20cc54096d
Bump minimist from 1.2.5 to 1.2.6 in /tools/benchmark-hooks (#2547)
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-03 00:46:36 +05:00
Jet Li
421b4e1f60
Add use_callback hook (#2566)
* Add use_callback hook

* Simply use_callback
2022-04-01 13:10:27 +03: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
Kyle Smith
e1f89a8352
Update wording on pure function definition. (#2556)
I was originally going to put a PR to fix "has not side-effects", but I also re-read this sentence and realized it could be interpreted as saying a pure function returns its parameters, not a deterministic value based on its parameters.
2022-03-28 00:29:33 +05:00
dependabot[bot]
2209db7b03
Bump typescript from 4.6.2 to 4.6.3 in /website (#2545)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.6.2 to 4.6.3.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.6.2...v4.6.3)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-26 08:59:06 +09:00
dependabot[bot]
1f4ccda256
Bump @types/react from 17.0.41 to 17.0.43 in /website (#2546)
Bumps [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react) from 17.0.41 to 17.0.43.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react)

---
updated-dependencies:
- dependency-name: "@types/react"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-26 08:58:48 +09:00
Kaede Hoshikawa
2e098f4f6c
Introduce additional information in SSR artifact to facilitate Hydration (#2540)
* Bring changes to this branch.

* Child components always render after parents.

* Add hydratable to render_to_string.

* Revert portal example.

* Fix vcomp.

* Prefer debug_assert.

* ServerRenderer now a Builder Pattern.

* Collectable.
2022-03-26 08:57:08 +09:00
WorldSEnder
ee6a67e3ea
Scoped event handlers (#2510)
* implement event handling with multiple subtree roots
* add listeners to all subtree roots
* move host element to Registry
* add BSubtree argument
* surface level internal API for BSubtree
* cache invalidation & document limitations
* Update portal documentation
* Add test case for hierarchical event bubbling
* add shadow dom test case
* add button to portals/shadow dom example
* change ShadowRootMode in example to open

BSubtree controls the element where listeners are registered.
 we have create_root and create_ssr

Async event dispatching is surprisingly complicated.
Make sure to see #2510 for details, comments and discussion

takes care of catching original events in shadow doms
2022-03-25 17:09:15 +01:00
Andreas Atle
bbb7ded83e
Fixed broken tutorial (#2531) (#2542)
* Changed dependency to yew = "0.19"

* Changed edition to 2021
2022-03-23 14:42:51 +05:00
Kaede Hoshikawa
62d78d0641
An ever Increasing Component ID (#2537)
* Bring changes to this branch.

* Child components always render after parents.

* Cleanup residual Portal references.

* Fix after merge.

* Fix trybuild.

* Opt for usize.

* Strip Generics.

* take instead of replace, first instead of front.
2022-03-21 23:47:33 +09:00
dependabot[bot]
39d3b37f4f
Bump @types/react from 17.0.40 to 17.0.41 in /website (#2539)
Bumps [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react) from 17.0.40 to 17.0.41.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react)

---
updated-dependencies:
- dependency-name: "@types/react"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-21 18:27:53 +09:00
Julius Lungys
70c9a71ff3
update HTML concept to use function components (#2511)
* update HTML concept to use function components

* adress comments 1

* fix test

* adress comments 2

* code outside of html
2022-03-20 13:22:55 +02:00
Julius Lungys
5ececa4644
update nested router docs (#2535)
* update nested router docs

* !!!

* fix according to comments

* fix error
2022-03-20 12:12:13 +02:00
Julius Lungys
b9bd18f3f4
add struct component context consumpion doc (#2533)
* add structs example

* Update website/docs/concepts/contexts.mdx

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>
2022-03-20 11:49:29 +02:00
Kaede Hoshikawa
b392023686
Prevents Fallback UI from becoming suspended (#2532)
* Bring changes to this branch.

* Add BaseSuspense.

* Create detached parent inside of bundle.

* Fix ctx and opt for html!.

* Make Portals "work" with SSR.

* Update docs.

* Fix feature flags.

* Revert portal design.

* Fix feature flag.
2022-03-20 17:01:40 +09:00
Muhammad Hamza
9c2480b93b
Update edition in docs, add git dependency for master docs (#2534) 2022-03-20 12:53:32 +05:00