433 Commits

Author SHA1 Message Date
Diggory Blake
e2d7619800
Bring context to standard components (#1835) 2021-05-05 23:16:18 +02:00
Muhammad Hamza
aa828d7b0f
Upgraded Hook API (2) (#1780)
* Feat: make hooks more ergonomic and easier to understand

* clippy, apply changes from review on PR (yew#1645)

* update docs

* fix docs and comment

* more ergonomic use_state

* update docs, fmt, clippy

* rename structs

* improve use_reducer API

* update use_reducer docs

* formatting

* Apply suggestions from code review

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
Co-authored-by: Simon <simon@siku2.io>
2021-05-05 22:06:26 +02:00
Diggory Blake
505826e109
Store hook state in a mutable scoped-TLS (#1831) 2021-05-03 17:36:26 +02:00
Kristoffer Søholm
2e89f29fc8
Fix crash in link to destroyed agents (#1827)
The destroyed field on the agent state was never set, so the early
return in `run` didn't prevent crashes when agents receive messages
after they are destroyed.
2021-05-02 16:40:50 +02:00
Diggory Blake
c7bc8e00f7
Remove unnecessary allocation from AnyScope (#1830) 2021-05-02 16:34:22 +02:00
Jasper
c51ab7f094
Added missing licenses to Cargo.toml files and updated to use SPDX syntax (#1822) 2021-04-25 23:24:14 +02:00
Hudson Shykowski
cc51208a48
Implement .into_inner() for Json (#1816)
* Implement .into_inner() for Json

This allows users to use .into_inner() the same way it would be possible
in the serde crate. Previously, it was only possible via dump.0 (which
looks gross), or Json(dump).

* Fix an error using HtmlBlock

The definition uses {content, brace} but the usage used [brace, content}

* Update packages/yew/src/format/json.rs

Co-authored-by: Simon <simon@siku2.io>
2021-04-12 20:04:38 +02:00
Yuta Hinokuma
bad4c77f61
update nom 6.1.2 and fix compile errors. (#1806) 2021-04-02 13:44:20 +02:00
Muhammad Hamza
991abab7e1
Update Rust version for macro tests to 1.51 & enable const generics tests (#1801)
* update rust version for macro test to 1.51

* enable const generic tests

* run integration tests using MSRV

* am blind

* clippy, fmt

* apply suggestion
2021-03-30 22:35:21 +02:00
Richard Walters
8309df32ca
Fix fetch test for same-origin referrer URL (#1788)
The `yew_services::fetch::tests::fetch_referrer_same_origin_url`
test broke for Chrome after Chrome changed the default
`Referrer-Policy` from `no-referrer-when-downgrade` to
`strict-origin-when-cross-origin`
(See: https://developers.google.com/web/updates/2020/07/referrer-policy-new-chrome-default)

The test makes a cross-site fetch (from the headless test
origin to the httpbin server) and the new default policy
causes the path to be stripped from the `Referer` header,
whereas the old policy didn't.

Fix this problem by explicitly setting the referrer policy
to the previous default `no-referrer-when-downgrade` when
making the test fetch.  This makes the test pass with Chrome
and should have no effect for other browsers which are
still using a default of `no-referrer-when-downgrade`
(i.e. Firefox).

Tested with both Chrome and Firefox:

* wasm-pack test --chrome --headless -- --features "wasm_test httpbin_test"
* wasm-pack test --firefox --headless -- --features "wasm_test httpbin_test"
2021-03-13 13:16:50 +01:00
Richard Walters
51e071467a
Fix issues in WebSocketTask during connection (#1783) (#1785)
During the connection handshake:

* `WebSocketTask::is_active` erronously returns `false`.
* Dropping `WebSocketTask` drops the `WebSocket` without
  calling `WebSocket::close` on it, resulting in the WebSocket
  "leaking"; it will typically continue the connection
  handshake and remain connected to the server, despite the
  client having dropped the object representing it.

Fix these by considering the task to be active if the
WebSocket `ready_state` is *either* `WebSocket::OPEN` or
`WebSocket::CONNECTING`.

Add two tests to check that a `WebSocketTask` returns `true`
for `is_active` while it's connecting, and that dropping
the `WebSocketTask` while it's connecting results in
the underlying WebSocket being closed properly.
2021-03-12 19:26:32 +01:00
Richard Walters
a1fa79d99e
Clean up asserts in WebSocket services test (#1784)
In `test_invalid_url_error`:

* First `assert` followed by `if let` is redundant.
* Second `if let` requires suppression of
  `irrefutable_let_patterns` since there is only one variant.
* Second `if let` necessitates a third "catch-all else" assert.

Replacing all of this with a single `assert!(matches!(...))`
makes it easier to read and removes the need for the
lint suppression without changing what's being tested.
2021-03-12 19:24:51 +01:00
Simon
37401402a1
Allow the use of Rust keywords for element names (#1772)
* time for more hygiene

* update corresponding tests

* while I'm at it

* now let's fix the actual issue

* fix the publish examples CI while I'm at it

* resolve clippy warnings
2021-02-28 15:49:58 +01:00
Luke Chu
bc46062864
Refactor html tag peeking (#1738)
* Fix html macro tests

* Fix generics with lowercase type param

* Satisfy clippy

* Parse generics with multiple type params

* Reorganize tests

* Remove Peek for HtmlTree

* Add additional test

* cargo fmt

* Remove peek_component_type

* Remove failing tests
2021-02-27 15:49:45 +01:00
Luke Chu
ee8eae19e9
Generic functional components (#1756)
* Generic functional components

* Add some tests

* Clippy

* Fix generic-props-fail snapshot

* Add docs for generic function components

* Add some more docs

* Fix trait bounds in docs

* Fix docs

* Improve lifetime error messages

* Fix parsing for const generics

* Use fully qualified path for pass test

* Remove TODO message

* Suggested change

Co-authored-by: Simon <simon@siku2.io>

* Update test

Co-authored-by: Simon <simon@siku2.io>

* Update test

Co-authored-by: Simon <simon@siku2.io>

* Update stderr snapshots

* Combine quote implementations

* Fix warning about type alias bounds

Co-authored-by: Simon <simon@siku2.io>
2021-02-24 19:05:48 +01:00
Martin Beták
f93fa3c8b2
yewtil: functional_component: Enable empty params (#1755)
* Automatically derive also the `Default` trait for function components
  without any properties.
2021-02-22 00:47:55 +01:00
Xavientois
f27e268f7e
Add support for the unit struct in Properties derive (#1752)
* Add support for the unit struct in Properties derive

* Add test to show that the code now compiles

* Fix fmt lint
2021-02-20 14:45:17 +01:00
xosxos
49a96257d9
Update README.md (#1750)
I was trying to get this to work by copy pasting but I suppose that line is outdated?
2021-02-19 21:25:58 +01:00
Teymour Aldridge
0b90a3df0a
Fix duplicate with props error messages. (#1730)
* Fix duplicate `with props` error messages.

* Fix error span.

* Use `quote!` for error message.

Co-authored-by: Simon <simon@siku2.io>

Co-authored-by: Simon <simon@siku2.io>
2021-02-05 23:43:13 +01:00
Teymour Aldridge
04fe2086f0
Fix clippy warnings on yew services. (#1731) 2021-02-05 20:30:00 +01:00
Teymour Aldridge
e0be985082
Replace #[to="..."] attribute with #[at="..."] attribute. (#1717)
* Replace `#[to="..."]` attribute with `#[at="..."]` attribute.

* Fix attribute formatting

* Fix spelling
2021-02-05 18:48:26 +01:00
Paolo Barbolini
de5021ba16
Bump minimum serde_yaml version in order to appease deps.rs (#1714) 2021-01-24 12:11:48 +01:00
Philip Peterson
5fc4387dc5
Rip out stdweb (#1697)
* feat: Remove usage of stdweb

* Cleanup Cargo.toml

* yew-services fixes

* fix doc test

Co-authored-by: Justin Starry <justin.starry@icloud.com>
2021-01-24 00:14:15 +08:00
Justin Starry
5adb142be5
Add Makefile.toml for yew-services (#1713) 2021-01-23 23:57:33 +08:00
Muhammad Hamza
ab76a446f1
Move yew/services to yew-services crate (#1693)
* move yew/services to yew-services crate

* fix stdweb examples

* remove services feature usage from workflow

* attempt at making CI pass

* remove unused feature

* add feature i missed during merge

* okay, it should compile now

* apply review

* fix yew-stdweb & aplease fmt

* misc fixes

Co-authored-by: Justin Starry <justin.starry@icloud.com>
2021-01-23 22:49:00 +08:00
Mindaugas Vinkelis
e5eda4e0fa
Added callback_future_once in yewtil (#1696) (#1712) 2021-01-23 20:22:28 +08:00
Justin Starry
aef2ee56c6
Fix CI by using local ws echo server (#1711) 2021-01-23 18:59:48 +08:00
Justin Starry
cf315476e8
yew-functional: Reorganize hooks into hook module (#1710) 2021-01-23 14:32:48 +08:00
Boomber
6f27a7440a
Added relevant examples section to the docs (#1695)
* Added relevant examples section to the doc page

* Added some relevant examples to doc comment.

* Change capitalization style
2021-01-23 11:25:51 +08:00
Justin Starry
a1809f209d
Enable std feature for indexmap (#1709) 2021-01-23 11:16:31 +08:00
Chan Kwan Yin
45b6cb8b07
Added missing KeyboardService re-export (#1694) 2021-01-23 09:13:09 +08:00
Justin Starry
389a6c4037
Clean up component lifecycle state (#1700) 2021-01-15 07:06:18 +08:00
Philip Peterson
e6a3ae7301
Move top-level crates to packages/<crate> (#1680)
* Move crates to packages/*

* Update Cargo.toml

* Update links

* Fix pull-request.yml

* Update examples Cargo.toml

* Update relative paths

* Update tests

* Fix path
2021-01-12 11:32:48 +08:00