Initial skeleton for a wasm ui crate.

This commit is contained in:
Jeremy Wall 2022-01-13 18:07:01 -05:00
parent 7194fa583d
commit 364f3a3d80
9 changed files with 192 additions and 36 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
target/ target/
.lsp/ .lsp/
.clj-kondo/ .clj-kondo/
web/dist/

128
Cargo.lock generated
View File

@ -51,6 +51,12 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "anyhow"
version = "1.0.52"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84450d0b4a8bd1ba4144ce8ce718fbc5d071358b1e5384bace6536b3d1f2d5b3"
[[package]] [[package]]
name = "async-channel" name = "async-channel"
version = "1.6.1" version = "1.6.1"
@ -298,6 +304,16 @@ dependencies = [
"cache-padded", "cache-padded",
] ]
[[package]]
name = "console_error_panic_hook"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc"
dependencies = [
"cfg-if",
"wasm-bindgen",
]
[[package]] [[package]]
name = "crossbeam-utils" name = "crossbeam-utils"
version = "0.8.6" version = "0.8.6"
@ -350,7 +366,7 @@ dependencies = [
"dioxus-core-macro", "dioxus-core-macro",
"dioxus-hooks", "dioxus-hooks",
"dioxus-html", "dioxus-html",
"dioxus-ssr", "dioxus-web",
] ]
[[package]] [[package]]
@ -368,7 +384,6 @@ dependencies = [
"log", "log",
"longest-increasing-subsequence", "longest-increasing-subsequence",
"once_cell", "once_cell",
"serde",
"slab", "slab",
"smallvec", "smallvec",
] ]
@ -405,12 +420,29 @@ dependencies = [
] ]
[[package]] [[package]]
name = "dioxus-ssr" name = "dioxus-web"
version = "0.1.2" version = "0.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f3144a01059134a72fe34a7fe2e91268f2a0fd3876024de5b02d2aab1daacf0" checksum = "8fb8c48f6a6d0de23eb39436387ebb6ecff86d12a3b439e559151d30d419899c"
dependencies = [ dependencies = [
"anyhow",
"async-channel",
"console_error_panic_hook",
"dioxus-core", "dioxus-core",
"dioxus-html",
"futures-util",
"fxhash",
"gloo-timers",
"js-sys",
"lazy_static",
"log",
"once_cell",
"smallstr",
"wasm-bindgen",
"wasm-bindgen-futures",
"wasm-bindgen-test",
"wasm-logger",
"web-sys",
] ]
[[package]] [[package]]
@ -464,6 +496,17 @@ dependencies = [
"waker-fn", "waker-fn",
] ]
[[package]]
name = "futures-macro"
version = "0.3.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6dbd947adfffb0efc70599b3ddcf7b5597bb5fa9e245eb99f62b3a5f7bb8bd3c"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "futures-task" name = "futures-task"
version = "0.3.19" version = "0.3.19"
@ -477,9 +520,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b5cf40b47a271f77a8b1bec03ca09044d99d2372c0de244e66430761127164" checksum = "d9b5cf40b47a271f77a8b1bec03ca09044d99d2372c0de244e66430761127164"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"futures-macro",
"futures-task", "futures-task",
"pin-project-lite", "pin-project-lite",
"pin-utils", "pin-utils",
"slab",
] ]
[[package]] [[package]]
@ -566,7 +611,6 @@ dependencies = [
"async-std", "async-std",
"clap", "clap",
"csv", "csv",
"dioxus",
"recipes", "recipes",
] ]
@ -805,25 +849,17 @@ version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
[[package]]
name = "scoped-tls"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.130" version = "1.0.130"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.130"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "slab" name = "slab"
@ -831,6 +867,15 @@ version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5"
[[package]]
name = "smallstr"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e922794d168678729ffc7e07182721a14219c65814e66e91b839a272fe5ae4f"
dependencies = [
"smallvec",
]
[[package]] [[package]]
name = "smallvec" name = "smallvec"
version = "1.7.0" version = "1.7.0"
@ -996,6 +1041,49 @@ version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc"
[[package]]
name = "wasm-bindgen-test"
version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96f1aa7971fdf61ef0f353602102dbea75a56e225ed036c1e3740564b91e6b7e"
dependencies = [
"console_error_panic_hook",
"js-sys",
"scoped-tls",
"wasm-bindgen",
"wasm-bindgen-futures",
"wasm-bindgen-test-macro",
]
[[package]]
name = "wasm-bindgen-test-macro"
version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6006f79628dfeb96a86d4db51fbf1344cd7fd8408f06fc9aa3c84913a4789688"
dependencies = [
"proc-macro2",
"quote",
]
[[package]]
name = "wasm-logger"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "074649a66bb306c8f2068c9016395fa65d8e08d2affcbf95acf3c24c3ab19718"
dependencies = [
"log",
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "web"
version = "0.1.0"
dependencies = [
"dioxus",
"recipes",
]
[[package]] [[package]]
name = "web-sys" name = "web-sys"
version = "0.3.55" version = "0.3.55"

View File

@ -1,2 +1,2 @@
[workspace] [workspace]
members = [ "recipes", "kitchen" ] members = [ "recipes", "kitchen", "web" ]

View File

@ -13,7 +13,3 @@ async-std = "1.10.0"
[dependencies.clap] [dependencies.clap]
version = "2.33.4" version = "2.33.4"
[dependencies.dioxus]
version = "0.1.7"
features = [ "ssr" ]

View File

@ -11,15 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
use dioxus::prelude::*;
pub fn ui(cx: Scope) -> Element {
cx.render(rsx! {
div { "hello chefs!" }
})
}
pub async fn ui_main() { pub async fn ui_main() {
let dom = VirtualDom::new(ui); panic!("Not implemented yet");
dbg!(dioxus::ssr::render_vdom(&dom));
} }

13
web/Cargo.toml Normal file
View File

@ -0,0 +1,13 @@
[package]
name = "web"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
recipes = {path = "../recipes" }
[dependencies.dioxus]
version = "0.1.7"
features = [ "web" ]

28
web/index.html Normal file
View File

@ -0,0 +1,28 @@
<!--
Copyright 2022 Jeremy Wall
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" name="viewport"
content="width=device-width, initial-scale=1.0" charset="UTF-8">
</head>
<body>
<div id="main"> </div>
</body>
</html>

18
web/src/main.rs Normal file
View File

@ -0,0 +1,18 @@
// Copyright 2022 Jeremy Wall
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
mod web;
fn main() {
dioxus::web::launch(web::ui);
}

20
web/src/web.rs Normal file
View File

@ -0,0 +1,20 @@
// Copyright 2022 Jeremy Wall
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use dioxus::prelude::*;
pub fn ui(cx: Scope) -> Element {
cx.render(rsx! {
div { "hello chefs!" }
})
}