Skip to content

Commit fa8a1d9

Browse files
authored
Reorganize examples and general repo layout (yewstack#1092)
* Reorganize crates * Remove symlink * Check examples * Cleanup CI scripts * nits * cleanup * cargo fmt * Fix yew-stdweb * cargo clippy --all * stdweb-examples * run_emscripten_checks.sh * Fix typo * fix typo * yew-stdweb * Run tests from yew-stdweb * fix webgl script
1 parent 6c16c8c commit fa8a1d9

File tree

271 files changed

+1070
-2012
lines changed

Some content is hidden

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

271 files changed

+1070
-2012
lines changed

.rustfmt.toml

-2
This file was deleted.

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ install:
3636
- ./ci/install_cargo_web.sh
3737

3838
script:
39-
- ./ci/run_checks.sh
39+
- ./ci/run_stable_checks.sh
4040
- GECKODRIVER=$(pwd)/geckodriver ./ci/run_tests.sh
41-
- ./ci/check_examples.sh
41+
- ./ci/run_emscripten_checks.sh

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ cloned is when a wrapper component re-renders nested children components.
404404

405405
- #### ⚡️ Features
406406

407-
- `Future` support :tada: A `Component` can update following the completion of a `Future`. Check out [this example](https://github.com/yewstack/yew/tree/master/examples/futures) to see how it works. This approach was borrowed from a fork of Yew called [`plaster`](https://github.com/carlosdp/plaster) created by [@carlosdp]. [[@hgzimmerman], [#717](https://github.com/yewstack/yew/pull/717)]
407+
- `Future` support :tada: A `Component` can update following the completion of a `Future`. Check out [this example](https://github.com/yewstack/yew/tree/v0.14.0/examples/futures) to see how it works. This approach was borrowed from a fork of Yew called [`plaster`](https://github.com/carlosdp/plaster) created by [@carlosdp]. [[@hgzimmerman], [#717](https://github.com/yewstack/yew/pull/717)]
408408
- Added the `agent` and `services` features so that this functionality can be disabled (useful if you are switching to using `Future`s). [[@hgzimmerman], [#684](https://github.com/yewstack/yew/pull/684)]
409409
- Add `ref` keyword for allowing a `Component` to have a direct reference to its rendered elements. For example, you can now easily focus an `<input>` element after mounting. [[@jstarry], [#715](https://github.com/yewstack/yew/pull/715)]
410410

CONTRIBUTING.md

+11-22
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,24 @@
88
rustup target add wasm32-unknown-unknown
99
```
1010

11-
#### Install [cargo-web]
12-
13-
This is an optional tool that simplifies running the examples:
11+
#### Build
1412

1513
```bash
16-
cargo install cargo-web
14+
cargo build --target wasm32-unknown-unknown
1715
```
1816

19-
> Add `--force` option to ensure you install the latest version.
17+
#### Examples
2018

21-
[cargo-web]: https://github.com/koute/cargo-web
19+
TODO: Add more info
2220

23-
#### Build
21+
##### stdweb
22+
In order to run the examples in `./yew-stdweb`, you may wish to install [cargo-web]:
2423

25-
Either
26-
```bash
27-
cargo build --target wasm32-unknown-unknown --features web_sys
28-
```
29-
or
3024
```bash
31-
cargo build --target wasm32-unknown-unknown --features std_web
25+
cargo install cargo-web
3226
```
33-
See more about features [here](https://docs.rs/yew/0.14.0/yew/#important-notes)
3427

28+
[cargo-web]: https://github.com/koute/cargo-web
3529

3630
#### Test
3731

@@ -48,9 +42,9 @@ although more driver support may be added! You can download these at:
4842
* safaridriver - should be preinstalled on OSX
4943

5044
##### Macro Tests
51-
When adding or updating tests, please make sure you have updated the appropriate `stderr` file, which you can find [here](https://github.com/yewstack/yew/tree/master/crates/macro/tests/macro) for the `html!` macro. These files ensure that macro compilation errors are correct and easy to understand.
45+
When adding or updating tests, please make sure you have updated the appropriate `stderr` file, which you can find [here](https://github.com/yewstack/yew/tree/master/yew-macro/tests/macro) for the `html!` macro. These files ensure that macro compilation errors are correct and easy to understand.
5246

53-
To update or generate a new `stderr` file you can run `TRYBUILD=overwrite cargo test --test macro_test` or `TRYBUILD=overwrite cargo test --test derive_props_test` from the `crates/macro` directory.
47+
To update or generate a new `stderr` file you can run `TRYBUILD=overwrite cargo test --test macro_test` or `TRYBUILD=overwrite cargo test --test derive_props_test` from the `yew-macro` directory.
5448

5549
##### Running Tests
5650

@@ -60,10 +54,5 @@ To update or generate a new `stderr` file you can run `TRYBUILD=overwrite cargo
6054
or
6155

6256
```bash
63-
cargo test --target wasm32-unknown-unknown --features wasm_test --features web_sys
64-
```
65-
or
66-
67-
```bash
68-
cargo test --target wasm32-unknown-unknown --features wasm_test --features std_web
57+
cargo test --target wasm32-unknown-unknown --features wasm_test
6958
```

Cargo.toml

+29-139
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,32 @@
1-
[package]
2-
name = "yew"
3-
version = "0.14.3"
4-
edition = "2018"
5-
authors = [
6-
"Denis Kolodin <deniskolodin@gmail.com>",
7-
"Justin Starry <justin@yew.rs>",
8-
]
9-
repository = "https://github.com/yewstack/yew"
10-
homepage = "https://github.com/yewstack/yew"
11-
documentation = "https://docs.rs/yew/"
12-
license = "MIT/Apache-2.0"
13-
readme = "README.md"
14-
keywords = ["web", "asmjs", "webasm", "javascript"]
15-
categories = ["gui", "web-programming"]
16-
description = "A framework for making client-side single-page apps"
17-
18-
[badges]
19-
travis-ci = { repository = "yewstack/yew" }
20-
21-
[dependencies]
22-
anyhow = "1"
23-
anymap = "0.12"
24-
bincode = { version = "~1.2.1", optional = true }
25-
cfg-if = "0.1"
26-
cfg-match = "0.2"
27-
console_error_panic_hook = { version = "0.1", optional = true }
28-
futures = { version = "0.3", optional = true }
29-
gloo = { version = "0.2.1", optional = true }
30-
http = "0.2"
31-
indexmap = "1.0.2"
32-
js-sys = { version = "0.3", optional = true }
33-
log = "0.4"
34-
proc-macro-hack = "0.5"
35-
proc-macro-nested = "0.1"
36-
rmp-serde = { version = "0.14.0", optional = true }
37-
serde = { version = "1.0", features = ["derive"] }
38-
serde_cbor = { version = "0.11.1", optional = true }
39-
serde_json = "1.0"
40-
serde_yaml = { version = "0.8.3", optional = true }
41-
slab = "0.4"
42-
stdweb = { version = "0.4.20", optional = true }
43-
thiserror = "1"
44-
toml = { version = "0.5", optional = true }
45-
wasm-bindgen = { version = "0.2.60", optional = true }
46-
wasm-bindgen-futures = { version = "0.4", optional = true }
47-
yew-macro = { version = "0.14.1", path = "crates/macro" }
48-
49-
[dependencies.web-sys]
50-
version = "0.3"
51-
optional = true
52-
features = [
53-
"AbortController",
54-
"AbortSignal",
55-
"BinaryType",
56-
"Blob",
57-
"BlobPropertyBag",
58-
"console",
59-
"DedicatedWorkerGlobalScope",
60-
"Document",
61-
"DomTokenList",
62-
"DragEvent",
63-
"Element",
64-
"Event",
65-
"EventTarget",
66-
"File",
67-
"FileList",
68-
"FileReader",
69-
"FocusEvent",
70-
"Headers",
71-
"HtmlElement",
72-
"HtmlInputElement",
73-
"HtmlSelectElement",
74-
"HtmlTextAreaElement",
75-
"KeyboardEvent",
76-
"Location",
77-
"MessageEvent",
78-
"MouseEvent",
79-
"Node",
80-
"ObserverCallback",
81-
"PointerEvent",
82-
"ReferrerPolicy",
83-
"Request",
84-
"RequestCache",
85-
"RequestCredentials",
86-
"RequestInit",
87-
"RequestMode",
88-
"RequestRedirect",
89-
"Response",
90-
"Storage",
91-
"Text",
92-
"TouchEvent",
93-
"UiEvent",
94-
"Url",
95-
"WebSocket",
96-
"WheelEvent",
97-
"Window",
98-
"Worker",
99-
"WorkerGlobalScope",
100-
"WorkerOptions",
101-
]
102-
103-
# Changes here must be reflected in `build.rs`
104-
[target.'cfg(all(target_arch = "wasm32", not(target_os="wasi"), not(cargo_web)))'.dependencies]
105-
wasm-bindgen = "0.2.60"
106-
107-
# Changes here must be reflected in `build.rs`
108-
[target.'cfg(all(target_arch = "wasm32", not(target_os="wasi"), not(cargo_web)))'.dev-dependencies]
109-
wasm-bindgen-test = "0.3.4"
110-
base64 = "0.12.0"
111-
ssri = "5.0.0"
112-
113-
[target.'cfg(target_os = "emscripten")'.dependencies]
114-
ryu = "1.0.2" # 1.0.1 breaks emscripten
115-
116-
[dev-dependencies]
117-
serde_derive = "1"
118-
trybuild = "1.0"
119-
rustversion = "1.0"
120-
rmp-serde = "0.14.0"
121-
bincode = "~1.2.1"
122-
123-
[features]
124-
default = ["services", "agent"]
125-
std_web = ["stdweb"]
126-
web_sys = ["console_error_panic_hook", "futures", "gloo", "js-sys", "web-sys", "wasm-bindgen", "wasm-bindgen-futures"]
127-
doc_test = []
128-
wasm_test = []
129-
services = []
130-
agent = ["bincode"]
131-
yaml = ["serde_yaml"]
132-
msgpack = ["rmp-serde"]
133-
cbor = ["serde_cbor"]
134-
135-
[package.metadata.docs.rs]
136-
features = ["web_sys", "agent", "services", "yaml", "cbor", "toml", "msgpack", "doc_test"]
137-
1381
[workspace]
1392
members = [
140-
"crates/macro",
141-
"crates/functional",
3+
"yew",
4+
"yew-functional",
5+
"yew-macro",
6+
7+
# Examples
8+
"examples/counter",
9+
"examples/crm",
10+
"examples/custom_components",
11+
"examples/dashboard",
12+
"examples/file_upload",
13+
"examples/fragments",
14+
"examples/futures",
15+
"examples/game_of_life",
16+
"examples/inner_html",
17+
"examples/js_callback",
18+
"examples/large_table",
19+
"examples/minimal",
20+
"examples/mount_point",
21+
"examples/multi_thread",
22+
"examples/nested_list",
23+
"examples/node_refs",
24+
"examples/npm_and_rest",
25+
"examples/pub_sub",
26+
"examples/server",
27+
"examples/textarea",
28+
"examples/timer",
29+
"examples/todomvc",
30+
"examples/two_apps",
31+
"examples/webgl",
14232
]

ci/check_examples.sh

-38
This file was deleted.

ci/run_checks.sh

-12
This file was deleted.

ci/run_emscripten_checks.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
echo "$(rustup default)" | grep -q "1.39.0"
3+
emscripten_supported=$?
4+
set -euxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
5+
6+
pushd yew-stdweb
7+
if [ "$emscripten_supported" == "0" ]; then
8+
# TODO - Emscripten builds are broken on rustc > 1.39.0
9+
cargo check --all --target asmjs-unknown-emscripten
10+
cargo check --all --target wasm32-unknown-emscripten
11+
fi
12+
popd

ci/run_stable_checks.sh

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
3+
echo "$(rustup default)" | grep -q "stable"
4+
if [ "$?" != "0" ]; then
5+
# only run checks on stable
6+
exit 0
7+
fi
8+
9+
set -euxo pipefail
10+
11+
cargo fmt --all -- --check
12+
cargo clippy --all -- --deny=warnings
13+
cargo check --all
14+
15+
# Enable all optional features
16+
(cd yew \
17+
&& cargo check --features cbor,msgpack,toml,yaml \
18+
&& cargo clippy --features cbor,msgpack,toml,yaml -- --deny=warnings)
19+
20+
# Check stdweb
21+
pushd yew-stdweb
22+
cargo fmt --all -- --check
23+
cargo clippy --all -- --deny=warnings
24+
cargo check --all --target wasm32-unknown-unknown
25+
26+
# webgl_stdweb doesn't play nice with wasm-bindgen
27+
(cd examples/webgl && cargo web check --target wasm32-unknown-unknown)
28+
popd

ci/run_tests.sh

+16-13
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,25 @@ echo "$(rustup default)" | grep -q "1.39.0"
33
emscripten_supported=$?
44
set -euxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
55

6-
cargo test --target wasm32-unknown-unknown --features wasm_test,std_web
7-
cargo test --target wasm32-unknown-unknown --features wasm_test,web_sys
6+
(cd yew \
7+
&& cargo test --target wasm32-unknown-unknown --features wasm_test \
8+
&& cargo test --doc --features doc_test,wasm_test,yaml,msgpack,cbor,toml \
9+
&& cargo test --doc --features doc_test,wasm_test,yaml,msgpack,cbor,toml \
10+
--features std_web,agent,services --no-default-features)
811

9-
if [ "$emscripten_supported" == "0" ]; then
10-
# TODO - Emscripten builds are broken on rustc > 1.39.0
11-
cargo web test --target asmjs-unknown-emscripten --features std_web
12-
cargo web test --target wasm32-unknown-emscripten --features std_web
13-
fi
14-
15-
cargo test --doc --features doc_test,wasm_test,yaml,msgpack,cbor,std_web
16-
cargo test --doc --features doc_test,wasm_test,yaml,msgpack,cbor,web_sys
12+
(cd yew-functional \
13+
&& cargo test --target wasm32-unknown-unknown)
1714

18-
(cd crates/macro \
15+
(cd yew-macro \
1916
&& cargo test --test macro_test \
2017
&& cargo test --test derive_props_test \
2118
&& cargo test --doc)
2219

23-
(cd crates/functional \
24-
&& cargo test --features wasm_test --target wasm32-unknown-unknown)
20+
(cd yew-stdweb && cargo test --target wasm32-unknown-unknown --features wasm_test)
21+
22+
# TODO - Emscripten builds are broken on rustc > 1.39.0
23+
if [ "$emscripten_supported" == "0" ]; then
24+
(cd yew-stdweb \
25+
&& cargo web test --target asmjs-unknown-emscripten \
26+
&& cargo web test --target wasm32-unknown-emscripten)
27+
fi

0 commit comments

Comments
 (0)