From dc1a145401377c4f7b61f62b24eda10bc4c1fbd7 Mon Sep 17 00:00:00 2001 From: StarArawn <toasterthegamer@gmail.com> Date: Mon, 13 Dec 2021 15:16:52 -0500 Subject: [PATCH] More cargo fixes.. --- Cargo.lock | 127 +++++++++--------- Cargo.toml | 4 +- bevy_kayak_ui/Cargo.toml | 1 - examples/bevy.rs | 7 +- examples/counter.rs | 11 +- examples/full_ui.rs | 9 +- examples/global_counter.rs | 8 +- examples/image.rs | 8 +- examples/nine_patch.rs | 9 +- kayak_core/Cargo.toml | 5 +- kayak_render_macros/Cargo.toml | 4 + kayak_render_macros/src/children.rs | 10 +- kayak_render_macros/src/function_component.rs | 32 +++-- kayak_render_macros/src/lib.rs | 7 +- kayak_render_macros/src/tags.rs | 9 +- kayak_render_macros/src/widget_attributes.rs | 11 +- kayak_widgets/Cargo.toml | 2 +- kayak_widgets/src/app.rs | 5 +- kayak_widgets/src/background.rs | 2 +- kayak_widgets/src/button.rs | 2 +- kayak_widgets/src/clip.rs | 2 +- kayak_widgets/src/image.rs | 2 +- kayak_widgets/src/nine_patch.rs | 2 +- kayak_widgets/src/text.rs | 2 +- kayak_widgets/src/window.rs | 2 +- src/lib.rs | 4 - 26 files changed, 159 insertions(+), 128 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0f06df8..dafabd1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -107,9 +107,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.47" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d9ff5d688f1c13395289f67db01d4826b46dd694e7580accdc3e8430f2d98e" +checksum = "8b26702f315f53b6071259e15dd9d64528213b44d61de1ec926eca7715d62203" [[package]] name = "approx" @@ -128,9 +128,9 @@ checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" [[package]] name = "as-any" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b564204d863976c470dbd0e41d1fcc351a8cd1b58222aaaae466f82c493fae4" +checksum = "088ccb346677e658e7ccd9627c62576fba881f4db7fab71fa9e21bf31c0aa4cb" [[package]] name = "ash" @@ -432,7 +432,6 @@ dependencies = [ "kayak_core", "kayak_font", "kayak_render_macros", - "kayak_widgets", "serde", "serde_json", "serde_path_to_error", @@ -778,7 +777,7 @@ dependencies = [ "bevy_app", "bevy_math", "bevy_utils", - "raw-window-handle", + "raw-window-handle 0.3.4", "web-sys", ] @@ -794,7 +793,7 @@ dependencies = [ "bevy_math", "bevy_utils", "bevy_window", - "raw-window-handle", + "raw-window-handle 0.3.4", "wasm-bindgen", "web-sys", "winit", @@ -1190,9 +1189,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" +checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" dependencies = [ "cfg-if 1.0.0", ] @@ -1286,6 +1285,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "cty" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" + [[package]] name = "d3d12" version = "0.4.1" @@ -1332,16 +1337,6 @@ dependencies = [ "syn", ] -[[package]] -name = "dashmap" -version = "4.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e77a43b28d0668df09411cb0bc9a8c2adc40f9a048afe863e05fd43251e8e39c" -dependencies = [ - "cfg-if 1.0.0", - "num_cpus", -] - [[package]] name = "deflate" version = "0.8.6" @@ -1697,9 +1692,9 @@ dependencies = [ [[package]] name = "glam" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2c626156a479bfb5a4362c43f5abadd700af33ebc8db068089d9cb92493d6ab" +checksum = "68270e16582ea40f9c5b2fcd588fbc9cb696577222e04a64d9085cc314806a8a" dependencies = [ "bytemuck", "mint", @@ -1994,7 +1989,6 @@ name = "kayak_core" version = "0.1.0" dependencies = [ "as-any", - "dashmap", "derivative", "diff-struct", "flo_binding", @@ -2037,6 +2031,7 @@ dependencies = [ "bevy_kayak_ui", "kayak_core", "kayak_font", + "kayak_render_macros", "kayak_widgets", ] @@ -2044,7 +2039,7 @@ dependencies = [ name = "kayak_widgets" version = "0.1.0" dependencies = [ - "kayak_core", + "kayak_ui", ] [[package]] @@ -2091,9 +2086,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.108" +version = "0.2.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8521a1b57e76b1ec69af7599e75e38e7b7fad6610f037db8c79b127201b5d119" +checksum = "8e167738f1866a7ec625567bae89ca0d44477232a4f7c52b1c7f2adc2c98804f" [[package]] name = "libloading" @@ -2183,9 +2178,9 @@ checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "memoffset" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" dependencies = [ "autocfg", ] @@ -2254,9 +2249,9 @@ dependencies = [ [[package]] name = "mio-misc" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ddf05411bb159cdb5801bb10002afb66cb4572be656044315e363460ce69dc2" +checksum = "b47412f3a52115b936ff2a229b803498c7b4d332adeb87c2f1498c9da54c398c" dependencies = [ "crossbeam", "crossbeam-queue", @@ -2276,7 +2271,7 @@ dependencies = [ [[package]] name = "morphorm" version = "0.2.0" -source = "git+https://github.com/geom3trik/morphorm#df4129d0e4fa390e92ede1a303aeeae71be5d3f4" +source = "git+https://github.com/geom3trik/morphorm#357bf5f0bd708bad1f4d8d4b76f02ebad9992dc3" dependencies = [ "bitflags", "smallvec", @@ -2284,9 +2279,9 @@ dependencies = [ [[package]] name = "naga" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eda66d09f712e1f0a6ab436137da4fac312f78301f6d4ac7cb8bfe96e988734f" +checksum = "63765d243f5d32ece09b2ff95c1f50ec7353266024a2ce89619a09e1b6aa4cce" dependencies = [ "bit-set", "bitflags", @@ -2562,7 +2557,7 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65ee3f72636e6f164cc41c9f9057f4e58c4e13507699ea7f5e5242b64b8198ee" dependencies = [ - "ttf-parser 0.13.3", + "ttf-parser 0.13.4", ] [[package]] @@ -2632,9 +2627,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.22" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12295df4f294471248581bc09bef3c38a5e46f1e36d6a37353621a0c6c357e1f" +checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" [[package]] name = "png" @@ -2718,9 +2713,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" +checksum = "fb37d2df5df740e582f28f8560cf425f52bb267d872fe58358eadb554909f07a" dependencies = [ "unicode-xid", ] @@ -2788,11 +2783,21 @@ checksum = "63e935c45e09cc6dcf00d2f0b2d630a58f4095320223d47fc68918722f0538b6" [[package]] name = "raw-window-handle" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a441a7a6c80ad6473bd4b74ec1c9a4c951794285bf941c2126f607c72e48211" +checksum = "e28f55143d0548dad60bb4fbdc835a3d7ac6acc3324506450c5fdd6e42903a76" dependencies = [ "libc", + "raw-window-handle 0.4.2", +] + +[[package]] +name = "raw-window-handle" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fba75eee94a9d5273a68c9e1e105d9cffe1ef700532325788389e5a83e2522b7" +dependencies = [ + "cty", ] [[package]] @@ -2902,9 +2907,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.5" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" [[package]] name = "same-file" @@ -2944,18 +2949,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.130" +version = "1.0.131" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" +checksum = "b4ad69dfbd3e45369132cc64e6748c2d65cdfb001a2b1c232d128b4ad60561c1" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.130" +version = "1.0.131" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" +checksum = "b710a83c4e0dff6a3d511946b95274ad9ca9e5d3ae497b63fda866ac955358d2" dependencies = [ "proc-macro2", "quote", @@ -2964,9 +2969,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.71" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063bf466a64011ac24040a49009724ee60a57da1b437617ceb32e53ad61bfb19" +checksum = "d0ffa0837f2dfa6fb90868c2b5468cad482e175f7dad97e7421951e663f2b527" dependencies = [ "itoa", "ryu", @@ -3173,9 +3178,9 @@ checksum = "8fb1df15f412ee2e9dfc1c504260fa695c1c3f10fe9f4a6ee2d2184d7d6450e2" [[package]] name = "syn" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2afee18b8beb5a596ecb4a2dce128c719b4ba399d34126b9e4396e3f9860966" +checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59" dependencies = [ "proc-macro2", "quote", @@ -3310,9 +3315,9 @@ checksum = "7ae2f58a822f08abdaf668897e96a5656fe72f5a9ce66422423e8849384872e6" [[package]] name = "ttf-parser" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47094e61a758dfddc5bc6de0862c2640ee2643997835e58332a4863bcd5852e9" +checksum = "76dacc724328b3d5e2ed67f9e30cdb56893a34ab239032502cc8f19f8dae4bbc" [[package]] name = "unicode-width" @@ -3449,16 +3454,16 @@ dependencies = [ [[package]] name = "wgpu" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1577ecc4f6992b9e965878ac594efb24eed2bdf089c11f45b3d1c5f216e2e30" +checksum = "eae7181fe6ba5f4b632a9079cc9e922a64555156c87def72c063f94b180c7d68" dependencies = [ "arrayvec", "js-sys", "log", "naga", "parking_lot", - "raw-window-handle", + "raw-window-handle 0.3.4", "smallvec", "wasm-bindgen", "wasm-bindgen-futures", @@ -3470,9 +3475,9 @@ dependencies = [ [[package]] name = "wgpu-core" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bdcbfa4885b32c2b1feb2faeb8b6a76065b752b8f08751b82f994e937687f46" +checksum = "35600627b6c718ad0e23ed75fb6140bfe32cdf21c8f539ce3c9ab8180e2cb38e" dependencies = [ "arrayvec", "bitflags", @@ -3483,7 +3488,7 @@ dependencies = [ "naga", "parking_lot", "profiling", - "raw-window-handle", + "raw-window-handle 0.3.4", "smallvec", "thiserror", "wgpu-hal", @@ -3492,9 +3497,9 @@ dependencies = [ [[package]] name = "wgpu-hal" -version = "0.11.4" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e493835d9edb153d5c8a9d8d016e1811dbe32ddb707a110be1453c7b051d3ec" +checksum = "af28b29ef0b44cd22dd9895d4349b9d5a687df42f58da234871198637eabe328" dependencies = [ "arrayvec", "ash", @@ -3519,7 +3524,7 @@ dependencies = [ "parking_lot", "profiling", "range-alloc", - "raw-window-handle", + "raw-window-handle 0.3.4", "renderdoc-sys", "thiserror", "wasm-bindgen", @@ -3592,7 +3597,7 @@ dependencies = [ "objc", "parking_lot", "percent-encoding", - "raw-window-handle", + "raw-window-handle 0.3.4", "scopeguard", "wasm-bindgen", "web-sys", diff --git a/Cargo.toml b/Cargo.toml index d8e4171..5b0957a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,12 +16,14 @@ members = [ [features] default = ["bevy_renderer"] bevy_renderer = ["bevy_kayak_ui", "kayak_font"] +internal = ["kayak_core/internal", "kayak_render_macros/internal"] [dependencies] -kayak_widgets = { path = "kayak_widgets" } kayak_core = { path = "kayak_core" } bevy_kayak_ui = { path = "bevy_kayak_ui", optional = true } kayak_font = { path = "kayak_font", optional = true } +kayak_render_macros = { path = "kayak_render_macros" } [dev-dependencies] bevy = { git = "https://github.com/bevyengine/bevy", rev = "38c7d5eb9e81ab8e1aec03673599b25a9aa0c69c" } +kayak_widgets = { path = "kayak_widgets" } diff --git a/bevy_kayak_ui/Cargo.toml b/bevy_kayak_ui/Cargo.toml index 0337af0..113f74e 100644 --- a/bevy_kayak_ui/Cargo.toml +++ b/bevy_kayak_ui/Cargo.toml @@ -7,7 +7,6 @@ edition = "2021" bytemuck = "1.7.2" bevy = { git = "https://github.com/bevyengine/bevy", rev = "38c7d5eb9e81ab8e1aec03673599b25a9aa0c69c" } kayak_core = { path = "../kayak_core" } -kayak_widgets = { path = "../kayak_widgets" } kayak_render_macros = { path = "../kayak_render_macros" } kayak_font = { path = "../kayak_font" } #kayak_font = { path = "../kayak_font" } diff --git a/examples/bevy.rs b/examples/bevy.rs index 7025169..10aee13 100644 --- a/examples/bevy.rs +++ b/examples/bevy.rs @@ -4,11 +4,10 @@ use bevy::{ window::{WindowDescriptor, Windows}, PipelinedDefaultPlugins, }; -use bevy_kayak_ui::{BevyContext, BevyKayakUIPlugin, FontMapping, UICameraBundle}; -use kayak_core::Index; +use kayak_ui::bevy::{BevyContext, BevyKayakUIPlugin, FontMapping, UICameraBundle}; +use kayak_ui::core::Index; use kayak_ui::core::{rsx, widget}; -use kayak_ui::widgets::App; -use kayak_widgets::Window; +use kayak_widgets::{App, Window}; #[widget] fn TestState() { diff --git a/examples/counter.rs b/examples/counter.rs index fd9ae01..d8017eb 100644 --- a/examples/counter.rs +++ b/examples/counter.rs @@ -4,14 +4,13 @@ use bevy::{ window::{WindowDescriptor, Windows}, PipelinedDefaultPlugins, }; -use bevy_kayak_ui::{BevyContext, BevyKayakUIPlugin, FontMapping, UICameraBundle}; -use kayak_core::{ +use kayak_ui::bevy::{BevyContext, BevyKayakUIPlugin, FontMapping, ImageManager, UICameraBundle}; +use kayak_ui::core::{ + rsx, styles::{Style, StyleProp, Units}, - Bound, EventType, Index, MutableBound, OnEvent, + widget, Bound, EventType, Index, MutableBound, OnEvent, }; -use kayak_ui::core::{rsx, widget}; -use kayak_ui::widgets::App; -use kayak_widgets::{Button, Text, Window}; +use kayak_widgets::{App, Button, Text, Window}; #[widget] fn Counter(context: &mut KayakContext) { diff --git a/examples/full_ui.rs b/examples/full_ui.rs index ea4a11e..b2e804f 100644 --- a/examples/full_ui.rs +++ b/examples/full_ui.rs @@ -4,15 +4,14 @@ use bevy::{ window::{WindowDescriptor, Windows}, PipelinedDefaultPlugins, }; -use bevy_kayak_ui::{BevyContext, BevyKayakUIPlugin, FontMapping, ImageManager, UICameraBundle}; -use kayak_core::{ +use kayak_ui::bevy::{BevyContext, BevyKayakUIPlugin, FontMapping, ImageManager, UICameraBundle}; +use kayak_ui::core::{ layout_cache::Space, + rsx, styles::{LayoutType, Style, StyleProp, Units}, widget, Bound, Children, EventType, Index, MutableBound, OnEvent, }; -use kayak_ui::core::rsx; -use kayak_ui::widgets::App; -use kayak_widgets::{NinePatch, Text}; +use kayak_widgets::{App, NinePatch, Text}; #[widget] fn BlueButton(context: KayakContext, children: Children, styles: Option<Style>) { diff --git a/examples/global_counter.rs b/examples/global_counter.rs index 8f14532..17b1ac8 100644 --- a/examples/global_counter.rs +++ b/examples/global_counter.rs @@ -4,11 +4,9 @@ use bevy::{ window::{WindowDescriptor, Windows}, PipelinedDefaultPlugins, }; -use bevy_kayak_ui::{BevyContext, BevyKayakUIPlugin, FontMapping, UICameraBundle}; -use kayak_core::{bind, Binding, Bound, Index, MutableBound}; -use kayak_ui::core::{rsx, widget}; -use kayak_ui::widgets::App; -use kayak_widgets::{Text, Window}; +use kayak_ui::bevy::{BevyContext, BevyKayakUIPlugin, FontMapping, UICameraBundle}; +use kayak_ui::core::{bind, rsx, widget, Binding, Bound, Index, MutableBound}; +use kayak_widgets::{App, Text, Window}; #[derive(Clone, PartialEq)] struct GlobalCount(pub u32); diff --git a/examples/image.rs b/examples/image.rs index 39388f4..e2e95ef 100644 --- a/examples/image.rs +++ b/examples/image.rs @@ -4,11 +4,9 @@ use bevy::{ window::{WindowDescriptor, Windows}, PipelinedDefaultPlugins, }; -use bevy_kayak_ui::{BevyContext, BevyKayakUIPlugin, ImageManager, UICameraBundle}; -use kayak_core::Index; -use kayak_ui::core::rsx; -use kayak_ui::widgets::App; -use kayak_widgets::Image; +use kayak_ui::bevy::{BevyContext, BevyKayakUIPlugin, ImageManager, UICameraBundle}; +use kayak_ui::core::{rsx, Index}; +use kayak_widgets::{App, Image}; fn startup( mut commands: Commands, diff --git a/examples/nine_patch.rs b/examples/nine_patch.rs index 202a891..016c438 100644 --- a/examples/nine_patch.rs +++ b/examples/nine_patch.rs @@ -4,15 +4,14 @@ use bevy::{ window::{WindowDescriptor, Windows}, PipelinedDefaultPlugins, }; -use bevy_kayak_ui::{BevyContext, BevyKayakUIPlugin, ImageManager, UICameraBundle}; -use kayak_core::{ +use kayak_ui::bevy::{BevyContext, BevyKayakUIPlugin, ImageManager, UICameraBundle}; +use kayak_ui::core::{ layout_cache::Space, + rsx, styles::{Style, StyleProp, Units}, Index, }; -use kayak_ui::core::rsx; -use kayak_ui::widgets::App; -use kayak_widgets::NinePatch; +use kayak_widgets::{App, NinePatch}; fn startup( mut commands: Commands, diff --git a/kayak_core/Cargo.toml b/kayak_core/Cargo.toml index ff68615..321ebd7 100644 --- a/kayak_core/Cargo.toml +++ b/kayak_core/Cargo.toml @@ -5,9 +5,12 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[features] +default = [] +internal = ["kayak_render_macros/internal"] + [dependencies] as-any = "0.2" -dashmap = "4.0" diff-struct = "0.3" derivative = "2.2" flo_binding = { git = "https://github.com/StarArawn/flo_binding.git", rev = "c78431a56df5ec082b7e1c271871e6c0ac75e81e" } diff --git a/kayak_render_macros/Cargo.toml b/kayak_render_macros/Cargo.toml index 8707f9a..b8539a0 100644 --- a/kayak_render_macros/Cargo.toml +++ b/kayak_render_macros/Cargo.toml @@ -6,6 +6,10 @@ edition = "2021" [lib] proc-macro = true +[features] +default = [] +internal = [] + [dependencies] syn = { version = "1.0", features = ["full"] } quote = "1.0" diff --git a/kayak_render_macros/src/children.rs b/kayak_render_macros/src/children.rs index 7849982..2935b19 100644 --- a/kayak_render_macros/src/children.rs +++ b/kayak_render_macros/src/children.rs @@ -52,6 +52,11 @@ impl Children { } pub fn as_option_of_tuples_tokens(&self) -> proc_macro2::TokenStream { + #[cfg(feature = "internal")] + let kayak_core = quote! { kayak_core }; + #[cfg(not(feature = "internal"))] + let kayak_core = quote! { kayak_ui::core }; + let children_quotes: Vec<_> = self .nodes .iter() @@ -82,8 +87,9 @@ impl Children { true, 0, ); + quote! { - Some(std::sync::Arc::new(move |parent_id: Option<kayak_core::Index>, context: &mut kayak_core::context::KayakContext| { + Some(std::sync::Arc::new(move |parent_id: Option<#kayak_core::Index>, context: &mut #kayak_core::context::KayakContext| { #cloned_attrs #children_builder })) @@ -184,7 +190,7 @@ impl Children { // ); quote! { - Some(std::sync::Arc::new(move |parent_id: Option<kayak_core::Index>, context: &mut kayak_core::context::KayakContext| { + Some(std::sync::Arc::new(move |parent_id: Option<#kayak_core::Index>, context: &mut #kayak_core::context::KayakContext| { #(#output)* })) } diff --git a/kayak_render_macros/src/function_component.rs b/kayak_render_macros/src/function_component.rs index 84af347..60e741c 100644 --- a/kayak_render_macros/src/function_component.rs +++ b/kayak_render_macros/src/function_component.rs @@ -10,6 +10,11 @@ pub fn create_function_widget(f: syn::ItemFn) -> TokenStream { let block = f.block; let vis = f.vis; + #[cfg(feature = "internal")] + let kayak_core = quote! { kayak_core }; + #[cfg(not(feature = "internal"))] + let kayak_core = quote! { kayak_ui::core }; + let mut input_names: Vec<_> = inputs .iter() .filter_map(|argument| match argument { @@ -65,21 +70,24 @@ pub fn create_function_widget(f: syn::ItemFn) -> TokenStream { "styles : Option< kayak_core :: styles :: Style >", ], quote! { - pub styles: Option<kayak_core::styles::Style> + pub styles: Option<#kayak_core::styles::Style> }, ), ( vec!["children : Children"], quote! { #[derivative(Debug = "ignore", PartialEq = "ignore")] - pub children: kayak_core::Children + pub children: #kayak_core::Children }, ), ( - vec!["on_event : Option<kayak_core::OnEvent>"], + vec![ + "on_event: Option<OnEvent>", + "on_event : Option<kayak_core::OnEvent>", + ], quote! { #[derivative(Debug = "ignore", PartialEq = "ignore")] - pub on_event: Option<kayak_core::OnEvent> + pub on_event: Option<#kayak_core::OnEvent> }, ), ]; @@ -119,25 +127,25 @@ pub fn create_function_widget(f: syn::ItemFn) -> TokenStream { }; TokenStream::from(quote! { - use kayak_core::derivative::*; + use #kayak_core::derivative::*; #[derive(Derivative)] #[derivative(Debug, PartialEq)] #vis struct #struct_name #impl_generics { - pub id: ::kayak_core::Index, + pub id: #kayak_core::Index, #inputs_block } - impl #impl_generics ::kayak_core::Widget for #struct_name #ty_generics #where_clause { - fn get_id(&self) -> ::kayak_core::Index { + impl #impl_generics #kayak_core::Widget for #struct_name #ty_generics #where_clause { + fn get_id(&self) -> #kayak_core::Index { self.id } - fn set_id(&mut self, id: ::kayak_core::Index) { + fn set_id(&mut self, id: #kayak_core::Index) { self.id = id; } - fn get_styles(&self) -> Option<::kayak_core::styles::Style> { + fn get_styles(&self) -> Option<#kayak_core::styles::Style> { self.styles.clone() } @@ -145,7 +153,7 @@ pub fn create_function_widget(f: syn::ItemFn) -> TokenStream { String::from(stringify!(#struct_name)) } - fn on_event(&mut self, context: &mut ::kayak_core::context::KayakContext, event: &mut ::kayak_core::Event) { + fn on_event(&mut self, context: &mut #kayak_core::context::KayakContext, event: &mut #kayak_core::Event) { if let Some(on_event) = self.on_event.as_ref() { if let Ok(mut on_event) = on_event.0.write() { on_event(context, event); @@ -153,7 +161,7 @@ pub fn create_function_widget(f: syn::ItemFn) -> TokenStream { } } - fn render(&mut self, context: &mut ::kayak_core::context::KayakContext) { + fn render(&mut self, context: &mut #kayak_core::context::KayakContext) { let parent_id = self.get_id(); context.set_current_id(parent_id); let parent_id = Some(parent_id); diff --git a/kayak_render_macros/src/lib.rs b/kayak_render_macros/src/lib.rs index 0ad5adb..f89a618 100644 --- a/kayak_render_macros/src/lib.rs +++ b/kayak_render_macros/src/lib.rs @@ -32,7 +32,12 @@ pub fn render(input: TokenStream) -> TokenStream { input.map(|token_tree| proc_macro2::TokenStream::from(TokenStream::from(token_tree))), ); let el = proc_macro2::TokenStream::from(rsx(TokenStream::from(rsx_data))); - let result = quote! { ::kayak_core::Render::render_into(&#el, #context, None) }; + #[cfg(feature = "internal")] + let kayak_core = quote! { kayak_core }; + #[cfg(not(feature = "internal"))] + let kayak_core = quote! { kayak_ui::core }; + + let result = quote! { #kayak_core::Render::render_into(&#el, #context, None) }; TokenStream::from(result) } diff --git a/kayak_render_macros/src/tags.rs b/kayak_render_macros/src/tags.rs index fffe931..0448e81 100644 --- a/kayak_render_macros/src/tags.rs +++ b/kayak_render_macros/src/tags.rs @@ -12,7 +12,14 @@ pub struct OpenTag { } fn name_or_fragment(maybe_name: Result<syn::Path>) -> syn::Path { - maybe_name.unwrap_or_else(|_| syn::parse_str::<syn::Path>("::kayak_core::Fragment").unwrap()) + #[cfg(feature = "internal")] + let kayak_core = "kayak_core"; + #[cfg(not(feature = "internal"))] + let kayak_core = "kayak_ui::core"; + + maybe_name.unwrap_or_else(|_| { + syn::parse_str::<syn::Path>(&format!("::{}::Fragment", kayak_core)).unwrap() + }) } fn is_custom_element_name(path: &syn::Path) -> bool { diff --git a/kayak_render_macros/src/widget_attributes.rs b/kayak_render_macros/src/widget_attributes.rs index 020f54a..d204fc8 100644 --- a/kayak_render_macros/src/widget_attributes.rs +++ b/kayak_render_macros/src/widget_attributes.rs @@ -107,17 +107,22 @@ impl<'a, 'c> ToTokens for CustomWidgetAttributes<'a, 'c> { } } + #[cfg(feature = "internal")] + let kayak_core = quote! { kayak_core }; + #[cfg(not(feature = "internal"))] + let kayak_core = quote! { kayak_ui::core }; + let quoted = if attrs.len() == 0 { - quote!({ id: kayak_core::Index::default(), styles: None, children: None, on_event: None, }) + quote!({ id: #kayak_core::Index::default(), styles: None, children: None, on_event: None, }) } else { if !self .attributes .iter() .any(|attribute| attribute.ident().to_token_stream().to_string() == "styles") { - quote!({ #(#attrs),*, id: kayak_core::Index::default() }) + quote!({ #(#attrs),*, id: #kayak_core::Index::default() }) } else { - quote!({ #(#attrs),*, id: kayak_core::Index::default() }) + quote!({ #(#attrs),*, id: #kayak_core::Index::default() }) } }; diff --git a/kayak_widgets/Cargo.toml b/kayak_widgets/Cargo.toml index 04a5ec4..1f4158e 100644 --- a/kayak_widgets/Cargo.toml +++ b/kayak_widgets/Cargo.toml @@ -5,4 +5,4 @@ edition = "2021" resolver = "2" [dependencies] -kayak_core = { path = "../kayak_core", version = "0.1.0" } +kayak_ui = { path = "../", version = "0.1.0" } diff --git a/kayak_widgets/src/app.rs b/kayak_widgets/src/app.rs index 31167ba..5cba4c6 100644 --- a/kayak_widgets/src/app.rs +++ b/kayak_widgets/src/app.rs @@ -1,6 +1,5 @@ -use kayak_core::{rsx, widget, Children}; - -use kayak_core::derivative::*; +use kayak_ui::core::{rsx, widget, Children}; +use kayak_ui::core::derivative::*; #[widget] pub fn App(children: Children) { diff --git a/kayak_widgets/src/background.rs b/kayak_widgets/src/background.rs index bd1ad1f..f084ec1 100644 --- a/kayak_widgets/src/background.rs +++ b/kayak_widgets/src/background.rs @@ -1,4 +1,4 @@ -use kayak_core::{ +use kayak_ui::core::{ render_command::RenderCommand, rsx, styles::{Style, StyleProp}, diff --git a/kayak_widgets/src/button.rs b/kayak_widgets/src/button.rs index 9ca7e9b..efd31db 100644 --- a/kayak_widgets/src/button.rs +++ b/kayak_widgets/src/button.rs @@ -1,4 +1,4 @@ -use kayak_core::{ +use kayak_ui::core::{ color::Color, render_command::RenderCommand, rsx, diff --git a/kayak_widgets/src/clip.rs b/kayak_widgets/src/clip.rs index d5883f6..86cbb64 100644 --- a/kayak_widgets/src/clip.rs +++ b/kayak_widgets/src/clip.rs @@ -1,4 +1,4 @@ -use kayak_core::{ +use kayak_ui::core::{ render_command::RenderCommand, rsx, styles::{Style, StyleProp}, diff --git a/kayak_widgets/src/image.rs b/kayak_widgets/src/image.rs index 39cd65c..8e2d2f5 100644 --- a/kayak_widgets/src/image.rs +++ b/kayak_widgets/src/image.rs @@ -1,4 +1,4 @@ -use kayak_core::{ +use kayak_ui::core::{ render_command::RenderCommand, rsx, styles::{Style, StyleProp}, diff --git a/kayak_widgets/src/nine_patch.rs b/kayak_widgets/src/nine_patch.rs index 8d652ab..c31f774 100644 --- a/kayak_widgets/src/nine_patch.rs +++ b/kayak_widgets/src/nine_patch.rs @@ -1,4 +1,4 @@ -use kayak_core::{ +use kayak_ui::core::{ layout_cache::Space, render_command::RenderCommand, rsx, diff --git a/kayak_widgets/src/text.rs b/kayak_widgets/src/text.rs index 8fd1a98..ad2c919 100644 --- a/kayak_widgets/src/text.rs +++ b/kayak_widgets/src/text.rs @@ -1,4 +1,4 @@ -use kayak_core::{ +use kayak_ui::core::{ render_command::RenderCommand, rsx, styles::{Style, StyleProp}, diff --git a/kayak_widgets/src/window.rs b/kayak_widgets/src/window.rs index 6f77956..e403916 100644 --- a/kayak_widgets/src/window.rs +++ b/kayak_widgets/src/window.rs @@ -1,4 +1,4 @@ -use kayak_core::{ +use kayak_ui::core::{ color::Color, render_command::RenderCommand, rsx, diff --git a/src/lib.rs b/src/lib.rs index 3a4a2c3..c9e0965 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,3 @@ -pub mod widgets { - pub use kayak_widgets::*; -} - pub mod core { pub use kayak_core::*; } -- GitLab