mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-27 22:50:19 +00:00
Merge pull request #84 from Demonthos/fix-hot-reloading
Fix hot reloading
This commit is contained in:
commit
b482b4c35d
6 changed files with 352 additions and 1000 deletions
333
Cargo.lock
generated
333
Cargo.lock
generated
|
@ -4,9 +4,9 @@ version = 3
|
|||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
version = "0.17.0"
|
||||
version = "0.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b"
|
||||
checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97"
|
||||
dependencies = [
|
||||
"gimli",
|
||||
]
|
||||
|
@ -49,9 +49,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.66"
|
||||
version = "1.0.68"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6"
|
||||
checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61"
|
||||
|
||||
[[package]]
|
||||
name = "arrayref"
|
||||
|
@ -67,9 +67,9 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
|
|||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.59"
|
||||
version = "0.1.60"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "31e6e93155431f3931513b243d371981bb2770112b370c82745a1d19d2f99364"
|
||||
checksum = "677d1d8ab452a3936018a687b20e6f7cf5363d713b732b8884001317b0e48aa3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -82,7 +82,7 @@ version = "0.2.14"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"hermit-abi 0.1.19",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
@ -146,15 +146,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.66"
|
||||
version = "0.3.67"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7"
|
||||
checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca"
|
||||
dependencies = [
|
||||
"addr2line",
|
||||
"cc",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"miniz_oxide 0.5.4",
|
||||
"miniz_oxide",
|
||||
"object",
|
||||
"rustc-demangle",
|
||||
]
|
||||
|
@ -317,9 +317,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.77"
|
||||
version = "1.0.78"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4"
|
||||
checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
]
|
||||
|
@ -556,9 +556,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cxx"
|
||||
version = "1.0.83"
|
||||
version = "1.0.85"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bdf07d07d6531bfcdbe9b8b739b104610c6508dcc4d63b410585faf338241daf"
|
||||
checksum = "5add3fc1717409d029b20c5b6903fc0c0b02fa6741d820054f4a2efa5e5816fd"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"cxxbridge-flags",
|
||||
|
@ -568,9 +568,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cxx-build"
|
||||
version = "1.0.83"
|
||||
version = "1.0.85"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2eb5b96ecdc99f72657332953d4d9c50135af1bac34277801cc3937906ebd39"
|
||||
checksum = "b4c87959ba14bc6fbc61df77c3fcfe180fc32b93538c4f1031dd802ccb5f2ff0"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"codespan-reporting",
|
||||
|
@ -583,21 +583,55 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cxxbridge-flags"
|
||||
version = "1.0.83"
|
||||
version = "1.0.85"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac040a39517fd1674e0f32177648334b0f4074625b5588a64519804ba0553b12"
|
||||
checksum = "69a3e162fde4e594ed2b07d0f83c6c67b745e7f28ce58c6df5e6b6bef99dfb59"
|
||||
|
||||
[[package]]
|
||||
name = "cxxbridge-macro"
|
||||
version = "1.0.83"
|
||||
version = "1.0.85"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1362b0ddcfc4eb0a1f57b68bd77dd99f0e826958a96abd0ae9bd092e114ffed6"
|
||||
checksum = "3e7e2adeb6a0d4a282e581096b06e1791532b7d576dcde5ccd9382acf55db8e6"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling"
|
||||
version = "0.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0dd3cd20dc6b5a876612a6e5accfe7f3dd883db6d07acfbf14c128f61550dfa"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"darling_macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_core"
|
||||
version = "0.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a784d2ccaf7c98501746bf0be29b2022ba41fd62a2e622af997a03e9f972859f"
|
||||
dependencies = [
|
||||
"fnv",
|
||||
"ident_case",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_macro"
|
||||
version = "0.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7618812407e9402654622dd402b0a89dff9ba93badd6540781526117b92aab7e"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "data-encoding"
|
||||
version = "2.3.3"
|
||||
|
@ -630,6 +664,8 @@ dependencies = [
|
|||
"colored 2.0.0",
|
||||
"convert_case",
|
||||
"ctrlc",
|
||||
"dioxus-core",
|
||||
"dioxus-html",
|
||||
"dioxus-rsx",
|
||||
"dirs 4.0.0",
|
||||
"fern",
|
||||
|
@ -661,11 +697,42 @@ dependencies = [
|
|||
"zip 0.6.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dioxus-core"
|
||||
version = "0.2.1"
|
||||
source = "git+https://github.com/dioxuslabs/dioxus#3824f386f7118999be739e92ac4f320f88979e06"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
"indexmap",
|
||||
"log",
|
||||
"longest-increasing-subsequence",
|
||||
"rustc-hash",
|
||||
"serde",
|
||||
"slab",
|
||||
"smallbox",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dioxus-html"
|
||||
version = "0.2.1"
|
||||
source = "git+https://github.com/dioxuslabs/dioxus#3824f386f7118999be739e92ac4f320f88979e06"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"dioxus-core",
|
||||
"enumset",
|
||||
"euclid",
|
||||
"keyboard-types",
|
||||
"serde",
|
||||
"serde-value",
|
||||
"serde_repr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dioxus-rsx"
|
||||
version = "0.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dbbc06efd42a94671472910bd5aeb55b28d0d2683d30dfc6af0508917478beb5"
|
||||
source = "git+https://github.com/dioxuslabs/dioxus#3824f386f7118999be739e92ac4f320f88979e06"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -737,6 +804,37 @@ dependencies = [
|
|||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "enumset"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19be8061a06ab6f3a6cf21106c873578bf01bd42ad15e0311a9c76161cb1c753"
|
||||
dependencies = [
|
||||
"enumset_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "enumset_derive"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03e7b551eba279bf0fa88b83a46330168c1560a52a94f5126f892f0b364ab3e0"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "euclid"
|
||||
version = "0.22.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b52c2ef4a78da0ba68fbe1fd920627411096d2ac478f7f4c9f3a54ba6705bade"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "failure"
|
||||
version = "0.1.8"
|
||||
|
@ -797,7 +895,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"miniz_oxide 0.6.2",
|
||||
"miniz_oxide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -968,9 +1066,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.26.2"
|
||||
version = "0.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d"
|
||||
checksum = "dec7af912d60cdbd3677c1af9352ebae6fb8394d165568a2234df0fa00f87793"
|
||||
|
||||
[[package]]
|
||||
name = "h2"
|
||||
|
@ -1046,6 +1144,15 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hex"
|
||||
version = "0.3.2"
|
||||
|
@ -1206,6 +1313,12 @@ version = "2.2.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005"
|
||||
|
||||
[[package]]
|
||||
name = "ident_case"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "0.2.3"
|
||||
|
@ -1316,9 +1429,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.4"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc"
|
||||
checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440"
|
||||
|
||||
[[package]]
|
||||
name = "jobserver"
|
||||
|
@ -1338,6 +1451,17 @@ dependencies = [
|
|||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "keyboard-types"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b7668b7cff6a51fe61cdde64cd27c8a220786f399501b57ebe36f7d8112fd68"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"serde",
|
||||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kqueue"
|
||||
version = "1.0.7"
|
||||
|
@ -1372,9 +1496,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67"
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.138"
|
||||
version = "0.2.139"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8"
|
||||
checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
|
||||
|
||||
[[package]]
|
||||
name = "libz-sys"
|
||||
|
@ -1390,9 +1514,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "link-cplusplus"
|
||||
version = "1.0.7"
|
||||
version = "1.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369"
|
||||
checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
@ -1422,6 +1546,12 @@ dependencies = [
|
|||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "longest-increasing-subsequence"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3bd0dd2cd90571056fdb71f6275fada10131182f84899f4b2a916e565d81d86"
|
||||
|
||||
[[package]]
|
||||
name = "lru-cache"
|
||||
version = "0.1.2"
|
||||
|
@ -1442,9 +1572,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "luajit-src"
|
||||
version = "210.4.3+resty8384278"
|
||||
version = "210.4.4+restydf15b79"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19ee5d5afddf1ec76ffa55ca7c3001f2f8a703834beba53c56a38ea6641cef44"
|
||||
checksum = "41f081de0df368f97e5d8bb60e435caa078bd5d42797a8c9f0bb8d5192dcdcc1"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
@ -1489,15 +1619,6 @@ dependencies = [
|
|||
"unicase",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34"
|
||||
dependencies = [
|
||||
"adler",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.6.2"
|
||||
|
@ -1624,11 +1745,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "num_cpus"
|
||||
version = "1.14.0"
|
||||
version = "1.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5"
|
||||
checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"hermit-abi 0.2.6",
|
||||
"libc",
|
||||
]
|
||||
|
||||
|
@ -1640,9 +1761,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3"
|
|||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.29.0"
|
||||
version = "0.30.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53"
|
||||
checksum = "239da7f290cfa979f43f85a8efeee9a8a76d0827c356d37f9d3d7254d6b537fb"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
@ -1661,9 +1782,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
|||
|
||||
[[package]]
|
||||
name = "openssl"
|
||||
version = "0.10.44"
|
||||
version = "0.10.45"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29d971fd5722fec23977260f6e81aa67d2f22cadbdc2aa049f1022d9a3be1566"
|
||||
checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
|
@ -1693,9 +1814,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
|
|||
|
||||
[[package]]
|
||||
name = "openssl-sys"
|
||||
version = "0.9.79"
|
||||
version = "0.9.80"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5454462c0eced1e97f2ec09036abc8da362e66802f66fd20f86854d9d8cbcbc4"
|
||||
checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"cc",
|
||||
|
@ -1704,6 +1825,15 @@ dependencies = [
|
|||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ordered-float"
|
||||
version = "2.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7940cf2ca942593318d07fcf2596cdca60a85c9e7fab408a5e21a4f9dcd40d87"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "os_str_bytes"
|
||||
version = "6.4.1"
|
||||
|
@ -1764,9 +1894,9 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
|
|||
|
||||
[[package]]
|
||||
name = "pest"
|
||||
version = "2.5.1"
|
||||
version = "2.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc8bed3549e0f9b0a2a78bf7c0018237a2cdf085eecbbc048e52612438e4e9d0"
|
||||
checksum = "0f6e86fb9e7026527a0d46bc308b841d73170ef8f443e1807f6ef88526a816d4"
|
||||
dependencies = [
|
||||
"thiserror",
|
||||
"ucd-trie",
|
||||
|
@ -1774,9 +1904,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "pest_derive"
|
||||
version = "2.5.1"
|
||||
version = "2.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cdc078600d06ff90d4ed238f0119d84ab5d43dbaad278b0e33a8820293b32344"
|
||||
checksum = "96504449aa860c8dcde14f9fba5c58dc6658688ca1fe363589d6327b8662c603"
|
||||
dependencies = [
|
||||
"pest",
|
||||
"pest_generator",
|
||||
|
@ -1784,9 +1914,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "pest_generator"
|
||||
version = "2.5.1"
|
||||
version = "2.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28a1af60b1c4148bb269006a750cff8e2ea36aff34d2d96cf7be0b14d1bed23c"
|
||||
checksum = "798e0220d1111ae63d66cb66a5dcb3fc2d986d520b98e49e1852bfdb11d7c5e7"
|
||||
dependencies = [
|
||||
"pest",
|
||||
"pest_meta",
|
||||
|
@ -1797,9 +1927,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "pest_meta"
|
||||
version = "2.5.1"
|
||||
version = "2.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fec8605d59fc2ae0c6c1aefc0c7c7a9769732017c0ce07f7a9cfffa7b4404f20"
|
||||
checksum = "984298b75898e30a843e278a9f2452c31e349a073a0ce6fd950a12a74464e065"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"pest",
|
||||
|
@ -1846,9 +1976,9 @@ checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
|
|||
|
||||
[[package]]
|
||||
name = "portable-atomic"
|
||||
version = "0.3.16"
|
||||
version = "0.3.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac662b3a6490de378b0ee15cf2dfff7127aebfe0b19acc65e7fbca3d299c3788"
|
||||
checksum = "81bdd679d533107e090c2704a35982fc06302e30898e63ffa26a81155c012e92"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
|
@ -1882,9 +2012,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.47"
|
||||
version = "1.0.49"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
|
||||
checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
@ -1897,9 +2027,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
|
|||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.21"
|
||||
version = "1.0.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
|
||||
checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
@ -2113,9 +2243,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.11"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09"
|
||||
checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde"
|
||||
|
||||
[[package]]
|
||||
name = "safemem"
|
||||
|
@ -2150,9 +2280,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
|||
|
||||
[[package]]
|
||||
name = "scratch"
|
||||
version = "1.0.2"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898"
|
||||
checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2"
|
||||
|
||||
[[package]]
|
||||
name = "sct"
|
||||
|
@ -2189,27 +2319,37 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.14"
|
||||
version = "1.0.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4"
|
||||
checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.149"
|
||||
version = "1.0.151"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "256b9932320c590e707b94576e3cc1f7c9024d0ee6612dfbcf1cb106cbe8e055"
|
||||
checksum = "97fed41fc1a24994d044e6db6935e69511a1153b52c15eb42493b26fa87feba0"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.149"
|
||||
name = "serde-value"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4eae9b04cbffdfd550eb462ed33bc6a1b68c935127d008b27444d08380f94e4"
|
||||
checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c"
|
||||
dependencies = [
|
||||
"ordered-float",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.151"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "255abe9a125a985c05190d687b320c12f9b1f0b99445e608c21ba0782c719ad8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -2218,15 +2358,26 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.89"
|
||||
version = "1.0.91"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db"
|
||||
checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_repr"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a5ec9fa74a20ebbe5d9ac23dac1fc96ba0ecfe9f50f2843b52e537b10fbcb4e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_urlencoded"
|
||||
version = "0.7.1"
|
||||
|
@ -2296,6 +2447,12 @@ dependencies = [
|
|||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "smallbox"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4679d6eef28b85020158619fc09769de89e90886c5de7157587d87cb72648faa"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.10.0"
|
||||
|
@ -2338,9 +2495,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.105"
|
||||
version = "1.0.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908"
|
||||
checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -2417,18 +2574,18 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d"
|
|||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.37"
|
||||
version = "1.0.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e"
|
||||
checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.37"
|
||||
version = "1.0.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb"
|
||||
checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -2568,9 +2725,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.9"
|
||||
version = "0.5.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7"
|
||||
checksum = "1333c76748e868a4d9d1017b5ab53171dfd095f70c712fdb4653a406547f598f"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
@ -2779,9 +2936,9 @@ checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992"
|
|||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.5"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"
|
||||
checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-normalization"
|
||||
|
|
|
@ -72,7 +72,10 @@ mlua = { version = "0.8.1", features = [
|
|||
"macros",
|
||||
] }
|
||||
ctrlc = "3.2.3"
|
||||
dioxus-rsx = "0.0.1"
|
||||
# dioxus-rsx = "0.0.1"
|
||||
dioxus-rsx = { git = "https://github.com/DioxusLabs/dioxus" }
|
||||
dioxus-html = { git = "https://github.com/DioxusLabs/dioxus", features = ["hot-reload-context"] }
|
||||
dioxus-core = { git = "https://github.com/DioxusLabs/dioxus", features = ["serialize"] }
|
||||
|
||||
[[bin]]
|
||||
path = "src/main.rs"
|
||||
|
|
|
@ -1,614 +0,0 @@
|
|||
use proc_macro2::TokenStream;
|
||||
use syn::{File, Macro};
|
||||
|
||||
pub enum DiffResult {
|
||||
CodeChanged,
|
||||
RsxChanged(Vec<(Macro, TokenStream)>),
|
||||
}
|
||||
|
||||
/// Find any rsx calls in the given file and return a list of all the rsx calls that have changed.
|
||||
pub fn find_rsx(new: &File, old: &File) -> DiffResult {
|
||||
let mut rsx_calls = Vec::new();
|
||||
if new.items.len() != old.items.len() {
|
||||
return DiffResult::CodeChanged;
|
||||
}
|
||||
for (new, old) in new.items.iter().zip(old.items.iter()) {
|
||||
if find_rsx_item(new, old, &mut rsx_calls) {
|
||||
return DiffResult::CodeChanged;
|
||||
}
|
||||
}
|
||||
DiffResult::RsxChanged(rsx_calls)
|
||||
}
|
||||
|
||||
fn find_rsx_item(
|
||||
new: &syn::Item,
|
||||
old: &syn::Item,
|
||||
rsx_calls: &mut Vec<(Macro, TokenStream)>,
|
||||
) -> bool {
|
||||
match (new, old) {
|
||||
(syn::Item::Const(new_item), syn::Item::Const(old_item)) => {
|
||||
find_rsx_expr(&new_item.expr, &old_item.expr, rsx_calls)
|
||||
|| new_item.attrs != old_item.attrs
|
||||
|| new_item.vis != old_item.vis
|
||||
|| new_item.const_token != old_item.const_token
|
||||
|| new_item.ident != old_item.ident
|
||||
|| new_item.colon_token != old_item.colon_token
|
||||
|| new_item.ty != old_item.ty
|
||||
|| new_item.eq_token != old_item.eq_token
|
||||
|| new_item.semi_token != old_item.semi_token
|
||||
}
|
||||
(syn::Item::Enum(new_item), syn::Item::Enum(old_item)) => {
|
||||
if new_item.variants.len() != old_item.variants.len() {
|
||||
return true;
|
||||
}
|
||||
for (new_varient, old_varient) in new_item.variants.iter().zip(old_item.variants.iter())
|
||||
{
|
||||
match (&new_varient.discriminant, &old_varient.discriminant) {
|
||||
(Some((new_eq, new_expr)), Some((old_eq, old_expr))) => {
|
||||
if find_rsx_expr(new_expr, old_expr, rsx_calls) || new_eq != old_eq {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
(None, None) => (),
|
||||
_ => return true,
|
||||
}
|
||||
if new_varient.attrs != old_varient.attrs
|
||||
|| new_varient.ident != old_varient.ident
|
||||
|| new_varient.fields != old_varient.fields
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
new_item.attrs != old_item.attrs
|
||||
|| new_item.vis != old_item.vis
|
||||
|| new_item.enum_token != old_item.enum_token
|
||||
|| new_item.ident != old_item.ident
|
||||
|| new_item.generics != old_item.generics
|
||||
|| new_item.brace_token != old_item.brace_token
|
||||
}
|
||||
(syn::Item::ExternCrate(new_item), syn::Item::ExternCrate(old_item)) => {
|
||||
old_item != new_item
|
||||
}
|
||||
(syn::Item::Fn(new_item), syn::Item::Fn(old_item)) => {
|
||||
find_rsx_block(&new_item.block, &old_item.block, rsx_calls)
|
||||
|| new_item.attrs != old_item.attrs
|
||||
|| new_item.vis != old_item.vis
|
||||
|| new_item.sig != old_item.sig
|
||||
}
|
||||
(syn::Item::ForeignMod(new_item), syn::Item::ForeignMod(old_item)) => old_item != new_item,
|
||||
(syn::Item::Impl(new_item), syn::Item::Impl(old_item)) => {
|
||||
if new_item.items.len() != old_item.items.len() {
|
||||
return true;
|
||||
}
|
||||
for (new_item, old_item) in new_item.items.iter().zip(old_item.items.iter()) {
|
||||
if match (new_item, old_item) {
|
||||
(syn::ImplItem::Const(new_item), syn::ImplItem::Const(old_item)) => {
|
||||
find_rsx_expr(&new_item.expr, &old_item.expr, rsx_calls)
|
||||
}
|
||||
(syn::ImplItem::Method(new_item), syn::ImplItem::Method(old_item)) => {
|
||||
find_rsx_block(&new_item.block, &old_item.block, rsx_calls)
|
||||
}
|
||||
(syn::ImplItem::Type(new_item), syn::ImplItem::Type(old_item)) => {
|
||||
old_item != new_item
|
||||
}
|
||||
(syn::ImplItem::Macro(new_item), syn::ImplItem::Macro(old_item)) => {
|
||||
old_item != new_item
|
||||
}
|
||||
_ => true,
|
||||
} {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
new_item.attrs != old_item.attrs
|
||||
|| new_item.defaultness != old_item.defaultness
|
||||
|| new_item.unsafety != old_item.unsafety
|
||||
|| new_item.impl_token != old_item.impl_token
|
||||
|| new_item.generics != old_item.generics
|
||||
|| new_item.trait_ != old_item.trait_
|
||||
|| new_item.self_ty != old_item.self_ty
|
||||
|| new_item.brace_token != old_item.brace_token
|
||||
}
|
||||
(syn::Item::Macro(new_item), syn::Item::Macro(old_item)) => old_item != new_item,
|
||||
(syn::Item::Macro2(new_item), syn::Item::Macro2(old_item)) => old_item != new_item,
|
||||
(syn::Item::Mod(new_item), syn::Item::Mod(old_item)) => {
|
||||
match (&new_item.content, &old_item.content) {
|
||||
(Some((_, new_items)), Some((_, old_items))) => {
|
||||
if new_items.len() != old_items.len() {
|
||||
return true;
|
||||
}
|
||||
for (new_item, old_item) in new_items.iter().zip(old_items.iter()) {
|
||||
if find_rsx_item(new_item, old_item, rsx_calls) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
new_item.attrs != old_item.attrs
|
||||
|| new_item.vis != old_item.vis
|
||||
|| new_item.mod_token != old_item.mod_token
|
||||
|| new_item.ident != old_item.ident
|
||||
|| new_item.semi != old_item.semi
|
||||
}
|
||||
(None, None) => {
|
||||
new_item.attrs != old_item.attrs
|
||||
|| new_item.vis != old_item.vis
|
||||
|| new_item.mod_token != old_item.mod_token
|
||||
|| new_item.ident != old_item.ident
|
||||
|| new_item.semi != old_item.semi
|
||||
}
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
(syn::Item::Static(new_item), syn::Item::Static(old_item)) => {
|
||||
find_rsx_expr(&new_item.expr, &old_item.expr, rsx_calls)
|
||||
|| new_item.attrs != old_item.attrs
|
||||
|| new_item.vis != old_item.vis
|
||||
|| new_item.static_token != old_item.static_token
|
||||
|| new_item.mutability != old_item.mutability
|
||||
|| new_item.ident != old_item.ident
|
||||
|| new_item.colon_token != old_item.colon_token
|
||||
|| new_item.ty != old_item.ty
|
||||
|| new_item.eq_token != old_item.eq_token
|
||||
|| new_item.semi_token != old_item.semi_token
|
||||
}
|
||||
(syn::Item::Struct(new_item), syn::Item::Struct(old_item)) => old_item != new_item,
|
||||
(syn::Item::Trait(new_item), syn::Item::Trait(old_item)) => {
|
||||
find_rsx_trait(new_item, old_item, rsx_calls)
|
||||
}
|
||||
(syn::Item::TraitAlias(new_item), syn::Item::TraitAlias(old_item)) => old_item != new_item,
|
||||
(syn::Item::Type(new_item), syn::Item::Type(old_item)) => old_item != new_item,
|
||||
(syn::Item::Union(new_item), syn::Item::Union(old_item)) => old_item != new_item,
|
||||
(syn::Item::Use(new_item), syn::Item::Use(old_item)) => old_item != new_item,
|
||||
(syn::Item::Verbatim(_), syn::Item::Verbatim(_)) => false,
|
||||
_ => return true,
|
||||
}
|
||||
}
|
||||
|
||||
fn find_rsx_trait(
|
||||
new_item: &syn::ItemTrait,
|
||||
old_item: &syn::ItemTrait,
|
||||
rsx_calls: &mut Vec<(Macro, TokenStream)>,
|
||||
) -> bool {
|
||||
if new_item.items.len() != old_item.items.len() {
|
||||
return true;
|
||||
}
|
||||
for (new_item, old_item) in new_item.items.iter().zip(old_item.items.iter()) {
|
||||
if match (new_item, old_item) {
|
||||
(syn::TraitItem::Const(new_item), syn::TraitItem::Const(old_item)) => {
|
||||
if let (Some((_, new_expr)), Some((_, old_expr))) =
|
||||
(&new_item.default, &old_item.default)
|
||||
{
|
||||
find_rsx_expr(new_expr, old_expr, rsx_calls)
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
||||
(syn::TraitItem::Method(new_item), syn::TraitItem::Method(old_item)) => {
|
||||
if let (Some(new_block), Some(old_block)) = (&new_item.default, &old_item.default) {
|
||||
find_rsx_block(new_block, old_block, rsx_calls)
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
||||
(syn::TraitItem::Type(new_item), syn::TraitItem::Type(old_item)) => {
|
||||
old_item != new_item
|
||||
}
|
||||
(syn::TraitItem::Macro(new_item), syn::TraitItem::Macro(old_item)) => {
|
||||
old_item != new_item
|
||||
}
|
||||
_ => true,
|
||||
} {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
new_item.attrs != old_item.attrs
|
||||
|| new_item.vis != old_item.vis
|
||||
|| new_item.unsafety != old_item.unsafety
|
||||
|| new_item.auto_token != old_item.auto_token
|
||||
|| new_item.ident != old_item.ident
|
||||
|| new_item.generics != old_item.generics
|
||||
|| new_item.colon_token != old_item.colon_token
|
||||
|| new_item.supertraits != old_item.supertraits
|
||||
|| new_item.brace_token != old_item.brace_token
|
||||
}
|
||||
|
||||
fn find_rsx_block(
|
||||
new_block: &syn::Block,
|
||||
old_block: &syn::Block,
|
||||
rsx_calls: &mut Vec<(Macro, TokenStream)>,
|
||||
) -> bool {
|
||||
if new_block.stmts.len() != old_block.stmts.len() {
|
||||
return true;
|
||||
}
|
||||
for (new_stmt, old_stmt) in new_block.stmts.iter().zip(old_block.stmts.iter()) {
|
||||
if find_rsx_stmt(new_stmt, old_stmt, rsx_calls) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
new_block.brace_token != old_block.brace_token
|
||||
}
|
||||
|
||||
fn find_rsx_stmt(
|
||||
new_stmt: &syn::Stmt,
|
||||
old_stmt: &syn::Stmt,
|
||||
rsx_calls: &mut Vec<(Macro, TokenStream)>,
|
||||
) -> bool {
|
||||
match (new_stmt, old_stmt) {
|
||||
(syn::Stmt::Local(new_local), syn::Stmt::Local(old_local)) => {
|
||||
(match (&new_local.init, &old_local.init) {
|
||||
(Some((new_eq, new_expr)), Some((old_eq, old_expr))) => {
|
||||
find_rsx_expr(new_expr, old_expr, rsx_calls) || new_eq != old_eq
|
||||
}
|
||||
(None, None) => false,
|
||||
_ => true,
|
||||
} || new_local.attrs != old_local.attrs
|
||||
|| new_local.let_token != old_local.let_token
|
||||
|| new_local.pat != old_local.pat
|
||||
|| new_local.semi_token != old_local.semi_token)
|
||||
}
|
||||
(syn::Stmt::Item(new_item), syn::Stmt::Item(old_item)) => {
|
||||
find_rsx_item(new_item, old_item, rsx_calls)
|
||||
}
|
||||
(syn::Stmt::Expr(new_expr), syn::Stmt::Expr(old_expr)) => {
|
||||
find_rsx_expr(new_expr, old_expr, rsx_calls)
|
||||
}
|
||||
(syn::Stmt::Semi(new_expr, new_semi), syn::Stmt::Semi(old_expr, old_semi)) => {
|
||||
find_rsx_expr(new_expr, old_expr, rsx_calls) || new_semi != old_semi
|
||||
}
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
||||
fn find_rsx_expr(
|
||||
new_expr: &syn::Expr,
|
||||
old_expr: &syn::Expr,
|
||||
rsx_calls: &mut Vec<(Macro, TokenStream)>,
|
||||
) -> bool {
|
||||
match (new_expr, old_expr) {
|
||||
(syn::Expr::Array(new_expr), syn::Expr::Array(old_expr)) => {
|
||||
if new_expr.elems.len() != old_expr.elems.len() {
|
||||
return true;
|
||||
}
|
||||
for (new_el, old_el) in new_expr.elems.iter().zip(old_expr.elems.iter()) {
|
||||
if find_rsx_expr(new_el, old_el, rsx_calls) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
new_expr.attrs != old_expr.attrs || new_expr.bracket_token != old_expr.bracket_token
|
||||
}
|
||||
(syn::Expr::Assign(new_expr), syn::Expr::Assign(old_expr)) => {
|
||||
find_rsx_expr(&new_expr.left, &old_expr.left, rsx_calls)
|
||||
|| find_rsx_expr(&new_expr.right, &old_expr.right, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.eq_token != old_expr.eq_token
|
||||
}
|
||||
(syn::Expr::AssignOp(new_expr), syn::Expr::AssignOp(old_expr)) => {
|
||||
find_rsx_expr(&new_expr.left, &old_expr.left, rsx_calls)
|
||||
|| find_rsx_expr(&new_expr.right, &old_expr.right, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.op != old_expr.op
|
||||
}
|
||||
(syn::Expr::Async(new_expr), syn::Expr::Async(old_expr)) => {
|
||||
find_rsx_block(&new_expr.block, &old_expr.block, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.async_token != old_expr.async_token
|
||||
|| new_expr.capture != old_expr.capture
|
||||
}
|
||||
(syn::Expr::Await(new_expr), syn::Expr::Await(old_expr)) => {
|
||||
find_rsx_expr(&new_expr.base, &old_expr.base, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.dot_token != old_expr.dot_token
|
||||
|| new_expr.await_token != old_expr.await_token
|
||||
}
|
||||
(syn::Expr::Binary(new_expr), syn::Expr::Binary(old_expr)) => {
|
||||
find_rsx_expr(&new_expr.left, &old_expr.left, rsx_calls)
|
||||
|| find_rsx_expr(&new_expr.right, &old_expr.right, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.op != old_expr.op
|
||||
}
|
||||
(syn::Expr::Block(new_expr), syn::Expr::Block(old_expr)) => {
|
||||
find_rsx_block(&new_expr.block, &old_expr.block, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.label != old_expr.label
|
||||
}
|
||||
(syn::Expr::Box(new_expr), syn::Expr::Box(old_expr)) => {
|
||||
find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.box_token != old_expr.box_token
|
||||
}
|
||||
(syn::Expr::Break(new_expr), syn::Expr::Break(old_expr)) => {
|
||||
match (&new_expr.expr, &old_expr.expr) {
|
||||
(Some(new_inner), Some(old_inner)) => {
|
||||
find_rsx_expr(new_inner, old_inner, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.break_token != old_expr.break_token
|
||||
|| new_expr.label != old_expr.label
|
||||
}
|
||||
(None, None) => {
|
||||
new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.break_token != old_expr.break_token
|
||||
|| new_expr.label != old_expr.label
|
||||
}
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
(syn::Expr::Call(new_expr), syn::Expr::Call(old_expr)) => {
|
||||
find_rsx_expr(&new_expr.func, &old_expr.func, rsx_calls);
|
||||
if new_expr.args.len() != old_expr.args.len() {
|
||||
return true;
|
||||
}
|
||||
for (new_arg, old_arg) in new_expr.args.iter().zip(old_expr.args.iter()) {
|
||||
if find_rsx_expr(new_arg, old_arg, rsx_calls) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
new_expr.attrs != old_expr.attrs || new_expr.paren_token != old_expr.paren_token
|
||||
}
|
||||
(syn::Expr::Cast(new_expr), syn::Expr::Cast(old_expr)) => {
|
||||
find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.as_token != old_expr.as_token
|
||||
|| new_expr.ty != old_expr.ty
|
||||
}
|
||||
(syn::Expr::Closure(new_expr), syn::Expr::Closure(old_expr)) => {
|
||||
find_rsx_expr(&new_expr.body, &old_expr.body, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.movability != old_expr.movability
|
||||
|| new_expr.asyncness != old_expr.asyncness
|
||||
|| new_expr.capture != old_expr.capture
|
||||
|| new_expr.or1_token != old_expr.or1_token
|
||||
|| new_expr.inputs != old_expr.inputs
|
||||
|| new_expr.or2_token != old_expr.or2_token
|
||||
|| new_expr.output != old_expr.output
|
||||
}
|
||||
(syn::Expr::Continue(new_expr), syn::Expr::Continue(old_expr)) => old_expr != new_expr,
|
||||
(syn::Expr::Field(new_expr), syn::Expr::Field(old_expr)) => {
|
||||
find_rsx_expr(&new_expr.base, &old_expr.base, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.dot_token != old_expr.dot_token
|
||||
|| new_expr.member != old_expr.member
|
||||
}
|
||||
(syn::Expr::ForLoop(new_expr), syn::Expr::ForLoop(old_expr)) => {
|
||||
find_rsx_block(&new_expr.body, &old_expr.body, rsx_calls)
|
||||
|| find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.label != old_expr.label
|
||||
|| new_expr.for_token != old_expr.for_token
|
||||
|| new_expr.pat != old_expr.pat
|
||||
|| new_expr.in_token != old_expr.in_token
|
||||
}
|
||||
(syn::Expr::Group(new_expr), syn::Expr::Group(old_expr)) => {
|
||||
find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls)
|
||||
}
|
||||
(syn::Expr::If(new_expr), syn::Expr::If(old_expr)) => {
|
||||
if find_rsx_expr(&new_expr.cond, &old_expr.cond, rsx_calls)
|
||||
|| find_rsx_block(&new_expr.then_branch, &old_expr.then_branch, rsx_calls)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
match (&new_expr.else_branch, &old_expr.else_branch) {
|
||||
(Some((new_tok, new_else)), Some((old_tok, old_else))) => {
|
||||
find_rsx_expr(new_else, old_else, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.if_token != old_expr.if_token
|
||||
|| new_expr.cond != old_expr.cond
|
||||
|| new_tok != old_tok
|
||||
}
|
||||
(None, None) => {
|
||||
new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.if_token != old_expr.if_token
|
||||
|| new_expr.cond != old_expr.cond
|
||||
}
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
(syn::Expr::Index(new_expr), syn::Expr::Index(old_expr)) => {
|
||||
find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls)
|
||||
|| find_rsx_expr(&new_expr.index, &old_expr.index, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.bracket_token != old_expr.bracket_token
|
||||
}
|
||||
(syn::Expr::Let(new_expr), syn::Expr::Let(old_expr)) => {
|
||||
find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.let_token != old_expr.let_token
|
||||
|| new_expr.pat != old_expr.pat
|
||||
|| new_expr.eq_token != old_expr.eq_token
|
||||
}
|
||||
(syn::Expr::Lit(new_expr), syn::Expr::Lit(old_expr)) => old_expr != new_expr,
|
||||
(syn::Expr::Loop(new_expr), syn::Expr::Loop(old_expr)) => {
|
||||
find_rsx_block(&new_expr.body, &old_expr.body, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.label != old_expr.label
|
||||
|| new_expr.loop_token != old_expr.loop_token
|
||||
}
|
||||
(syn::Expr::Macro(new_expr), syn::Expr::Macro(old_expr)) => {
|
||||
let new_mac = &new_expr.mac;
|
||||
let old_mac = &old_expr.mac;
|
||||
if new_mac.path.get_ident().map(|ident| ident.to_string()) == Some("rsx".to_string())
|
||||
&& old_mac.path.get_ident().map(|ident| ident.to_string())
|
||||
== Some("rsx".to_string())
|
||||
{
|
||||
rsx_calls.push((old_mac.clone(), new_mac.tokens.clone()));
|
||||
false
|
||||
} else {
|
||||
new_expr != old_expr
|
||||
}
|
||||
}
|
||||
(syn::Expr::Match(new_expr), syn::Expr::Match(old_expr)) => {
|
||||
if find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls) {
|
||||
return true;
|
||||
}
|
||||
for (new_arm, old_arm) in new_expr.arms.iter().zip(old_expr.arms.iter()) {
|
||||
match (&new_arm.guard, &old_arm.guard) {
|
||||
(Some((new_tok, new_expr)), Some((old_tok, old_expr))) => {
|
||||
if find_rsx_expr(new_expr, old_expr, rsx_calls) || new_tok != old_tok {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
(None, None) => (),
|
||||
_ => return true,
|
||||
}
|
||||
if find_rsx_expr(&new_arm.body, &old_arm.body, rsx_calls)
|
||||
|| new_arm.attrs != old_arm.attrs
|
||||
|| new_arm.pat != old_arm.pat
|
||||
|| new_arm.fat_arrow_token != old_arm.fat_arrow_token
|
||||
|| new_arm.comma != old_arm.comma
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.match_token != old_expr.match_token
|
||||
|| new_expr.brace_token != old_expr.brace_token
|
||||
}
|
||||
(syn::Expr::MethodCall(new_expr), syn::Expr::MethodCall(old_expr)) => {
|
||||
if find_rsx_expr(&new_expr.receiver, &old_expr.receiver, rsx_calls) {
|
||||
return true;
|
||||
}
|
||||
for (new_arg, old_arg) in new_expr.args.iter().zip(old_expr.args.iter()) {
|
||||
if find_rsx_expr(new_arg, old_arg, rsx_calls) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.dot_token != old_expr.dot_token
|
||||
|| new_expr.method != old_expr.method
|
||||
|| new_expr.turbofish != old_expr.turbofish
|
||||
|| new_expr.paren_token != old_expr.paren_token
|
||||
}
|
||||
(syn::Expr::Paren(new_expr), syn::Expr::Paren(old_expr)) => {
|
||||
find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.paren_token != old_expr.paren_token
|
||||
}
|
||||
(syn::Expr::Path(new_expr), syn::Expr::Path(old_expr)) => old_expr != new_expr,
|
||||
(syn::Expr::Range(new_expr), syn::Expr::Range(old_expr)) => {
|
||||
match (&new_expr.from, &old_expr.from) {
|
||||
(Some(new_expr), Some(old_expr)) => {
|
||||
if find_rsx_expr(new_expr, old_expr, rsx_calls) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
(None, None) => (),
|
||||
_ => return true,
|
||||
}
|
||||
match (&new_expr.to, &old_expr.to) {
|
||||
(Some(new_inner), Some(old_inner)) => {
|
||||
find_rsx_expr(new_inner, old_inner, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.limits != old_expr.limits
|
||||
}
|
||||
(None, None) => {
|
||||
new_expr.attrs != old_expr.attrs || new_expr.limits != old_expr.limits
|
||||
}
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
(syn::Expr::Reference(new_expr), syn::Expr::Reference(old_expr)) => {
|
||||
find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.and_token != old_expr.and_token
|
||||
|| new_expr.mutability != old_expr.mutability
|
||||
}
|
||||
(syn::Expr::Repeat(new_expr), syn::Expr::Repeat(old_expr)) => {
|
||||
find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls)
|
||||
|| find_rsx_expr(&new_expr.len, &old_expr.len, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.bracket_token != old_expr.bracket_token
|
||||
|| new_expr.semi_token != old_expr.semi_token
|
||||
}
|
||||
(syn::Expr::Return(new_expr), syn::Expr::Return(old_expr)) => {
|
||||
match (&new_expr.expr, &old_expr.expr) {
|
||||
(Some(new_inner), Some(old_inner)) => {
|
||||
find_rsx_expr(new_inner, old_inner, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.return_token != old_expr.return_token
|
||||
}
|
||||
(None, None) => {
|
||||
new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.return_token != old_expr.return_token
|
||||
}
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
(syn::Expr::Struct(new_expr), syn::Expr::Struct(old_expr)) => {
|
||||
match (&new_expr.rest, &old_expr.rest) {
|
||||
(Some(new_expr), Some(old_expr)) => {
|
||||
if find_rsx_expr(new_expr, old_expr, rsx_calls) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
(None, None) => (),
|
||||
_ => return true,
|
||||
}
|
||||
for (new_field, old_field) in new_expr.fields.iter().zip(old_expr.fields.iter()) {
|
||||
if find_rsx_expr(&new_field.expr, &old_field.expr, rsx_calls)
|
||||
|| new_field.attrs != old_field.attrs
|
||||
|| new_field.member != old_field.member
|
||||
|| new_field.colon_token != old_field.colon_token
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.path != old_expr.path
|
||||
|| new_expr.brace_token != old_expr.brace_token
|
||||
|| new_expr.dot2_token != old_expr.dot2_token
|
||||
}
|
||||
(syn::Expr::Try(new_expr), syn::Expr::Try(old_expr)) => {
|
||||
find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.question_token != old_expr.question_token
|
||||
}
|
||||
(syn::Expr::TryBlock(new_expr), syn::Expr::TryBlock(old_expr)) => {
|
||||
find_rsx_block(&new_expr.block, &old_expr.block, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.try_token != old_expr.try_token
|
||||
}
|
||||
(syn::Expr::Tuple(new_expr), syn::Expr::Tuple(old_expr)) => {
|
||||
for (new_el, old_el) in new_expr.elems.iter().zip(old_expr.elems.iter()) {
|
||||
if find_rsx_expr(new_el, old_el, rsx_calls) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
new_expr.attrs != old_expr.attrs || new_expr.paren_token != old_expr.paren_token
|
||||
}
|
||||
(syn::Expr::Type(new_expr), syn::Expr::Type(old_expr)) => {
|
||||
find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.colon_token != old_expr.colon_token
|
||||
|| new_expr.ty != old_expr.ty
|
||||
}
|
||||
(syn::Expr::Unary(new_expr), syn::Expr::Unary(old_expr)) => {
|
||||
find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.op != old_expr.op
|
||||
}
|
||||
(syn::Expr::Unsafe(new_expr), syn::Expr::Unsafe(old_expr)) => {
|
||||
find_rsx_block(&new_expr.block, &old_expr.block, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.unsafe_token != old_expr.unsafe_token
|
||||
}
|
||||
(syn::Expr::While(new_expr), syn::Expr::While(old_expr)) => {
|
||||
find_rsx_expr(&new_expr.cond, &old_expr.cond, rsx_calls)
|
||||
|| find_rsx_block(&new_expr.body, &old_expr.body, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.label != old_expr.label
|
||||
|| new_expr.while_token != old_expr.while_token
|
||||
}
|
||||
(syn::Expr::Yield(new_expr), syn::Expr::Yield(old_expr)) => {
|
||||
match (&new_expr.expr, &old_expr.expr) {
|
||||
(Some(new_inner), Some(old_inner)) => {
|
||||
find_rsx_expr(new_inner, old_inner, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
|| new_expr.yield_token != old_expr.yield_token
|
||||
}
|
||||
(None, None) => {
|
||||
new_expr.attrs != old_expr.attrs || new_expr.yield_token != old_expr.yield_token
|
||||
}
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
(syn::Expr::Verbatim(_), syn::Expr::Verbatim(_)) => false,
|
||||
_ => true,
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
pub const DIOXUS_CLI_VERSION: &'static str = "0.1.5";
|
||||
pub const DIOXUS_CLI_VERSION: &str = "0.1.5";
|
||||
|
||||
pub mod builder;
|
||||
pub mod server;
|
||||
|
@ -21,5 +21,4 @@ pub use error::*;
|
|||
pub mod logging;
|
||||
pub use logging::*;
|
||||
|
||||
pub mod hot_reload;
|
||||
pub mod plugin;
|
|
@ -1,184 +0,0 @@
|
|||
use axum::{
|
||||
extract::{ws::Message, Extension, TypedHeader, WebSocketUpgrade},
|
||||
response::IntoResponse,
|
||||
};
|
||||
// use dioxus_rsx::try_parse_template;
|
||||
|
||||
use std::{path::PathBuf, sync::Arc};
|
||||
|
||||
use super::BuildManager;
|
||||
pub use crate::hot_reload::{find_rsx, DiffResult};
|
||||
use crate::CrateConfig;
|
||||
pub use proc_macro2::TokenStream;
|
||||
pub use std::collections::HashMap;
|
||||
pub use std::sync::Mutex;
|
||||
pub use std::time::SystemTime;
|
||||
pub use std::{fs, io, path::Path};
|
||||
pub use std::{fs::File, io::Read};
|
||||
pub use syn::__private::ToTokens;
|
||||
use syn::spanned::Spanned;
|
||||
use tokio::sync::broadcast;
|
||||
|
||||
pub struct HotReloadState {
|
||||
pub messages: broadcast::Sender<String>,
|
||||
pub build_manager: Arc<BuildManager>,
|
||||
pub last_file_rebuild: Arc<Mutex<FileMap>>,
|
||||
pub watcher_config: CrateConfig,
|
||||
}
|
||||
|
||||
pub struct FileMap {
|
||||
pub map: HashMap<PathBuf, String>,
|
||||
pub last_updated_time: std::time::SystemTime,
|
||||
}
|
||||
|
||||
impl FileMap {
|
||||
pub fn new(path: PathBuf) -> Self {
|
||||
log::info!("🔮 Searching files for changes since last compile...");
|
||||
fn find_rs_files(root: PathBuf) -> io::Result<HashMap<PathBuf, String>> {
|
||||
let mut files = HashMap::new();
|
||||
if root.is_dir() {
|
||||
for entry in fs::read_dir(root)? {
|
||||
if let Ok(entry) = entry {
|
||||
let path = entry.path();
|
||||
files.extend(find_rs_files(path)?);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if root.extension().map(|s| s.to_str()).flatten() == Some("rs") {
|
||||
if let Ok(mut file) = File::open(root.clone()) {
|
||||
let mut src = String::new();
|
||||
file.read_to_string(&mut src).expect("Unable to read file");
|
||||
files.insert(root, src);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(files)
|
||||
}
|
||||
|
||||
let last_updated_time = SystemTime::now();
|
||||
let result = Self {
|
||||
last_updated_time,
|
||||
map: find_rs_files(path).unwrap(),
|
||||
};
|
||||
// log::info!("Files updated");
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn hot_reload_handler(
|
||||
ws: WebSocketUpgrade,
|
||||
_: Option<TypedHeader<headers::UserAgent>>,
|
||||
Extension(state): Extension<Arc<HotReloadState>>,
|
||||
) -> impl IntoResponse {
|
||||
ws.on_upgrade(|mut socket| async move {
|
||||
log::info!("🔥 Hot Reload WebSocket connected");
|
||||
{
|
||||
// update any rsx calls that changed before the websocket connected.
|
||||
// let mut messages = Vec::new();
|
||||
|
||||
{
|
||||
log::info!("🔮 Finding updates since last compile...");
|
||||
let handle = state.last_file_rebuild.lock().unwrap();
|
||||
let update_time = handle.last_updated_time.clone();
|
||||
for (k, v) in handle.map.iter() {
|
||||
let mut file = File::open(k).unwrap();
|
||||
if let Ok(md) = file.metadata() {
|
||||
if let Ok(time) = md.modified() {
|
||||
if time < update_time {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut new_str = String::new();
|
||||
file.read_to_string(&mut new_str)
|
||||
.expect("Unable to read file");
|
||||
if let Ok(new_file) = syn::parse_file(&new_str) {
|
||||
if let Ok(old_file) = syn::parse_file(&v) {
|
||||
if let DiffResult::RsxChanged(changed) = find_rsx(&new_file, &old_file)
|
||||
{
|
||||
for (old, new) in changed.into_iter() {
|
||||
// let hr = get_location(
|
||||
// &state.watcher_config.crate_dir,
|
||||
// k,
|
||||
// old.to_token_stream(),
|
||||
// );
|
||||
// get the original source code to preserve whitespace
|
||||
let span = new.span();
|
||||
let start = span.start();
|
||||
let end = span.end();
|
||||
let mut lines: Vec<_> = new_str
|
||||
.lines()
|
||||
.skip(start.line - 1)
|
||||
.take(end.line - start.line + 1)
|
||||
.collect();
|
||||
if let Some(first) = lines.first_mut() {
|
||||
*first = first.split_at(start.column).1;
|
||||
}
|
||||
if let Some(last) = lines.last_mut() {
|
||||
// if there is only one line the start index of last line will be the start of the rsx!, not the start of the line
|
||||
if start.line == end.line {
|
||||
*last = last.split_at(end.column - start.column).0;
|
||||
} else {
|
||||
*last = last.split_at(end.column).0;
|
||||
}
|
||||
}
|
||||
let rsx = lines.join("\n");
|
||||
|
||||
// let old_dyn_ctx = try_parse_template(
|
||||
// &format!("{}", old.tokens),
|
||||
// hr.to_owned(),
|
||||
// None,
|
||||
// )
|
||||
// .map(|(_, old_dyn_ctx)| old_dyn_ctx);
|
||||
// if let Ok((template, _)) =
|
||||
// try_parse_template(&rsx, hr.to_owned(), old_dyn_ctx.ok())
|
||||
// {
|
||||
// // messages.push(SetTemplateMsg(TemplateId(hr), template));
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// for msg in messages {
|
||||
// if socket
|
||||
// .send(Message::Text(serde_json::to_string(&msg).unwrap()))
|
||||
// .await
|
||||
// .is_err()
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
log::info!("finished");
|
||||
}
|
||||
|
||||
let mut rx = state.messages.subscribe();
|
||||
let hot_reload_handle = tokio::spawn(async move {
|
||||
loop {
|
||||
if let Ok(rsx) = rx.recv().await {
|
||||
if socket
|
||||
.send(Message::Text(serde_json::to_string(&rsx).unwrap()))
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
hot_reload_handle.await.unwrap();
|
||||
})
|
||||
}
|
||||
|
||||
// pub fn get_location(crate_path: &Path, path: &Path, ts: TokenStream) -> CodeLocation {
|
||||
// let span = ts.span().start();
|
||||
// let relative = path.strip_prefix(crate_path).unwrap();
|
||||
// CodeLocation::Dynamic(Box::new(OwnedCodeLocation {
|
||||
// file_path: relative.display().to_string(),
|
||||
// crate_path: crate_path.display().to_string(),
|
||||
// line: span.line as u32,
|
||||
// column: span.column as u32 + 1,
|
||||
// }))
|
||||
// }
|
|
@ -1,3 +1,4 @@
|
|||
use crate::{builder, plugin::PluginManager, serve::Serve, BuildResult, CrateConfig, Result};
|
||||
use axum::{
|
||||
body::{Full, HttpBody},
|
||||
extract::{ws::Message, Extension, TypedHeader, WebSocketUpgrade},
|
||||
|
@ -8,20 +9,20 @@ use axum::{
|
|||
};
|
||||
use cargo_metadata::diagnostic::Diagnostic;
|
||||
use colored::Colorize;
|
||||
// use dioxus_rsx::try_parse_template;
|
||||
use dioxus_core::Template;
|
||||
use dioxus_html::HtmlCtx;
|
||||
use dioxus_rsx::hot_reload::*;
|
||||
use notify::{RecommendedWatcher, Watcher};
|
||||
use syn::spanned::Spanned;
|
||||
|
||||
use std::{net::UdpSocket, path::PathBuf, process::Command, sync::Arc};
|
||||
use std::{
|
||||
net::UdpSocket,
|
||||
path::PathBuf,
|
||||
process::Command,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
use tokio::sync::broadcast;
|
||||
use tower::ServiceBuilder;
|
||||
use tower_http::services::fs::{ServeDir, ServeFileSystemResponseBody};
|
||||
|
||||
use crate::{builder, plugin::PluginManager, serve::Serve, BuildResult, CrateConfig, Result};
|
||||
use tokio::sync::broadcast;
|
||||
|
||||
mod hot_reload;
|
||||
use hot_reload::*;
|
||||
|
||||
pub struct BuildManager {
|
||||
config: CrateConfig,
|
||||
reload_tx: broadcast::Sender<()>,
|
||||
|
@ -68,6 +69,62 @@ pub async fn startup(port: u16, config: CrateConfig) -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub struct HotReloadState {
|
||||
pub messages: broadcast::Sender<Template<'static>>,
|
||||
pub build_manager: Arc<BuildManager>,
|
||||
pub file_map: Arc<Mutex<FileMap<HtmlCtx>>>,
|
||||
pub watcher_config: CrateConfig,
|
||||
}
|
||||
|
||||
pub async fn hot_reload_handler(
|
||||
ws: WebSocketUpgrade,
|
||||
_: Option<TypedHeader<headers::UserAgent>>,
|
||||
Extension(state): Extension<Arc<HotReloadState>>,
|
||||
) -> impl IntoResponse {
|
||||
ws.on_upgrade(|mut socket| async move {
|
||||
log::info!("🔥 Hot Reload WebSocket connected");
|
||||
{
|
||||
// update any rsx calls that changed before the websocket connected.
|
||||
{
|
||||
log::info!("🔮 Finding updates since last compile...");
|
||||
let templates: Vec<_> = {
|
||||
state
|
||||
.file_map
|
||||
.lock()
|
||||
.unwrap()
|
||||
.map
|
||||
.values()
|
||||
.filter_map(|(_, template_slot)| *template_slot)
|
||||
.collect()
|
||||
};
|
||||
for template in templates {
|
||||
if socket
|
||||
.send(Message::Text(serde_json::to_string(&template).unwrap()))
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
log::info!("finished");
|
||||
}
|
||||
|
||||
let mut rx = state.messages.subscribe();
|
||||
loop {
|
||||
if let Ok(rsx) = rx.recv().await {
|
||||
if socket
|
||||
.send(Message::Text(serde_json::to_string(&rsx).unwrap()))
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(unused_assignments)]
|
||||
pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> {
|
||||
let first_build_result = crate::builder::build(&config, false)?;
|
||||
|
@ -78,7 +135,9 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> {
|
|||
|
||||
let dist_path = config.out_dir.clone();
|
||||
let (reload_tx, _) = broadcast::channel(100);
|
||||
let last_file_rebuild = Arc::new(Mutex::new(FileMap::new(config.crate_dir.clone())));
|
||||
let file_map = Arc::new(Mutex::new(FileMap::<HtmlCtx>::new(
|
||||
config.crate_dir.clone(),
|
||||
)));
|
||||
let build_manager = Arc::new(BuildManager {
|
||||
config: config.clone(),
|
||||
reload_tx: reload_tx.clone(),
|
||||
|
@ -87,7 +146,7 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> {
|
|||
let hot_reload_state = Arc::new(HotReloadState {
|
||||
messages: hot_reload_tx.clone(),
|
||||
build_manager: build_manager.clone(),
|
||||
last_file_rebuild: last_file_rebuild.clone(),
|
||||
file_map: file_map.clone(),
|
||||
watcher_config: config.clone(),
|
||||
});
|
||||
|
||||
|
@ -96,8 +155,6 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> {
|
|||
update: reload_tx.clone(),
|
||||
});
|
||||
|
||||
let mut last_update_time = chrono::Local::now().timestamp();
|
||||
|
||||
// file watcher: check file change
|
||||
let allow_watch_path = config
|
||||
.dioxus_config
|
||||
|
@ -108,95 +165,28 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> {
|
|||
.unwrap_or_else(|| vec![PathBuf::from("src")]);
|
||||
|
||||
let watcher_config = config.clone();
|
||||
let mut last_update_time = chrono::Local::now().timestamp();
|
||||
|
||||
let mut watcher = RecommendedWatcher::new(
|
||||
move |evt: notify::Result<notify::Event>| {
|
||||
let config = watcher_config.clone();
|
||||
if chrono::Local::now().timestamp() > last_update_time {
|
||||
// Give time for the change to take effect before reading the file
|
||||
std::thread::sleep(std::time::Duration::from_millis(100));
|
||||
let mut updated = false;
|
||||
if chrono::Local::now().timestamp() > last_update_time {
|
||||
if let Ok(evt) = evt {
|
||||
let mut messages = Vec::new();
|
||||
let mut needs_rebuild = false;
|
||||
let mut messages: Vec<Template<'static>> = Vec::new();
|
||||
for path in evt.paths.clone() {
|
||||
if path.extension().map(|p| p.to_str()).flatten() != Some("rs") {
|
||||
if path.extension().and_then(|p| p.to_str()) != Some("rs") {
|
||||
continue;
|
||||
}
|
||||
let mut file = File::open(path.clone()).unwrap();
|
||||
let mut src = String::new();
|
||||
file.read_to_string(&mut src).expect("Unable to read file");
|
||||
// find changes to the rsx in the file
|
||||
if let Ok(syntax) = syn::parse_file(&src) {
|
||||
let mut last_file_rebuild = last_file_rebuild.lock().unwrap();
|
||||
if let Some(old_str) = last_file_rebuild.map.get(&path) {
|
||||
if let Ok(old) = syn::parse_file(&old_str) {
|
||||
updated = true;
|
||||
match find_rsx(&syntax, &old) {
|
||||
DiffResult::CodeChanged => {
|
||||
needs_rebuild = true;
|
||||
last_file_rebuild.map.insert(path, src);
|
||||
}
|
||||
DiffResult::RsxChanged(changed) => {
|
||||
log::info!("🪁 reloading rsx");
|
||||
// for (old, new) in changed.into_iter() {
|
||||
// let hr = get_location(
|
||||
// &crate_dir,
|
||||
// &path.to_path_buf(),
|
||||
// old.to_token_stream(),
|
||||
// );
|
||||
// // get the original source code to preserve whitespace
|
||||
// let span = new.span();
|
||||
// let start = span.start();
|
||||
// let end = span.end();
|
||||
// let mut lines: Vec<_> = src
|
||||
// .lines()
|
||||
// .skip(start.line - 1)
|
||||
// .take(end.line - start.line + 1)
|
||||
// .collect();
|
||||
// if let Some(first) = lines.first_mut() {
|
||||
// *first = first.split_at(start.column).1;
|
||||
// }
|
||||
// if let Some(last) = lines.last_mut() {
|
||||
// // if there is only one line the start index of last line will be the start of the rsx!, not the start of the line
|
||||
// if start.line == end.line {
|
||||
// *last = last
|
||||
// .split_at(end.column - start.column)
|
||||
// .0;
|
||||
// } else {
|
||||
// *last = last.split_at(end.column).0;
|
||||
// }
|
||||
// }
|
||||
// let rsx = lines.join("\n");
|
||||
let mut map = file_map.lock().unwrap();
|
||||
|
||||
// let old_dyn_ctx = try_parse_template(
|
||||
// &format!("{}", old.tokens),
|
||||
// hr.to_owned(),
|
||||
// None,
|
||||
// )
|
||||
// .map(|(_, old_dyn_ctx)| old_dyn_ctx);
|
||||
// // if let Ok((template, _)) = try_parse_template(
|
||||
// // &rsx,
|
||||
// // hr.to_owned(),
|
||||
// // old_dyn_ctx.ok(),
|
||||
// // ) {
|
||||
// // messages.push(SetTemplateMsg(
|
||||
// // TemplateId(hr),
|
||||
// // template,
|
||||
// // ));
|
||||
// // } else {
|
||||
// // needs_rebuild = true;
|
||||
// // }
|
||||
// }
|
||||
match map.update_rsx(&path, &crate_dir) {
|
||||
UpdateResult::UpdatedRsx(msgs) => {
|
||||
messages.extend(msgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// if this is a new file, rebuild the project
|
||||
*last_file_rebuild = FileMap::new(crate_dir.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
if needs_rebuild {
|
||||
UpdateResult::NeedsRebuild => {
|
||||
match build_manager.rebuild() {
|
||||
Ok(res) => {
|
||||
print_console_info(
|
||||
|
@ -213,15 +203,16 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> {
|
|||
log::error!("{}", err);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
for msg in messages {
|
||||
let _ = hot_reload_tx.send(msg);
|
||||
}
|
||||
}
|
||||
if updated {
|
||||
last_update_time = chrono::Local::now().timestamp();
|
||||
}
|
||||
}
|
||||
},
|
||||
notify::Config::default(),
|
||||
)
|
||||
|
@ -282,7 +273,7 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> {
|
|||
Ok(response)
|
||||
},
|
||||
)
|
||||
.service(ServeDir::new((&config.crate_dir).join(&dist_path)));
|
||||
.service(ServeDir::new(config.crate_dir.join(&dist_path)));
|
||||
|
||||
let router = Router::new()
|
||||
.route("/_dioxus/ws", get(ws_handler))
|
||||
|
@ -422,7 +413,7 @@ pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> {
|
|||
Ok(response)
|
||||
},
|
||||
)
|
||||
.service(ServeDir::new((&config.crate_dir).join(&dist_path)));
|
||||
.service(ServeDir::new(config.crate_dir.join(&dist_path)));
|
||||
|
||||
let router = Router::new()
|
||||
.route("/_dioxus/ws", get(ws_handler))
|
||||
|
|
Loading…
Reference in a new issue