From 364f3a3d80f2bf3d538bc54734c71633e7067819 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Thu, 13 Jan 2022 18:07:01 -0500 Subject: [PATCH] Initial skeleton for a wasm ui crate. --- .gitignore | 3 +- Cargo.lock | 128 ++++++++++++++++++++++++++++++++++++++------- Cargo.toml | 2 +- kitchen/Cargo.toml | 6 +-- kitchen/src/web.rs | 10 +--- web/Cargo.toml | 13 +++++ web/index.html | 28 ++++++++++ web/src/main.rs | 18 +++++++ web/src/web.rs | 20 +++++++ 9 files changed, 192 insertions(+), 36 deletions(-) create mode 100644 web/Cargo.toml create mode 100644 web/index.html create mode 100644 web/src/main.rs create mode 100644 web/src/web.rs diff --git a/.gitignore b/.gitignore index bea51c7..ebebcb8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ target/ .lsp/ -.clj-kondo/ \ No newline at end of file +.clj-kondo/ +web/dist/ \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 6fd8f93..ae81e62 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -51,6 +51,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "anyhow" +version = "1.0.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84450d0b4a8bd1ba4144ce8ce718fbc5d071358b1e5384bace6536b3d1f2d5b3" + [[package]] name = "async-channel" version = "1.6.1" @@ -298,6 +304,16 @@ dependencies = [ "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]] name = "crossbeam-utils" version = "0.8.6" @@ -350,7 +366,7 @@ dependencies = [ "dioxus-core-macro", "dioxus-hooks", "dioxus-html", - "dioxus-ssr", + "dioxus-web", ] [[package]] @@ -368,7 +384,6 @@ dependencies = [ "log", "longest-increasing-subsequence", "once_cell", - "serde", "slab", "smallvec", ] @@ -405,12 +420,29 @@ dependencies = [ ] [[package]] -name = "dioxus-ssr" -version = "0.1.2" +name = "dioxus-web" +version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f3144a01059134a72fe34a7fe2e91268f2a0fd3876024de5b02d2aab1daacf0" +checksum = "8fb8c48f6a6d0de23eb39436387ebb6ecff86d12a3b439e559151d30d419899c" dependencies = [ + "anyhow", + "async-channel", + "console_error_panic_hook", "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]] @@ -464,6 +496,17 @@ dependencies = [ "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]] name = "futures-task" version = "0.3.19" @@ -477,9 +520,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b5cf40b47a271f77a8b1bec03ca09044d99d2372c0de244e66430761127164" dependencies = [ "futures-core", + "futures-macro", "futures-task", "pin-project-lite", "pin-utils", + "slab", ] [[package]] @@ -566,7 +611,6 @@ dependencies = [ "async-std", "clap", "csv", - "dioxus", "recipes", ] @@ -805,25 +849,17 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +[[package]] +name = "scoped-tls" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" + [[package]] name = "serde" version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "slab" @@ -831,6 +867,15 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" +[[package]] +name = "smallstr" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e922794d168678729ffc7e07182721a14219c65814e66e91b839a272fe5ae4f" +dependencies = [ + "smallvec", +] + [[package]] name = "smallvec" version = "1.7.0" @@ -996,6 +1041,49 @@ version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "web-sys" version = "0.3.55" diff --git a/Cargo.toml b/Cargo.toml index c1c48ec..2c20466 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,2 +1,2 @@ [workspace] -members = [ "recipes", "kitchen" ] \ No newline at end of file +members = [ "recipes", "kitchen", "web" ] \ No newline at end of file diff --git a/kitchen/Cargo.toml b/kitchen/Cargo.toml index 5d3c7e9..34f2fe2 100644 --- a/kitchen/Cargo.toml +++ b/kitchen/Cargo.toml @@ -12,8 +12,4 @@ csv = "1.1.1" async-std = "1.10.0" [dependencies.clap] -version = "2.33.4" - -[dependencies.dioxus] -version = "0.1.7" -features = [ "ssr" ] \ No newline at end of file +version = "2.33.4" \ No newline at end of file diff --git a/kitchen/src/web.rs b/kitchen/src/web.rs index 39a8099..01f1a8a 100644 --- a/kitchen/src/web.rs +++ b/kitchen/src/web.rs @@ -11,15 +11,7 @@ // 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!" } - }) -} pub async fn ui_main() { - let dom = VirtualDom::new(ui); - dbg!(dioxus::ssr::render_vdom(&dom)); + panic!("Not implemented yet"); } diff --git a/web/Cargo.toml b/web/Cargo.toml new file mode 100644 index 0000000..345400f --- /dev/null +++ b/web/Cargo.toml @@ -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" ] diff --git a/web/index.html b/web/index.html new file mode 100644 index 0000000..2ce89d6 --- /dev/null +++ b/web/index.html @@ -0,0 +1,28 @@ + + + + + + + + + +
+ + + \ No newline at end of file diff --git a/web/src/main.rs b/web/src/main.rs new file mode 100644 index 0000000..121e407 --- /dev/null +++ b/web/src/main.rs @@ -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); +} diff --git a/web/src/web.rs b/web/src/web.rs new file mode 100644 index 0000000..449f17c --- /dev/null +++ b/web/src/web.rs @@ -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!" } + }) +} \ No newline at end of file