Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
c98f685
Make a Renderer.
futursolo Jan 25, 2022
76b5ecf
Assistive nodes on hydration.
futursolo Jan 26, 2022
f2038c7
Prints assistive node for root as well.
futursolo Jan 27, 2022
9c43557
Merge branch 'yewstack:master' into hydration
futursolo Feb 9, 2022
2bb5701
Hydrate methods in AppHandle and Scope.
futursolo Feb 10, 2022
cd53916
Merge branch 'hydration' of https://github.com/futursolo/yew into hyd…
futursolo Feb 10, 2022
336f66b
Hydrate & ComponentState Refactoring (clippy).
futursolo Feb 10, 2022
61b69e8
Hydrate VText.
futursolo Feb 10, 2022
0b91f03
Fix ssr tests.
futursolo Feb 10, 2022
4dc2958
Fix end comment location.
futursolo Feb 10, 2022
51712af
Hydrate VList and VComp.
futursolo Feb 10, 2022
9e8bdac
Hydrate a VTag.
futursolo Feb 10, 2022
86ce59a
Shift fragments & Phantom Component.
futursolo Feb 10, 2022
c1a6dbf
Hydrate Suspense.
futursolo Feb 10, 2022
a2e3970
Remove extra comments.
futursolo Feb 10, 2022
0fed576
Trim Text Node before Starting to search nodes, Next Sibling, Remove …
futursolo Feb 10, 2022
4f2eb81
Remove redundant next_sibling handling.
futursolo Feb 10, 2022
487de57
Assert element to be element.
futursolo Feb 10, 2022
f77d085
Add more documentation & move second render to always happen after hy…
futursolo Feb 11, 2022
0fbc185
Component ID & Parent always rendered First, Hydrate before first_ren…
futursolo Feb 11, 2022
4ef70d6
Fix scheduler.
futursolo Feb 11, 2022
37f06ab
Hydration capable simple ssr example.
futursolo Feb 11, 2022
3124c0a
void elements, function router example.
futursolo Feb 11, 2022
0319dab
Fix usize.
futursolo Feb 11, 2022
8edceeb
Fix example.
futursolo Feb 11, 2022
e703830
Better debugging support.
futursolo Feb 11, 2022
a7d355a
Hydration documentation.
futursolo Feb 11, 2022
88fd0e7
Hydration is no longer default feature.
futursolo Feb 11, 2022
9f7af45
Formatting & Feature flags.
futursolo Feb 11, 2022
7d29256
FIx pr-flow.
futursolo Feb 11, 2022
885e0c9
Fix pr-flow.
futursolo Feb 11, 2022
0b8dbaa
Introduce Fragment.
futursolo Feb 12, 2022
74fabb1
Fix shift of hydration fragment.
futursolo Feb 12, 2022
277b41a
Move children to children.rs.
futursolo Feb 12, 2022
3171fe4
Add tests.
futursolo Feb 12, 2022
caa25ef
Cleanup the codebase.
futursolo Feb 13, 2022
2d8672b
Merge scheduler queue.
futursolo Feb 13, 2022
ec08c6b
Shorter opening and closing tags.
futursolo Feb 13, 2022
c231e60
Prevent fallback from suspending Suspense.
futursolo Feb 13, 2022
4d96d9b
Update packages/yew/src/html/component/marker.rs
futursolo Feb 18, 2022
3c7c305
remove log, add trace_hydration.
futursolo Feb 18, 2022
b4a2616
Do not spawn a new thread for every request in the examples.
futursolo Feb 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions .github/workflows/main-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ jobs:
args: --doc --features doc_test --features wasm_test



integration_tests:
name: Integration Tests on ${{ matrix.toolchain }}
runs-on: ubuntu-latest
Expand Down Expand Up @@ -156,9 +155,39 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
args: --all-targets --workspace --exclude yew --exclude website-test
args: --all-targets --workspace --exclude website-test


ssr_tests:
name: SSR Tests on ${{ matrix.toolchain }}
runs-on: ubuntu-latest
strategy:
matrix:
toolchain:
# anyway to dynamically grep the MSRV from Cargo.toml?
- 1.56.0 # MSRV
- stable
- nightly

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
override: true
profile: minimal

- uses: Swatinem/rust-cache@v1

- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace ssr_tests --features ssr


test-lints:
name: Test lints on nightly
Expand All @@ -180,4 +209,3 @@ jobs:
with:
command: test
args: -p yew-macro test_html_lints --features lints

5 changes: 5 additions & 0 deletions .github/workflows/publish-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ jobs:
continue
fi

# ssr does not need trunk
if [[ "$example" == "ssr_router" ]]; then
continue
fi

echo "building: $example"
(
cd "$path"
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ members = [
"examples/dyn_create_destroy_apps",
"examples/file_upload",
"examples/function_memory_game",
"examples/function_router",
"examples/function_todomvc",
"examples/futures",
"examples/game_of_life",
Expand All @@ -28,6 +29,7 @@ members = [
"examples/portals",
"examples/router",
"examples/simple_ssr",
"examples/ssr_router",
"examples/timer",
"examples/todomvc",
"examples/two_apps",
Expand Down
2 changes: 1 addition & 1 deletion Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ dependencies = ["test"]
[tasks.test]
private = true
command = "cargo"
args = ["test", "--all-targets", "--workspace", "--exclude", "website-test"]
args = ["test", "--all-targets", "--workspace", "--exclude", "website-test", "--exclude", "changelog"]

[tasks.doc-test-flow]
private = true
Expand Down
23 changes: 23 additions & 0 deletions examples/function_router/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "function_router"
version = "0.1.0"
edition = "2021"
license = "MIT OR Apache-2.0"

[dependencies]
lipsum = "0.8"
log = "0.4"
rand = { version = "0.8", features = ["small_rng"] }
yew = { path = "../../packages/yew" }
yew-router = { path = "../../packages/yew-router" }
serde = { version = "1.0", features = ["derive"] }
lazy_static = "1.4.0"
gloo-timers = "0.2"

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2", features = ["js"] }
instant = { version = "0.1", features = ["wasm-bindgen"] }
wasm-logger = "0.2"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
instant = { version = "0.1" }
49 changes: 49 additions & 0 deletions examples/function_router/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Function Router Example

This is identical to the router example, but written in function
components.

[![Demo](https://img.shields.io/website?label=demo&url=https%3A%2F%2Fexamples.yew.rs%2Ffunction_router)](https://examples.yew.rs/function_router)

A blog all about yew.
The best way to figure out what this example is about is to just open it up.
It's mobile friendly too!

## Running

While not strictly necessary, this example should be built in release mode:

```bash
trunk serve --release
```

Content generation can take up quite a bit of time in debug builds.

## Concepts

This example involves many different parts, here are just the Yew specific things:

- Uses [`yew-router`] to render and switch between multiple pages.

The example automatically adapts to the `--public-url` value passed to Trunk.
This allows it to be hosted on any path, not just at the root.
For example, our demo is hosted at [/router](https://examples.yew.rs/router).

This is achieved by adding `<base data-trunk-public-url />` to the [index.html](index.html) file.
Trunk rewrites this tag to contain the value passed to `--public-url` which can then be retrieved at runtime.
Take a look at [`Route`](src/main.rs) for the implementation.

## Improvements

- Use a special image component which shows a progress bar until the image is loaded.
- Scroll back to the top after switching route
- Run content generation in a dedicated web worker
- Use longer Markov chains to achieve more coherent results
- Make images deterministic (the same seed should produce the same images)
- Show posts by the author on their page
(this is currently impossible because we need to find post seeds which in turn generate the author's seed)
- Show other posts at the end of a post ("continue reading")
- Home (`/`) should include links to the post list and the author introduction
- Detect sub-path from `--public-url` value passed to Trunk. See: thedodd/trunk#51

[`yew-router`]: https://docs.rs/yew-router/latest/yew_router/
34 changes: 34 additions & 0 deletions examples/function_router/data/keywords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
allergenics
archaeology
austria
berries
birds
color
conservation
cosmology
culture
europe
evergreens
fleshy
france
guides
horticulture
ireland
landscaping
medicine
music
poison
religion
rome
rust
scotland
seeds
spain
taxonomy
toxics
tradition
trees
wasm
wood
woodworking
yew
20 changes: 20 additions & 0 deletions examples/function_router/data/syllables.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ald
ber
fe
ger
jo
jus
kas
lix
lu
mon
mour
nas
ridge
ry
si
star
tey
tim
tin
yew
Loading