Skip to content

Commit c4f62ff

Browse files
committed
Merge remote-tracking branch 'upstream/master' into fix/remerge-vtag-construction-opt
2 parents 4e70f06 + 2412a68 commit c4f62ff

File tree

220 files changed

+607
-7933
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

220 files changed

+607
-7933
lines changed

.github/workflows/pull-request.yml

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ jobs:
4141
command: clippy
4242
args: --all-targets -- -D warnings
4343

44-
- name: Run clippy - yew with all features
45-
if: always()
46-
run: |
47-
cd packages/yew
48-
cargo clippy --all-targets --features "cbor msgpack toml yaml" -- -D warnings
49-
5044
check_examples:
5145
name: Check Examples
5246
runs-on: ubuntu-latest
@@ -110,20 +104,11 @@ jobs:
110104
- name: Run doctest - yew with features
111105
run: |
112106
cd packages/yew
113-
cargo test --doc --features "doc_test wasm_test yaml msgpack cbor toml"
107+
cargo test --doc --features "doc_test wasm_test"
114108
115109
integration_tests:
116110
name: Integration Tests on ${{ matrix.toolchain }}
117111
runs-on: ubuntu-latest
118-
services:
119-
httpbin:
120-
image: kennethreitz/httpbin@sha256:599fe5e5073102dbb0ee3dbb65f049dab44fa9fc251f6835c9990f8fb196a72b
121-
ports:
122-
- 8080:80
123-
echo_server:
124-
image: jmalloc/echo-server@sha256:c461e7e54d947a8777413aaf9c624b4ad1f1bac5d8272475da859ae82c1abd7d
125-
ports:
126-
- 8081:8080
127112

128113
strategy:
129114
matrix:
@@ -163,19 +148,6 @@ jobs:
163148
cd packages/yew-router
164149
wasm-pack test --chrome --firefox --headless
165150
166-
- name: Run tests - yew-functional
167-
run: |
168-
cd packages/yew-functional
169-
wasm-pack test --chrome --firefox --headless
170-
171-
- name: Run tests - yew-services
172-
env:
173-
HTTPBIN_URL: "http://localhost:8080"
174-
ECHO_SERVER_URL: "ws://localhost:8081"
175-
run: |
176-
cd packages/yew-services
177-
wasm-pack test --chrome --firefox --headless -- --features "wasm_test httpbin_test echo_server_test"
178-
179151
unit_tests:
180152
name: Unit Tests on ${{ matrix.toolchain }}
181153
runs-on: ubuntu-latest

Cargo.toml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,18 @@
11
[workspace]
22
members = [
33
"packages/yew",
4-
"packages/yew-components",
54
"packages/yew-macro",
6-
"packages/yew-services",
75
"packages/yew-validation",
6+
"packages/yew-agent",
87

98
# Router
109
"packages/yew-router",
1110
"packages/yew-router-macro",
1211

13-
# Function components
14-
"packages/yew-functional",
15-
"packages/yew-functional-macro",
16-
17-
# Utilities
18-
"packages/yewtil",
19-
"packages/yewtil-macro",
20-
21-
# dsl
22-
"packages/yew-dsl",
23-
2412
# Examples
2513
"examples/boids",
2614
"examples/counter",
2715
"examples/crm",
28-
"examples/dashboard",
2916
"examples/dyn_create_destroy_apps",
3017
"examples/file_upload",
3118
"examples/futures",

examples/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ As an example, check out the TodoMVC example here: <https://examples.yew.rs/todo
3131
| [boids](boids) | Yew port of [Boids](https://en.wikipedia.org/wiki/Boids) |
3232
| [counter](counter) | Simple counter which can be incremented and decremented |
3333
| [crm](crm) | Shallow customer relationship management tool |
34-
| [dashboard](dashboard) | Uses the `fetch` and `websocket` services to load external data |
3534
| [dyn_create_destroy_apps](dyn_create_destroy_apps) | Uses the function `start_app_in_element` and the `AppHandle` struct to dynamically create and delete Yew apps |
36-
| [file_upload](file_upload) | Uses the `reader` service to read the content of user uploaded files |
35+
| [file_upload](file_upload) | Uses the `gloo::file` to read the content of user uploaded files |
3736
| [futures](futures) | Demonstrates how you can use futures and async code with Yew. Features a Markdown renderer. |
3837
| [game_of_life](game_of_life) | Implementation of [Conway's Game of Life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life) |
3938
| [inner_html](inner_html) | Embeds an external document as raw HTML by manually managing the element |

examples/boids/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ getrandom = { version = "0.2", features = ["js"] }
1212
rand = "0.8"
1313
serde = { version = "1.0", features = ["derive"] }
1414
yew = { path = "../../packages/yew" }
15-
yew-services = { path = "../../packages/yew-services" }
15+
gloo = { git = "https://github.com/rustwasm/gloo/" }

examples/boids/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,15 @@ trunk serve --release
1717

1818
## Concepts
1919

20-
The example uses [`IntervalService`] to drive the game loop.
20+
The example uses [`gloo::timers`](https://gloo-rs.web.app/docs/timer) implementation of `setInterval` to drive the Yew game loop.
2121

2222
## Improvements
2323

2424
- Add the possibility to switch the behaviour from flocking to scattering by inverting the cohesion rule so that boids avoid each other.
2525
This should also invert the color adaption to restore some variety.
26-
- Add keyboard shortcuts (using the `KeyboardService`) for the actions.
26+
- Add keyboard shortcuts for the actions.
2727
- Make it possible to hide the settings panel entirely
2828
- Bigger boids should accelerate slower than smaller ones
2929
- Share settings by encoding them into the URL
3030
- Resize the boids when "Spacing" is changed.
3131
The setting should then also be renamed to something like "Size".
32-
33-
[`intervalservice`]: https://docs.rs/yew-services/latest/yew_services/struct.IntervalService.html

examples/boids/src/settings.rs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1+
use gloo::storage::{LocalStorage, Storage};
12
use serde::{Deserialize, Serialize};
2-
use yew::format::Json;
3-
use yew_services::storage::{Area, StorageService};
43

54
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
65
pub struct Settings {
@@ -31,27 +30,15 @@ impl Settings {
3130
const KEY: &'static str = "yew.boids.settings";
3231

3332
pub fn load() -> Self {
34-
StorageService::new(Area::Local)
35-
.ok()
36-
.and_then(|storage| {
37-
storage
38-
.restore::<Json<anyhow::Result<Settings>>>(Self::KEY)
39-
.0
40-
.ok()
41-
})
42-
.unwrap_or_default()
33+
LocalStorage::get(Self::KEY).unwrap_or_default()
4334
}
4435

4536
pub fn remove() {
46-
if let Ok(mut storage) = StorageService::new(Area::Local) {
47-
storage.remove(Self::KEY);
48-
}
37+
LocalStorage::delete(Self::KEY);
4938
}
5039

5140
pub fn store(&self) {
52-
if let Ok(mut storage) = StorageService::new(Area::Local) {
53-
storage.store(Self::KEY, Json(self))
54-
}
41+
let _ = LocalStorage::set(Self::KEY, self);
5542
}
5643
}
5744
impl Default for Settings {

examples/boids/src/simulation.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use crate::boid::Boid;
22
use crate::math::Vector2D;
33
use crate::settings::Settings;
4-
use std::time::Duration;
4+
use gloo::timers::callback::Interval;
55
use yew::{html, Component, ComponentLink, Html, Properties, ShouldRender};
6-
use yew_services::interval::{IntervalService, IntervalTask};
76

87
pub const SIZE: Vector2D = Vector2D::new(1600.0, 1000.0);
98

@@ -26,7 +25,7 @@ pub struct Simulation {
2625
props: Props,
2726
link: ComponentLink<Self>,
2827
boids: Vec<Boid>,
29-
interval_task: IntervalTask,
28+
interval: Interval,
3029
}
3130
impl Component for Simulation {
3231
type Message = Msg;
@@ -38,16 +37,18 @@ impl Component for Simulation {
3837
.map(|_| Boid::new_random(settings))
3938
.collect();
4039

41-
let interval_task = IntervalService::spawn(
42-
Duration::from_millis(settings.tick_interval_ms),
43-
link.callback(|_| Msg::Tick),
44-
);
40+
let interval = {
41+
let link = link.clone();
42+
Interval::new(settings.tick_interval_ms as u32, move || {
43+
link.send_message(Msg::Tick)
44+
})
45+
};
4546

4647
Self {
4748
props,
4849
link,
4950
boids,
50-
interval_task,
51+
interval,
5152
}
5253
}
5354

@@ -86,10 +87,12 @@ impl Component for Simulation {
8687
if settings.tick_interval_ms != self.props.settings.tick_interval_ms {
8788
// as soon as the previous task is dropped it is cancelled.
8889
// We don't need to worry about manually stopping it.
89-
self.interval_task = IntervalService::spawn(
90-
Duration::from_millis(settings.tick_interval_ms),
91-
self.link.callback(|_| Msg::Tick),
92-
);
90+
self.interval = {
91+
let link = self.link.clone();
92+
Interval::new(settings.tick_interval_ms as u32, move || {
93+
link.send_message(Msg::Tick)
94+
})
95+
}
9396
}
9497

9598
self.props = props;

examples/counter/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ license = "MIT OR Apache-2.0"
88
[dependencies]
99
js-sys = "0.3"
1010
yew = { path = "../../packages/yew" }
11-
yew-services = { path = "../../packages/yew-services" }
11+
weblog = "0.3"
12+
wasm-bindgen = "0.2"

examples/counter/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use js_sys::Date;
2+
use weblog::console_log;
23
use yew::{html, Component, ComponentLink, Html, ShouldRender};
3-
use yew_services::ConsoleService;
44

55
// Define the possible messages which can be sent to the component
66
pub enum Msg {
@@ -25,12 +25,12 @@ impl Component for Model {
2525
match msg {
2626
Msg::Increment => {
2727
self.value += 1;
28-
ConsoleService::log("plus one"); // Will output a string to the browser console
28+
console_log!("plus one"); // Will output a string to the browser console
2929
true // Return true to cause the displayed change to update
3030
}
3131
Msg::Decrement => {
3232
self.value -= 1;
33-
ConsoleService::log("minus one");
33+
console_log!("minus one");
3434
true
3535
}
3636
}

examples/crm/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ license = "MIT OR Apache-2.0"
99
serde = "1"
1010
serde_derive = "1"
1111
yew = { path = "../../packages/yew" }
12-
yew-services = { path = "../../packages/yew-services" }
12+
gloo = { git = "https://github.com/rustwasm/gloo/" }
13+

0 commit comments

Comments
 (0)