Skip to content

Commit 8bc2212

Browse files
authored
#[cfg(feature = "render")] and yew::Renderer (yewstack#2498)
* Bring changes to this branch. * Bring changes to this branch. * Add feature render and renderer. * Bring changes to this branch. * Migrate examples to Renderer. * Satisfy no any render. * Satisfy ssr. * Satisfy feature render. * Lint feature soundness. * Suppress tests. * Fix pr-flow, update docs. * Add a notice. * Adjust visibility. * Correctly feature gate tests. * make test scope available under feature render. * Fix CI. * Fix CI. * Restore tests module to its original place as well. * Make bundles crate private. * Make most bundle APIs private. * Adjust docs. * Adjust debug implementation. * Replace start_app with Renderer. * Adjust documentation. * Remove unused lint. * Remove start_app from docs. * DomBundle -> ReconcileTarget. * Adjust documentation. * Once render, now csr. * Fix docs as well.
1 parent 3ad4540 commit 8bc2212

File tree

99 files changed

+1457
-1080
lines changed

Some content is hidden

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

99 files changed

+1457
-1080
lines changed

.github/workflows/main-checks.yml

+16-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ jobs:
2727
command: clippy
2828
args: --all-targets -- -D warnings
2929

30+
- name: Lint feature soundness
31+
run: |
32+
cargo clippy -- --deny=warnings
33+
cargo clippy --features=ssr -- --deny=warnings
34+
cargo clippy --features=csr -- --deny=warnings
35+
cargo clippy --all-features --all-targets -- --deny=warnings
36+
working-directory: packages/yew
37+
3038

3139
clippy-release:
3240
name: Clippy on release profile
@@ -49,6 +57,14 @@ jobs:
4957
command: clippy
5058
args: --all-targets --release -- -D warnings
5159

60+
- name: Lint feature soundness
61+
run: |
62+
cargo clippy --release -- --deny=warnings
63+
cargo clippy --release --features=ssr -- --deny=warnings
64+
cargo clippy --release --features=csr -- --deny=warnings
65+
cargo clippy --release --all-features --all-targets -- --deny=warnings
66+
working-directory: packages/yew
67+
5268

5369
doc_tests:
5470
name: Documentation Tests
@@ -180,4 +196,3 @@ jobs:
180196
with:
181197
command: test
182198
args: -p yew-macro test_html_lints --features lints
183-

examples/agents/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ license = "MIT OR Apache-2.0"
99
log = "0.4"
1010
serde = { version = "1.0", features = ["derive"] }
1111
wasm-logger = "0.2"
12-
yew = { path = "../../packages/yew" }
12+
yew = { path = "../../packages/yew", features = ["csr"] }
1313
yew-agent = { path = "../../packages/yew-agent" }
1414
gloo-timers = "0.2"

examples/agents/src/bin/app.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
fn main() {
22
wasm_logger::init(wasm_logger::Config::default());
3-
yew::start_app::<agents::App>();
3+
yew::Renderer::<agents::App>::new().render();
44
}

examples/boids/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ anyhow = "1.0"
1111
getrandom = { version = "0.2", features = ["js"] }
1212
rand = "0.8"
1313
serde = { version = "1.0", features = ["derive"] }
14-
yew = { path = "../../packages/yew" }
14+
yew = { path = "../../packages/yew", features = ["csr"] }
1515
gloo = "0.6"
1616

1717
[dependencies.web-sys]

examples/boids/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,5 +162,5 @@ impl App {
162162
}
163163

164164
fn main() {
165-
yew::start_app::<App>();
165+
yew::Renderer::<App>::new().render();
166166
}

examples/contexts/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ license = "MIT OR Apache-2.0"
66

77
[dependencies]
88
serde = { version = "1.0", features = ["derive"] }
9-
yew = { path = "../../packages/yew" }
9+
yew = { path = "../../packages/yew", features = ["csr"] }
1010
yew-agent = { path = "../../packages/yew-agent" }

examples/contexts/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ pub fn App() -> Html {
1919
}
2020

2121
fn main() {
22-
yew::start_app::<App>();
22+
yew::Renderer::<App>::new().render();
2323
}

examples/counter/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ license = "MIT OR Apache-2.0"
88
[dependencies]
99
gloo-console = "0.2"
1010
js-sys = "0.3"
11-
yew = { path = "../../packages/yew" }
11+
yew = { path = "../../packages/yew", features = ["csr"] }
1212
wasm-bindgen = "0.2"

examples/counter/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,5 @@ impl Component for App {
7272
}
7373

7474
fn main() {
75-
yew::start_app::<App>();
75+
yew::Renderer::<App>::new().render();
7676
}

examples/dyn_create_destroy_apps/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
77

88
[dependencies]
99
js-sys = "0.3"
10-
yew = { path = "../../packages/yew" }
10+
yew = { path = "../../packages/yew", features = ["csr"] }
1111
slab = "0.4.3"
1212
gloo = "0.6"
1313
wasm-bindgen = "0.2"

examples/dyn_create_destroy_apps/src/main.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,15 @@ impl Component for App {
5555
// Get the key for the entry and create and mount a new CounterModel app
5656
// with a callback that destroys the app when emitted
5757
let app_key = app_entry.key();
58-
let new_counter_app = yew::start_app_with_props_in_element(
58+
let new_counter_app = yew::Renderer::<CounterModel>::with_root_and_props(
5959
app_div.clone(),
6060
CounterProps {
6161
destroy_callback: ctx
6262
.link()
6363
.callback(move |_| Msg::DestroyCounterApp(app_key)),
6464
},
65-
);
65+
)
66+
.render();
6667

6768
// Insert the app and the app div to our app collection
6869
app_entry.insert((app_div, new_counter_app));
@@ -107,5 +108,5 @@ impl Component for App {
107108

108109
fn main() {
109110
// Start main app
110-
yew::start_app::<App>();
111+
yew::Renderer::<App>::new().render();
111112
}

examples/file_upload/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
77

88
[dependencies]
99
js-sys = "0.3"
10-
yew = { path = "../../packages/yew" }
10+
yew = { path = "../../packages/yew", features = ["csr"] }
1111
gloo-file = "0.2"
1212

1313
[dependencies.web-sys]

examples/file_upload/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,5 @@ impl App {
124124
}
125125

126126
fn main() {
127-
yew::start_app::<App>();
127+
yew::Renderer::<App>::new().render();
128128
}

examples/function_memory_game/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ gloo = "0.6"
1313
nanoid = "0.4"
1414
rand = "0.8"
1515
getrandom = { version = "0.2", features = ["js"] }
16-
yew = { path = "../../packages/yew" }
16+
yew = { path = "../../packages/yew", features = ["csr"] }
1717

1818
[dependencies.web-sys]
1919
version = "0.3"

examples/function_memory_game/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ mod state;
66
use crate::components::app::App;
77

88
fn main() {
9-
yew::start_app::<App>();
9+
yew::Renderer::<App>::new().render();
1010
}

examples/function_router/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ wasm-logger = "0.2"
2121

2222
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
2323
instant = { version = "0.1" }
24+
25+
[features]
26+
csr = ["yew/csr"]

examples/function_router/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
href="https://cdn.jsdelivr.net/npm/bulma@0.9.0/css/bulma.min.css"
1212
/>
1313
<link data-trunk rel="sass" href="index.scss" />
14+
<link data-trunk rel="rust" data-cargo-features="csr" />
1415
</head>
1516

1617
<body></body>

examples/function_router/src/main.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ pub use app::*;
99
fn main() {
1010
#[cfg(target_arch = "wasm32")]
1111
wasm_logger::init(wasm_logger::Config::new(log::Level::Trace));
12-
yew::start_app::<App>();
12+
#[cfg(feature = "render")]
13+
yew::Renderer::<App>::new().render();
1314
}

examples/function_todomvc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ serde = { version = "1.0", features = ["derive"] }
1010
strum = "0.24"
1111
strum_macros = "0.24"
1212
gloo = "0.6"
13-
yew = { path = "../../packages/yew" }
13+
yew = { path = "../../packages/yew", features = ["csr"] }
1414

1515
[dependencies.web-sys]
1616
version = "0.3"

examples/function_todomvc/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,5 +145,5 @@ fn app() -> Html {
145145
}
146146

147147
fn main() {
148-
yew::start_app::<App>();
148+
yew::Renderer::<App>::new().render();
149149
}

examples/futures/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0"
99
pulldown-cmark = { version = "0.9", default-features = false }
1010
wasm-bindgen = "0.2"
1111
wasm-bindgen-futures = "0.4"
12-
yew = { path = "../../packages/yew", features = ["tokio"] }
12+
yew = { path = "../../packages/yew", features = ["tokio", "csr"] }
1313
gloo-utils = "0.1"
1414

1515
[dependencies.web-sys]

examples/futures/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,5 @@ impl Component for App {
128128
}
129129

130130
fn main() {
131-
yew::start_app::<App>();
131+
yew::Renderer::<App>::new().render();
132132
}

examples/game_of_life/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ getrandom = { version = "0.2", features = ["js"] }
1414
log = "0.4"
1515
rand = "0.8"
1616
wasm-logger = "0.2"
17-
yew = { path = "../../packages/yew" }
17+
yew = { path = "../../packages/yew", features = ["csr"] }
1818
gloo-timers = "0.2"

examples/game_of_life/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,5 +226,5 @@ fn wrap(coord: isize, range: isize) -> usize {
226226
fn main() {
227227
wasm_logger::init(wasm_logger::Config::default());
228228
log::trace!("Initializing yew...");
229-
yew::start_app::<App>();
229+
yew::Renderer::<App>::new().render();
230230
}

examples/inner_html/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66
license = "MIT OR Apache-2.0"
77

88
[dependencies]
9-
yew = { path = "../../packages/yew" }
9+
yew = { path = "../../packages/yew", features = ["csr"] }
1010
gloo-utils = "0.1"
1111

1212
[dependencies.web-sys]

examples/inner_html/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ impl Component for App {
2626
}
2727

2828
fn main() {
29-
yew::start_app::<App>();
29+
yew::Renderer::<App>::new().render();
3030
}

examples/js_callback/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
77

88
[dependencies]
99
wasm-bindgen = "0.2"
10-
yew = { path = "../../packages/yew" }
10+
yew = { path = "../../packages/yew", features = ["csr"] }
1111

1212
[dependencies.web-sys]
1313
version = "0.3"

examples/js_callback/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,5 @@ impl Component for App {
7373
}
7474

7575
fn main() {
76-
yew::start_app::<App>();
76+
yew::Renderer::<App>::new().render();
7777
}

examples/keyed_list/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ instant = { version = "0.1", features = ["wasm-bindgen"] }
1212
log = "0.4"
1313
rand = "0.8"
1414
wasm-logger = "0.2"
15-
yew = { path = "../../packages/yew" }
15+
yew = { path = "../../packages/yew", features = ["csr"] }
1616

1717
[dependencies.web-sys]
1818
version = "0.3"

examples/keyed_list/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,5 +279,5 @@ impl App {
279279

280280
fn main() {
281281
wasm_logger::init(wasm_logger::Config::new(log::Level::Trace));
282-
yew::start_app::<App>();
282+
yew::Renderer::<App>::new().render();
283283
}

examples/mount_point/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
77

88
[dependencies]
99
wasm-bindgen = "0.2"
10-
yew = { path = "../../packages/yew" }
10+
yew = { path = "../../packages/yew", features = ["csr"] }
1111
gloo-utils = "0.1"
1212

1313
[dependencies.web-sys]

examples/mount_point/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,5 @@ fn main() {
7373

7474
body.append_child(&mount_point).unwrap();
7575

76-
yew::start_app_in_element::<App>(mount_point);
76+
yew::Renderer::<App>::with_root(mount_point).render();
7777
}

examples/nested_list/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ license = "MIT OR Apache-2.0"
88
[dependencies]
99
log = "0.4"
1010
wasm-logger = "0.2"
11-
yew = { path = "../../packages/yew" }
11+
yew = { path = "../../packages/yew", features = ["csr"] }

examples/nested_list/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,5 @@ impl fmt::Display for Hovered {
6363

6464
fn main() {
6565
wasm_logger::init(wasm_logger::Config::default());
66-
yew::start_app::<app::App>();
66+
yew::Renderer::<app::App>::new().render();
6767
}

examples/node_refs/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ edition = "2021"
66
license = "MIT OR Apache-2.0"
77

88
[dependencies]
9-
yew = { path = "../../packages/yew" }
9+
yew = { path = "../../packages/yew", features = ["csr"] }
1010
web-sys = { version = "0.3", features = ["HtmlElement", "HtmlInputElement", "Node"] }

examples/node_refs/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,5 @@ impl Component for App {
7777
}
7878

7979
fn main() {
80-
yew::start_app::<App>();
80+
yew::Renderer::<App>::new().render();
8181
}

examples/password_strength/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88
[dependencies]
9-
yew = { path = "../../packages/yew" }
9+
yew = { path = "../../packages/yew", features = ["csr"] }
1010
zxcvbn = "2.1.2, <2.2.0"
1111
js-sys = "0.3.46"
1212
web-sys = { version = "0.3", features = ["Event","EventTarget","InputEvent"] }

examples/password_strength/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ mod password;
88
use app::App;
99

1010
fn main() {
11-
yew::start_app::<App>();
11+
yew::Renderer::<App>::new().render();
1212
}

examples/portals/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66
license = "MIT OR Apache-2.0"
77

88
[dependencies]
9-
yew = { path = "../../packages/yew" }
9+
yew = { path = "../../packages/yew", features = ["csr"] }
1010
gloo-utils = "0.1"
1111
wasm-bindgen = "0.2"
1212

examples/portals/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,5 @@ impl Component for App {
102102
}
103103

104104
fn main() {
105-
yew::start_app::<App>();
105+
yew::Renderer::<App>::new().render();
106106
}

examples/router/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ log = "0.4"
1111
getrandom = { version = "0.2", features = ["js"] }
1212
rand = { version = "0.8", features = ["small_rng"] }
1313
wasm-logger = "0.2"
14-
yew = { path = "../../packages/yew" }
14+
yew = { path = "../../packages/yew", features = ["csr"] }
1515
yew-router = { path = "../../packages/yew-router" }
1616
serde = { version = "1.0", features = ["derive"] }
1717
lazy_static = "1.4.0"

examples/router/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,5 @@ fn switch(routes: &Route) -> Html {
147147

148148
fn main() {
149149
wasm_logger::init(wasm_logger::Config::new(log::Level::Trace));
150-
yew::start_app::<App>();
150+
yew::Renderer::<App>::new().render();
151151
}

examples/suspense/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

99
[dependencies]
10-
yew = { path = "../../packages/yew", features = ["tokio"] }
10+
yew = { path = "../../packages/yew", features = ["tokio", "csr"] }
1111
gloo-timers = { version = "0.2.2", features = ["futures"] }
1212
wasm-bindgen-futures = "0.4"
1313
wasm-bindgen = "0.2"

examples/suspense/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@ fn app() -> Html {
5656
}
5757

5858
fn main() {
59-
yew::start_app::<App>();
59+
yew::Renderer::<App>::new().render();
6060
}

examples/timer/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66
license = "MIT OR Apache-2.0"
77

88
[dependencies]
9-
yew = { path = "../../packages/yew" }
9+
yew = { path = "../../packages/yew", features = ["csr"] }
1010
js-sys = "0.3"
1111
gloo = "0.6"
1212
wasm-bindgen = "0.2"

examples/timer/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,5 @@ impl Component for App {
150150
}
151151

152152
fn main() {
153-
yew::start_app::<App>();
153+
yew::Renderer::<App>::new().render();
154154
}

0 commit comments

Comments
 (0)