Implement hot reloading

This commit is contained in:
JMS55 2023-12-21 00:45:28 -08:00
parent 4fb0f30862
commit 89dfe9ebc1
5 changed files with 751 additions and 3 deletions

607
Cargo.lock generated
View File

@ -86,6 +86,17 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "ahash"
version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd"
dependencies = [
"getrandom",
"once_cell",
"version_check",
]
[[package]]
name = "ahash"
version = "0.8.6"
@ -160,6 +171,12 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04"
[[package]]
name = "android-tzdata"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
[[package]]
name = "android_log-sys"
version = "0.3.1"
@ -291,6 +308,17 @@ version = "4.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4eb2cdb97421e01129ccb49169d8279ed21e829929144f4a22a6e54ac549ca1"
[[package]]
name = "async-trait"
version = "0.1.75"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdf6721fb0140e4f897002dd086c06f6c27775df19cfe1fccb21181a48fd2c98"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.41",
]
[[package]]
name = "atomic-waker"
version = "1.1.2"
@ -518,6 +546,8 @@ dependencies = [
"bevy",
"bevy_mod_picking",
"dioxus",
"dioxus-hot-reload",
"dioxus-rsx",
]
[[package]]
@ -1105,7 +1135,7 @@ name = "bevy_utils"
version = "0.12.0"
source = "git+https://github.com/JMS55/bevy?branch=query_new_12#2dc833144dffd98bf4633fb206f2c30e7f92bdb6"
dependencies = [
"ahash",
"ahash 0.8.6",
"bevy_utils_proc_macros",
"getrandom",
"hashbrown 0.14.3",
@ -1270,6 +1300,16 @@ dependencies = [
"tracing",
]
[[package]]
name = "bstr"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "542f33a8835a0884b006a0c3df3dadd99c0c3f296ed26c2fdc8028e01ad6230c"
dependencies = [
"memchr",
"serde",
]
[[package]]
name = "bumpalo"
version = "3.14.0"
@ -1308,6 +1348,38 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223"
[[package]]
name = "camino"
version = "1.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c"
dependencies = [
"serde",
]
[[package]]
name = "cargo-platform"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e34637b3140142bdf929fb439e8aa4ebad7651ebf7b1080b3930aa16ac1459ff"
dependencies = [
"serde",
]
[[package]]
name = "cargo_metadata"
version = "0.15.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a"
dependencies = [
"camino",
"cargo-platform",
"semver",
"serde",
"serde_json",
"thiserror",
]
[[package]]
name = "cc"
version = "1.0.83"
@ -1333,6 +1405,15 @@ dependencies = [
"nom",
]
[[package]]
name = "cfg-expr"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bbc13bf6290a6b202cc3efb36f7ec2b739a80634215630c8053a313edf6abef"
dependencies = [
"smallvec",
]
[[package]]
name = "cfg-if"
version = "1.0.0"
@ -1345,6 +1426,18 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
[[package]]
name = "chrono"
version = "0.4.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38"
dependencies = [
"android-tzdata",
"iana-time-zone",
"num-traits",
"windows-targets 0.48.5",
]
[[package]]
name = "clang-sys"
version = "1.6.1"
@ -1544,6 +1637,30 @@ dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-deque"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef"
dependencies = [
"cfg-if",
"crossbeam-epoch",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-epoch"
version = "0.9.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7"
dependencies = [
"autocfg",
"cfg-if",
"crossbeam-utils",
"memoffset",
"scopeguard",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.16"
@ -1564,6 +1681,40 @@ dependencies = [
"winapi",
]
[[package]]
name = "darling"
version = "0.20.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e"
dependencies = [
"darling_core",
"darling_macro",
]
[[package]]
name = "darling_core"
version = "0.20.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621"
dependencies = [
"fnv",
"ident_case",
"proc-macro2",
"quote",
"syn 2.0.41",
]
[[package]]
name = "darling_macro"
version = "0.20.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5"
dependencies = [
"darling_core",
"quote",
"syn 2.0.41",
]
[[package]]
name = "dasp_sample"
version = "0.11.0"
@ -1585,6 +1736,7 @@ dependencies = [
"dioxus-core",
"dioxus-core-macro",
"dioxus-hooks",
"dioxus-hot-reload",
"dioxus-rsx",
]
@ -1599,6 +1751,7 @@ dependencies = [
"futures-util",
"longest-increasing-subsequence",
"rustc-hash",
"serde",
"slab",
"smallbox",
"tracing",
@ -1639,6 +1792,44 @@ dependencies = [
"tracing",
]
[[package]]
name = "dioxus-hot-reload"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7d8c9e89e866a6b84b8ad696f0ff2f6f6563d2235eb99acc6952f19e516cc09"
dependencies = [
"chrono",
"dioxus-core",
"dioxus-html",
"dioxus-rsx",
"execute",
"ignore",
"interprocess-docfix",
"notify",
"once_cell",
"serde",
"serde_json",
]
[[package]]
name = "dioxus-html"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "828a42a2d70688a2412a8538c8b5a5eceadf68f682f899dc4455a0169db39dfd"
dependencies = [
"async-channel 1.9.0",
"async-trait",
"dioxus-core",
"enumset",
"euclid",
"keyboard-types",
"serde",
"serde-value",
"serde_json",
"serde_repr",
"web-sys",
]
[[package]]
name = "dioxus-rsx"
version = "0.4.3"
@ -1646,6 +1837,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c974133c7c95497a486d587e40449927711430b308134b9cd374b8d35eceafb3"
dependencies = [
"dioxus-core",
"internment",
"krates",
"proc-macro2",
"quote",
"syn 2.0.41",
@ -1695,6 +1888,27 @@ dependencies = [
"syn 2.0.41",
]
[[package]]
name = "enumset"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "226c0da7462c13fb57e5cc9e0dc8f0635e7d27f276a3a7fd30054647f669007d"
dependencies = [
"enumset_derive",
]
[[package]]
name = "enumset_derive"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e08b6c6ab82d70f08844964ba10c7babb716de2ecaeab9be5717918a5177d3af"
dependencies = [
"darling",
"proc-macro2",
"quote",
"syn 2.0.41",
]
[[package]]
name = "equivalent"
version = "1.0.1"
@ -1717,6 +1931,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87f253bc5c813ca05792837a0ff4b3a580336b224512d48f7eda1d7dd9210787"
dependencies = [
"num-traits",
"serde",
]
[[package]]
@ -1746,6 +1961,43 @@ dependencies = [
"pin-project-lite",
]
[[package]]
name = "execute"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a82608ee96ce76aeab659e9b8d3c2b787bffd223199af88c674923d861ada10"
dependencies = [
"execute-command-macro",
"execute-command-tokens",
"generic-array",
]
[[package]]
name = "execute-command-macro"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90dec53d547564e911dc4ff3ecb726a64cf41a6fa01a2370ebc0d95175dd08bd"
dependencies = [
"execute-command-macro-impl",
]
[[package]]
name = "execute-command-macro-impl"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce8cd46a041ad005ab9c71263f9a0ff5b529eac0fe4cc9b4a20f4f0765d8cf4b"
dependencies = [
"execute-command-tokens",
"quote",
"syn 2.0.41",
]
[[package]]
name = "execute-command-tokens"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69dc321eb6be977f44674620ca3aa21703cb20ffbe560e1ae97da08401ffbcad"
[[package]]
name = "fastrand"
version = "1.9.0"
@ -1770,6 +2022,18 @@ dependencies = [
"simd-adler32",
]
[[package]]
name = "filetime"
version = "0.2.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd"
dependencies = [
"cfg-if",
"libc",
"redox_syscall 0.4.1",
"windows-sys 0.52.0",
]
[[package]]
name = "fixedbitset"
version = "0.4.2"
@ -1834,6 +2098,15 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
[[package]]
name = "fsevent-sys"
version = "4.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76ee7a02da4d231650c7cea31349b889be2f45ddb3ef3032d2ec8185f6313fd2"
dependencies = [
"libc",
]
[[package]]
name = "futures-channel"
version = "0.3.29"
@ -1901,6 +2174,15 @@ dependencies = [
"pin-utils",
]
[[package]]
name = "generic-array"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe739944a5406424e080edccb6add95685130b9f160d5407c639c7df0c5836b0"
dependencies = [
"typenum",
]
[[package]]
name = "getrandom"
version = "0.2.11"
@ -1934,7 +2216,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "178769da179a47b187837d1ab2b5b9b684a21180166a77a4ca37e7e58ee3833d"
dependencies = [
"core-foundation",
"inotify",
"inotify 0.10.2",
"io-kit-sys",
"js-sys",
"libc",
@ -1970,6 +2252,19 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "globset"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1"
dependencies = [
"aho-corasick",
"bstr",
"log",
"regex-automata 0.4.3",
"regex-syntax 0.8.2",
]
[[package]]
name = "glow"
version = "0.12.3"
@ -2101,6 +2396,9 @@ name = "hashbrown"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
dependencies = [
"ahash 0.7.7",
]
[[package]]
name = "hashbrown"
@ -2108,7 +2406,7 @@ version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
dependencies = [
"ahash",
"ahash 0.8.6",
"allocator-api2",
"serde",
]
@ -2144,6 +2442,51 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
[[package]]
name = "iana-time-zone"
version = "0.1.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20"
dependencies = [
"android_system_properties",
"core-foundation-sys",
"iana-time-zone-haiku",
"js-sys",
"wasm-bindgen",
"windows-core",
]
[[package]]
name = "iana-time-zone-haiku"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
dependencies = [
"cc",
]
[[package]]
name = "ident_case"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "ignore"
version = "0.4.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "747ad1b4ae841a78e8aba0d63adbfbeaea26b517b63705d47856b73015d27060"
dependencies = [
"crossbeam-deque",
"globset",
"log",
"memchr",
"regex-automata 0.4.3",
"same-file",
"walkdir",
"winapi-util",
]
[[package]]
name = "image"
version = "0.24.7"
@ -2184,6 +2527,17 @@ version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a257582fdcde896fd96463bf2d40eefea0580021c0712a0e2b028b60b47a837a"
[[package]]
name = "inotify"
version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff"
dependencies = [
"bitflags 1.3.2",
"inotify-sys",
"libc",
]
[[package]]
name = "inotify"
version = "0.10.2"
@ -2216,6 +2570,42 @@ dependencies = [
"web-sys",
]
[[package]]
name = "internment"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e976188335292f66a1533fd41d5c2ce24b32dc2c000569b8dccf4e57f489806"
dependencies = [
"hashbrown 0.12.3",
"parking_lot",
]
[[package]]
name = "interprocess-docfix"
version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b84ee245c606aeb0841649a9288e3eae8c61b853a8cd5c0e14450e96d53d28f"
dependencies = [
"blocking",
"cfg-if",
"futures-core",
"futures-io",
"intmap",
"libc",
"once_cell",
"rustc_version",
"spinning",
"thiserror",
"to_method",
"winapi",
]
[[package]]
name = "intmap"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae52f28f45ac2bc96edb7714de995cffc174a395fb0abf5bff453587c980d7b9"
[[package]]
name = "io-kit-sys"
version = "0.4.0"
@ -2284,6 +2674,17 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "keyboard-types"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b750dcadc39a09dbadd74e118f6dd6598df77fa01df0cfcdc52c28dece74528a"
dependencies = [
"bitflags 2.4.1",
"serde",
"unicode-segmentation",
]
[[package]]
name = "khronos-egl"
version = "4.1.0"
@ -2295,6 +2696,38 @@ dependencies = [
"pkg-config",
]
[[package]]
name = "kqueue"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7447f1ca1b7b563588a205fe93dea8df60fd981423a768bc1c0ded35ed147d0c"
dependencies = [
"kqueue-sys",
"libc",
]
[[package]]
name = "kqueue-sys"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b"
dependencies = [
"bitflags 1.3.2",
"libc",
]
[[package]]
name = "krates"
version = "0.12.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "942c43a6cba1c201dfe81a943c89fa5c9140b34993e0c027f542c80b92e319a7"
dependencies = [
"cargo_metadata",
"cfg-expr",
"petgraph",
"semver",
]
[[package]]
name = "ktx2"
version = "0.3.0"
@ -2429,6 +2862,15 @@ version = "2.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
[[package]]
name = "memoffset"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c"
dependencies = [
"autocfg",
]
[[package]]
name = "metal"
version = "0.26.0"
@ -2580,6 +3022,24 @@ version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "610a5acd306ec67f907abe5567859a3c693fb9886eb1f012ab8f2a47bef3db51"
[[package]]
name = "notify"
version = "5.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "729f63e1ca555a43fe3efa4f3efdf4801c479da85b432242a7b726f353c88486"
dependencies = [
"bitflags 1.3.2",
"crossbeam-channel",
"filetime",
"fsevent-sys",
"inotify 0.9.6",
"kqueue",
"libc",
"mio",
"walkdir",
"windows-sys 0.45.0",
]
[[package]]
name = "ntapi"
version = "0.4.1"
@ -2783,6 +3243,15 @@ dependencies = [
"libredox",
]
[[package]]
name = "ordered-float"
version = "2.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c"
dependencies = [
"num-traits",
]
[[package]]
name = "overload"
version = "0.1.1"
@ -3082,6 +3551,15 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustc_version"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [
"semver",
]
[[package]]
name = "ruzstd"
version = "0.4.0"
@ -3114,6 +3592,15 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "semver"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090"
dependencies = [
"serde",
]
[[package]]
name = "serde"
version = "1.0.193"
@ -3123,6 +3610,16 @@ dependencies = [
"serde_derive",
]
[[package]]
name = "serde-value"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c"
dependencies = [
"ordered-float",
"serde",
]
[[package]]
name = "serde_derive"
version = "1.0.193"
@ -3145,6 +3642,17 @@ dependencies = [
"serde",
]
[[package]]
name = "serde_repr"
version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.41",
]
[[package]]
name = "sharded-slab"
version = "0.1.7"
@ -3208,6 +3716,15 @@ dependencies = [
"serde",
]
[[package]]
name = "spinning"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d4f0e86297cad2658d92a707320d87bf4e6ae1050287f51d19b67ef3f153a7b"
dependencies = [
"lock_api",
]
[[package]]
name = "spirv"
version = "0.2.0+1.5.4"
@ -3352,6 +3869,12 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "to_method"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7c4ceeeca15c8384bbc3e011dbd8fccb7f068a440b752b7d9b32ceb0ca0e2e8"
[[package]]
name = "toml_datetime"
version = "0.6.5"
@ -3479,12 +4002,24 @@ dependencies = [
"static_assertions",
]
[[package]]
name = "typenum"
version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
[[package]]
name = "unicode-ident"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "unicode-segmentation"
version = "1.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
[[package]]
name = "unicode-width"
version = "0.1.11"
@ -3858,6 +4393,15 @@ dependencies = [
"windows-targets 0.48.5",
]
[[package]]
name = "windows-sys"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets 0.52.0",
]
[[package]]
name = "windows-targets"
version = "0.42.2"
@ -3888,6 +4432,21 @@ dependencies = [
"windows_x86_64_msvc 0.48.5",
]
[[package]]
name = "windows-targets"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
dependencies = [
"windows_aarch64_gnullvm 0.52.0",
"windows_aarch64_msvc 0.52.0",
"windows_i686_gnu 0.52.0",
"windows_i686_msvc 0.52.0",
"windows_x86_64_gnu 0.52.0",
"windows_x86_64_gnullvm 0.52.0",
"windows_x86_64_msvc 0.52.0",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.42.2"
@ -3900,6 +4459,12 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
[[package]]
name = "windows_aarch64_msvc"
version = "0.42.2"
@ -3912,6 +4477,12 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
[[package]]
name = "windows_i686_gnu"
version = "0.42.2"
@ -3924,6 +4495,12 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_gnu"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
[[package]]
name = "windows_i686_msvc"
version = "0.42.2"
@ -3936,6 +4513,12 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_i686_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.2"
@ -3948,6 +4531,12 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.2"
@ -3960,6 +4549,12 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
[[package]]
name = "windows_x86_64_msvc"
version = "0.42.2"
@ -3972,6 +4567,12 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
[[package]]
name = "winit"
version = "0.28.7"

View File

@ -9,10 +9,19 @@ dioxus = { version = "0.4", default-features = false, features = [
"macro",
"hooks",
] }
dioxus-rsx = { version = "0.4", default-features = false, features = [
"hot_reload",
], optional = true }
dioxus-hot-reload = { version = "0.4", default-features = false, features = [
"custom_file_watcher",
], optional = true }
bevy_mod_picking = { version = "0.17", default-features = false, features = [
"backend_bevy_ui",
] }
[features]
hot_reload = ["dioxus/hot-reload", "dioxus-rsx", "dioxus-hot-reload"]
[patch.crates-io]
bevy_app = { git = "https://github.com/JMS55/bevy", branch = "query_new_12" }
bevy_asset = { git = "https://github.com/JMS55/bevy", branch = "query_new_12" }

128
src/hot_reload.rs Normal file
View File

@ -0,0 +1,128 @@
use crate::prelude::dioxus_elements;
use bevy::ecs::world::World;
use dioxus::core::{Template, VirtualDom};
use dioxus_hot_reload::{connect, HotReloadMsg};
use dioxus_rsx::HotReloadingContext;
use std::sync::mpsc::{channel, Receiver};
pub fn update_templates(world: &mut World, virtual_dom: &mut VirtualDom) {
if !world.contains_non_send::<Receiver<Template<'static>>>() {
let (updated_templates_sender, updated_templates_receiver) = channel();
connect(move |msg| match msg {
HotReloadMsg::UpdateTemplate(updated_templated) => {
let _ = updated_templates_sender.send(updated_templated);
}
HotReloadMsg::Shutdown => {}
});
world.insert_non_send_resource(updated_templates_receiver);
}
let updated_templates_receiver = world.non_send_resource_mut::<Receiver<Template<'static>>>();
while let Ok(updated_templated) = updated_templates_receiver.try_recv() {
virtual_dom.replace_template(updated_templated);
}
}
pub struct HotReloadContext;
impl HotReloadingContext for HotReloadContext {
fn map_attribute(
element_name_rust: &str,
attribute_name_rust: &str,
) -> Option<(&'static str, Option<&'static str>)> {
if element_name_rust == dioxus_elements::text::TAG_NAME {
let attribute = match attribute_name_rust {
"text" => Some(("text", None)),
"text_direction" => Some(("text_direction", None)),
"text_alignment" => Some(("text_alignment", None)),
"text_size" => Some(("text_size", None)),
"text_color" => Some(("text_color", None)),
_ => None,
};
if let Some(attribute) = attribute {
return Some(attribute);
}
}
if let dioxus_elements::node::TAG_NAME | dioxus_elements::text::TAG_NAME = element_name_rust
{
match attribute_name_rust {
"display" => Some(("display", None)),
"position" => Some(("position", None)),
"overflow" => Some(("overflow", None)),
"overflow_x" => Some(("overflow_x", None)),
"overflow_y" => Some(("overflow_y", None)),
"left" => Some(("left", None)),
"right" => Some(("right", None)),
"top" => Some(("top", None)),
"bottom" => Some(("bottom", None)),
"width" => Some(("width", None)),
"height" => Some(("height", None)),
"min_width" => Some(("min_width", None)),
"min_height" => Some(("min_height", None)),
"aspect_ratio" => Some(("aspect_ratio", None)),
"align_items" => Some(("align_items", None)),
"justify_items" => Some(("justify_items", None)),
"align_self" => Some(("align_self", None)),
"justify_self" => Some(("justify_self", None)),
"align_content" => Some(("align_content", None)),
"justify_content" => Some(("justify_content", None)),
"margin" => Some(("margin", None)),
"margin_left" => Some(("margin_left", None)),
"margin_right" => Some(("margin_right", None)),
"margin_top" => Some(("margin_top", None)),
"margin_bottom" => Some(("margin_bottom", None)),
"padding" => Some(("padding", None)),
"padding_left" => Some(("padding_left", None)),
"padding_right" => Some(("padding_right", None)),
"padding_top" => Some(("padding_top", None)),
"padding_bottom" => Some(("padding_bottom", None)),
"border_width" => Some(("border_width", None)),
"border_width_left" => Some(("border_width_left", None)),
"border_width_right" => Some(("border_width_right", None)),
"border_width_top" => Some(("border_width_top", None)),
"border_width_bottom" => Some(("border_width_bottom", None)),
"border_color" => Some(("border_color", None)),
"outline_width" => Some(("outline_width", None)),
"outline_offset" => Some(("outline_offset", None)),
"outline_color" => Some(("outline_color", None)),
"flex_direction" => Some(("flex_direction", None)),
"flex_wrap" => Some(("flex_wrap", None)),
"flex_grow" => Some(("flex_grow", None)),
"flex_shrink" => Some(("flex_shrink", None)),
"flex_basis" => Some(("flex_basis", None)),
"row_gap" => Some(("row_gap", None)),
"column_gap" => Some(("column_gap", None)),
"grid_auto_flow" => Some(("grid_auto_flow", None)),
"grid_template_rows" => Some(("grid_template_rows", None)),
"grid_template_columns" => Some(("grid_template_columns", None)),
"grid_auto_rows" => Some(("grid_auto_rows", None)),
"grid_auto_columns" => Some(("grid_auto_columns", None)),
"grid_row" => Some(("grid_row", None)),
"grid_column" => Some(("grid_column", None)),
"background_color" => Some(("background_color", None)),
"translation" => Some(("translation", None)),
"rotation" => Some(("rotation", None)),
"scale" => Some(("scale", None)),
"visibility" => Some(("visibility", None)),
"z_index" => Some(("z_index", None)),
_ => None,
}
} else {
None
}
}
fn map_element(element_name_rust: &str) -> Option<(&'static str, Option<&'static str>)> {
match element_name_rust {
dioxus_elements::node::TAG_NAME => Some((
dioxus_elements::node::TAG_NAME,
dioxus_elements::node::NAME_SPACE,
)),
dioxus_elements::text::TAG_NAME => Some((
dioxus_elements::text::TAG_NAME,
dioxus_elements::text::NAME_SPACE,
)),
_ => None,
}
}
}

View File

@ -5,6 +5,8 @@ mod elements;
#[macro_use]
mod events;
mod hooks;
#[cfg(feature = "hot_reload")]
mod hot_reload;
mod parse_attributes;
mod tick;
@ -33,6 +35,11 @@ pub struct DioxusUiPlugin;
impl Plugin for DioxusUiPlugin {
fn build(&self, app: &mut App) {
#[cfg(feature = "hot_reload")]
dioxus_hot_reload::hot_reload_init!(dioxus_hot_reload::Config::<
hot_reload::HotReloadContext,
>::default());
app.init_non_send_resource::<UiContext>()
.init_resource::<DeferredSystemRegistry>()
.init_resource::<EventReaders>()

View File

@ -101,6 +101,9 @@ fn render_ui(root_entity: Entity, ui_root: &mut UiRoot, world: &mut World) {
.base_scope()
.provide_context(EcsContext { world });
#[cfg(feature = "hot_reload")]
crate::hot_reload::update_templates(world, &mut ui_root.virtual_dom);
if ui_root.needs_rebuild {
apply_mutations(
ui_root.virtual_dom.rebuild(),