diff --git a/Cargo.lock b/Cargo.lock index 73f9a7a5..2e9b225e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,9 +34,9 @@ checksum = "4aa90d7ce82d4be67b64039a3d588d38dbcc6736577de4a847025ce5b0c468d1" [[package]] name = "allocator-api2" -version = "0.2.20" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "android-tzdata" @@ -135,7 +135,7 @@ checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn", ] [[package]] @@ -306,9 +306,9 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" [[package]] name = "bytes" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" [[package]] name = "cassowary" @@ -327,9 +327,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" +checksum = "f34d93e62b03caf570cccc334cbc6c2fceca82f39211051345108adcba3eebdc" dependencies = [ "jobserver", "libc", @@ -424,7 +424,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.89", + "syn", ] [[package]] @@ -603,7 +603,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.89", + "syn", ] [[package]] @@ -614,7 +614,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.89", + "syn", ] [[package]] @@ -644,7 +644,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.89", + "syn", ] [[package]] @@ -654,7 +654,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.89", + "syn", ] [[package]] @@ -702,7 +702,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn", ] [[package]] @@ -735,12 +735,12 @@ dependencies = [ [[package]] name = "errno" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -913,7 +913,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn", ] [[package]] @@ -1023,12 +1023,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" - [[package]] name = "home" version = "0.5.9" @@ -1176,7 +1170,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn", ] [[package]] @@ -1245,9 +1239,9 @@ checksum = "d0263a3d970d5c054ed9312c0057b4f3bde9c0b33836d3637361d4a9e6e7a408" [[package]] name = "indexmap" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" dependencies = [ "equivalent", "hashbrown", @@ -1291,7 +1285,7 @@ dependencies = [ "pretty_assertions", "proc-macro2", "quote", - "syn 2.0.89", + "syn", ] [[package]] @@ -1311,7 +1305,7 @@ checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn", ] [[package]] @@ -1355,10 +1349,11 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.72" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +checksum = "a865e038f7f6ed956f788f0d7d60c541fff74c7bd74272c5d4cf15c63743e705" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -1396,9 +1391,9 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "libc" -version = "0.2.166" +version = "0.2.167" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2ccc108bbc0b1331bd061864e7cd823c0cab660bbe6970e66e2c0614decde36" +checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" [[package]] name = "libfuzzer-sys" @@ -1538,11 +1533,10 @@ dependencies = [ [[package]] name = "mio" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ - "hermit-abi", "libc", "log", "wasi", @@ -1551,9 +1545,9 @@ dependencies = [ [[package]] name = "mlua" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ae9546e4a268c309804e8bbb7526e31cbfdedca7cd60ac1b987d0b212e0d876" +checksum = "9ea43c3ffac2d0798bd7128815212dd78c98316b299b7a902dabef13dc7b6b8d" dependencies = [ "anyhow", "bstr", @@ -1571,9 +1565,9 @@ dependencies = [ [[package]] name = "mlua-sys" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efa6bf1a64f06848749b7e7727417f4ec2121599e2a10ef0a8a3888b0e9a5a0d" +checksum = "63a11d485edf0f3f04a508615d36c7d50d299cf61a7ee6d3e2530651e0a31771" dependencies = [ "cc", "cfg-if", @@ -1584,17 +1578,17 @@ dependencies = [ [[package]] name = "mlua_derive" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cfc5faa2e0d044b3f5f0879be2920e0a711c97744c42cf1c295cb183668933e" +checksum = "870d71c172fcf491c6b5fb4c04160619a2ee3e5a42a1402269c66bcbf1dd4deb" dependencies = [ "itertools 0.13.0", "once_cell", - "proc-macro-error", + "proc-macro-error2", "proc-macro2", "quote", "regex", - "syn 2.0.89", + "syn", ] [[package]] @@ -1681,7 +1675,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn", ] [[package]] @@ -1924,30 +1918,6 @@ dependencies = [ "yansi", ] -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro-error-attr2" version = "2.0.0" @@ -1967,7 +1937,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.89", + "syn", ] [[package]] @@ -1995,7 +1965,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a65f2e60fbf1063868558d69c6beacf412dc755f9fc020f514b7955fc914fe30" dependencies = [ "quote", - "syn 2.0.89", + "syn", ] [[package]] @@ -2219,9 +2189,9 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" +checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" [[package]] name = "rustc_version" @@ -2305,7 +2275,7 @@ checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn", ] [[package]] @@ -2475,24 +2445,14 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.89", + "syn", ] [[package]] name = "syn" -version = "1.0.109" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -2507,7 +2467,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn", ] [[package]] @@ -2567,7 +2527,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn", ] [[package]] @@ -2669,7 +2629,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn", ] [[package]] @@ -2762,7 +2722,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn", ] [[package]] @@ -2788,9 +2748,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" dependencies = [ "matchers", "nu-ansi-term", @@ -2951,7 +2911,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.89", + "syn", ] [[package]] @@ -3029,9 +2989,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +checksum = "d15e63b4482863c109d70a7b8706c1e364eb6ea449b201a76c5b89cedcec2d5c" dependencies = [ "cfg-if", "once_cell", @@ -3040,24 +3000,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +checksum = "8d36ef12e3aaca16ddd3f67922bc63e48e953f126de60bd33ccc0101ef9998cd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.89", + "syn", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +checksum = "705440e08b42d3e4b36de7d66c944be628d579796b8090bfa3471478a2260051" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3065,22 +3025,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +checksum = "98c9ae5a76e46f4deecd0f0255cc223cfa18dc9b261213b8aa0c7b36f61b3f1d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +checksum = "6ee99da9c5ba11bd675621338ef6fa52296b76b83305e9b6e5c77d4c286d6d49" [[package]] name = "weezl" @@ -3170,7 +3130,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn", ] [[package]] @@ -3181,7 +3141,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn", ] [[package]] @@ -3407,6 +3367,7 @@ dependencies = [ "vergen-gitcl", "yazi-adapter", "yazi-config", + "yazi-fs", "yazi-macro", "yazi-shared", ] @@ -3428,6 +3389,7 @@ dependencies = [ "vergen-gitcl", "yazi-boot", "yazi-dds", + "yazi-fs", "yazi-macro", "yazi-shared", ] @@ -3437,7 +3399,7 @@ name = "yazi-codegen" version = "0.3.3" dependencies = [ "quote", - "syn 2.0.89", + "syn", ] [[package]] @@ -3455,6 +3417,7 @@ dependencies = [ "toml", "tracing", "validator", + "yazi-fs", "yazi-macro", "yazi-shared", ] @@ -3508,6 +3471,7 @@ dependencies = [ "uzers", "vergen-gitcl", "yazi-boot", + "yazi-fs", "yazi-macro", "yazi-shared", ] @@ -3551,12 +3515,16 @@ name = "yazi-fs" version = "0.3.3" dependencies = [ "anyhow", + "bitflags 2.6.0", + "dirs", "futures", + "libc", "regex", + "serde", "tokio", - "yazi-config", + "uzers", + "windows-sys 0.59.0", "yazi-macro", - "yazi-proxy", "yazi-shared", ] @@ -3580,7 +3548,6 @@ dependencies = [ "parking_lot", "ratatui", "serde_json", - "shell-words", "syntect", "tokio", "tokio-stream", @@ -3592,6 +3559,7 @@ dependencies = [ "yazi-boot", "yazi-config", "yazi-dds", + "yazi-fs", "yazi-macro", "yazi-prebuild", "yazi-proxy", @@ -3632,6 +3600,7 @@ dependencies = [ "trash", "yazi-config", "yazi-dds", + "yazi-fs", "yazi-macro", "yazi-plugin", "yazi-proxy", @@ -3643,15 +3612,12 @@ name = "yazi-shared" version = "0.3.3" dependencies = [ "anyhow", - "bitflags 2.6.0", "crossterm", - "dirs", "futures", "libc", "parking_lot", "percent-encoding", "ratatui", - "regex", "serde", "shell-words", "tokio", @@ -3680,7 +3646,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn", "synstructure", ] @@ -3702,7 +3668,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn", ] [[package]] @@ -3722,7 +3688,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn", "synstructure", ] @@ -3745,7 +3711,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 62404772..fdcfbbff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,9 +19,9 @@ crossterm = { version = "0.28.1", features = [ "event-stream" ] } dirs = "5.0.1" futures = "0.3.31" globset = "0.4.15" -libc = "0.2.166" +libc = "0.2.167" md-5 = "0.10.6" -mlua = { version = "0.10.1", features = [ "anyhow", "async", "error-send", "lua54", "macros", "serialize" ] } +mlua = { version = "0.10.2", features = [ "anyhow", "async", "error-send", "lua54", "macros", "serialize" ] } parking_lot = "0.12.3" ratatui = { version = "0.29.0", features = [ "unstable-rendered-line-info" ] } regex = "1.11.1" diff --git a/yazi-boot/Cargo.toml b/yazi-boot/Cargo.toml index 8c43ea28..618ad074 100644 --- a/yazi-boot/Cargo.toml +++ b/yazi-boot/Cargo.toml @@ -11,6 +11,7 @@ repository = "https://github.com/sxyazi/yazi" [dependencies] yazi-adapter = { path = "../yazi-adapter", version = "0.3.3" } yazi-config = { path = "../yazi-config", version = "0.3.3" } +yazi-fs = { path = "../yazi-fs", version = "0.3.3" } yazi-macro = { path = "../yazi-macro", version = "0.3.3" } yazi-shared = { path = "../yazi-shared", version = "0.3.3" } diff --git a/yazi-boot/src/actions/clear_cache.rs b/yazi-boot/src/actions/clear_cache.rs index 75fe43ec..2d9fd422 100644 --- a/yazi-boot/src/actions/clear_cache.rs +++ b/yazi-boot/src/actions/clear_cache.rs @@ -1,5 +1,5 @@ use yazi_config::PREVIEW; -use yazi_shared::Xdg; +use yazi_fs::Xdg; use super::Actions; diff --git a/yazi-boot/src/boot.rs b/yazi-boot/src/boot.rs index c066ced1..1f23dea8 100644 --- a/yazi-boot/src/boot.rs +++ b/yazi-boot/src/boot.rs @@ -1,7 +1,7 @@ use std::{collections::HashSet, ffi::OsString, path::PathBuf}; use serde::Serialize; -use yazi_shared::{Xdg, fs::{current_cwd, expand_path}}; +use yazi_fs::{Xdg, current_cwd, expand_path}; #[derive(Debug, Default, Serialize)] pub struct Boot { diff --git a/yazi-cli/Cargo.toml b/yazi-cli/Cargo.toml index 34c99095..127577b3 100644 --- a/yazi-cli/Cargo.toml +++ b/yazi-cli/Cargo.toml @@ -11,6 +11,7 @@ repository = "https://github.com/sxyazi/yazi" [dependencies] yazi-boot = { path = "../yazi-boot", version = "0.3.3" } yazi-dds = { path = "../yazi-dds", version = "0.3.3" } +yazi-fs = { path = "../yazi-fs", version = "0.3.3" } yazi-macro = { path = "../yazi-macro", version = "0.3.3" } yazi-shared = { path = "../yazi-shared", version = "0.3.3" } diff --git a/yazi-cli/src/package/add.rs b/yazi-cli/src/package/add.rs index c7541a46..736ecd24 100644 --- a/yazi-cli/src/package/add.rs +++ b/yazi-cli/src/package/add.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use yazi_shared::fs::must_exists; +use yazi_fs::must_exists; use super::{Git, Package}; diff --git a/yazi-cli/src/package/deploy.rs b/yazi-cli/src/package/deploy.rs index cf4b27cc..36c6c602 100644 --- a/yazi-cli/src/package/deploy.rs +++ b/yazi-cli/src/package/deploy.rs @@ -2,7 +2,7 @@ use std::path::PathBuf; use anyhow::{Context, Result, bail}; use tokio::fs; -use yazi_shared::{Xdg, fs::{maybe_exists, must_exists, remove_dir_clean}}; +use yazi_fs::{Xdg, maybe_exists, must_exists, remove_dir_clean}; use super::Package; diff --git a/yazi-cli/src/package/install.rs b/yazi-cli/src/package/install.rs index 215ed72a..17ee5799 100644 --- a/yazi-cli/src/package/install.rs +++ b/yazi-cli/src/package/install.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use yazi_shared::fs::must_exists; +use yazi_fs::must_exists; use super::{Git, Package}; diff --git a/yazi-cli/src/package/mod.rs b/yazi-cli/src/package/mod.rs index 15bb2146..062709f1 100644 --- a/yazi-cli/src/package/mod.rs +++ b/yazi-cli/src/package/mod.rs @@ -3,9 +3,10 @@ yazi_macro::mod_flat!(add deploy git install package parser upgrade); use anyhow::Context; +use yazi_fs::Xdg; pub(super) fn init() -> anyhow::Result<()> { - let root = yazi_shared::Xdg::state_dir().join("packages"); + let root = Xdg::state_dir().join("packages"); std::fs::create_dir_all(&root) .with_context(|| format!("failed to create packages directory: {root:?}"))?; diff --git a/yazi-cli/src/package/package.rs b/yazi-cli/src/package/package.rs index 5a8034cf..82864b8a 100644 --- a/yazi-cli/src/package/package.rs +++ b/yazi-cli/src/package/package.rs @@ -2,7 +2,7 @@ use std::{borrow::Cow, io::BufWriter, path::PathBuf}; use anyhow::Result; use md5::{Digest, Md5}; -use yazi_shared::Xdg; +use yazi_fs::Xdg; pub(crate) struct Package { pub(crate) repo: String, diff --git a/yazi-cli/src/package/parser.rs b/yazi-cli/src/package/parser.rs index 7322ebf9..c034fa41 100644 --- a/yazi-cli/src/package/parser.rs +++ b/yazi-cli/src/package/parser.rs @@ -1,7 +1,7 @@ use anyhow::{Context, Result, bail}; use tokio::fs; use toml_edit::{Array, DocumentMut, InlineTable, Item, Value}; -use yazi_shared::Xdg; +use yazi_fs::Xdg; use super::Package; diff --git a/yazi-codegen/Cargo.toml b/yazi-codegen/Cargo.toml index ce566313..8bb0ab44 100644 --- a/yazi-codegen/Cargo.toml +++ b/yazi-codegen/Cargo.toml @@ -13,5 +13,5 @@ proc-macro = true [dependencies] # External dependencies -syn = "2.0.89" +syn = "2.0.90" quote = "1.0.37" diff --git a/yazi-config/Cargo.toml b/yazi-config/Cargo.toml index e6037f09..d8185511 100644 --- a/yazi-config/Cargo.toml +++ b/yazi-config/Cargo.toml @@ -9,6 +9,7 @@ homepage = "https://yazi-rs.github.io" repository = "https://github.com/sxyazi/yazi" [dependencies] +yazi-fs = { path = "../yazi-fs", version = "0.3.3" } yazi-macro = { path = "../yazi-macro", version = "0.3.3" } yazi-shared = { path = "../yazi-shared", version = "0.3.3" } @@ -17,7 +18,7 @@ anyhow = { workspace = true } bitflags = { workspace = true } crossterm = { workspace = true } globset = { workspace = true } -indexmap = { version = "2.6.0", features = [ "serde" ] } +indexmap = { version = "2.7.0", features = [ "serde" ] } ratatui = { workspace = true } regex = { workspace = true } serde = { workspace = true } diff --git a/yazi-config/src/lib.rs b/yazi-config/src/lib.rs index 5cbf3b53..96b101da 100644 --- a/yazi-config/src/lib.rs +++ b/yazi-config/src/lib.rs @@ -6,7 +6,7 @@ yazi_macro::mod_flat!(layout pattern preset priority); use std::str::FromStr; -use yazi_shared::{RoCell, SyncCell, Xdg}; +use yazi_shared::{RoCell, SyncCell}; pub static KEYMAP: RoCell = RoCell::new(); pub static MANAGER: RoCell = RoCell::new(); @@ -74,7 +74,7 @@ pub fn init_flavor(light: bool) -> anyhow::Result<()> { theme.manager.syntect_theme = theme .flavor .syntect_path(light) - .unwrap_or_else(|| yazi_shared::fs::expand_path(&theme.manager.syntect_theme)); + .unwrap_or_else(|| yazi_fs::expand_path(&theme.manager.syntect_theme)); THEME.init(theme); Ok(()) @@ -82,7 +82,7 @@ pub fn init_flavor(light: bool) -> anyhow::Result<()> { fn try_init(merge: bool) -> anyhow::Result<()> { let (yazi_toml, keymap_toml) = if merge { - let p = Xdg::config_dir(); + let p = yazi_fs::Xdg::config_dir(); (Preset::yazi(&p)?, Preset::keymap(&p)?) } else { (yazi_macro::config_preset!("yazi"), yazi_macro::config_preset!("keymap")) diff --git a/yazi-config/src/manager/manager.rs b/yazi-config/src/manager/manager.rs index 78efa5c3..923b7dc1 100644 --- a/yazi-config/src/manager/manager.rs +++ b/yazi-config/src/manager/manager.rs @@ -3,8 +3,9 @@ use std::str::FromStr; use anyhow::Context; use serde::{Deserialize, Serialize}; use validator::Validate; +use yazi_fs::SortBy; -use super::{ManagerRatio, MouseEvents, SortBy}; +use super::{ManagerRatio, MouseEvents}; #[derive(Debug, Deserialize, Serialize, Validate)] pub struct Manager { diff --git a/yazi-config/src/manager/mod.rs b/yazi-config/src/manager/mod.rs index 221344eb..75c2a5ed 100644 --- a/yazi-config/src/manager/mod.rs +++ b/yazi-config/src/manager/mod.rs @@ -1 +1 @@ -yazi_macro::mod_flat!(manager mouse ratio sorting); +yazi_macro::mod_flat!(manager mouse ratio); diff --git a/yazi-config/src/pattern.rs b/yazi-config/src/pattern.rs index 37be5c6a..2adf707a 100644 --- a/yazi-config/src/pattern.rs +++ b/yazi-config/src/pattern.rs @@ -29,7 +29,7 @@ impl Pattern { #[cfg(windows)] let path = if self.sep_lit { - yazi_shared::fs::backslash_to_slash(path.as_ref()) + yazi_fs::backslash_to_slash(path.as_ref()) } else { std::borrow::Cow::Borrowed(path.as_ref()) }; diff --git a/yazi-config/src/plugin/plugin.rs b/yazi-config/src/plugin/plugin.rs index 279dd3e4..e713e338 100644 --- a/yazi-config/src/plugin/plugin.rs +++ b/yazi-config/src/plugin/plugin.rs @@ -3,7 +3,7 @@ use std::{collections::HashSet, path::Path, str::FromStr}; use anyhow::Context; use serde::{Deserialize, Deserializer}; use tracing::warn; -use yazi_shared::fs::File; +use yazi_fs::File; use super::{Fetcher, Preloader, Previewer, Spotter}; use crate::{Preset, plugin::MAX_PREWORKERS}; diff --git a/yazi-config/src/popup/options.rs b/yazi-config/src/popup/options.rs index c97a640c..b1d4b550 100644 --- a/yazi-config/src/popup/options.rs +++ b/yazi-config/src/popup/options.rs @@ -1,5 +1,5 @@ use ratatui::{text::Text, widgets::{Paragraph, Wrap}}; -use yazi_shared::fs::Url; +use yazi_shared::url::Url; use super::{Offset, Origin, Position}; use crate::{CONFIRM, INPUT, PICK}; @@ -119,7 +119,7 @@ impl ConfirmCfg { } } - pub fn trash(urls: &[yazi_shared::fs::Url]) -> Self { + pub fn trash(urls: &[yazi_shared::url::Url]) -> Self { Self::new( Self::replace_number(&CONFIRM.trash_title, urls.len()), (CONFIRM.trash_origin, CONFIRM.trash_offset), @@ -128,7 +128,7 @@ impl ConfirmCfg { ) } - pub fn delete(urls: &[yazi_shared::fs::Url]) -> Self { + pub fn delete(urls: &[yazi_shared::url::Url]) -> Self { Self::new( Self::replace_number(&CONFIRM.delete_title, urls.len()), (CONFIRM.delete_origin, CONFIRM.delete_offset), diff --git a/yazi-config/src/preset.rs b/yazi-config/src/preset.rs index 3ea85edd..3154fe2c 100644 --- a/yazi-config/src/preset.rs +++ b/yazi-config/src/preset.rs @@ -2,7 +2,7 @@ use std::{borrow::Cow, path::{Path, PathBuf}, str::FromStr}; use anyhow::{Context, Result}; use toml::{Table, Value}; -use yazi_shared::Xdg; +use yazi_fs::Xdg; use crate::theme::Flavor; diff --git a/yazi-config/src/preview/preview.rs b/yazi-config/src/preview/preview.rs index de9075ac..a127dddd 100644 --- a/yazi-config/src/preview/preview.rs +++ b/yazi-config/src/preview/preview.rs @@ -3,10 +3,10 @@ use std::{borrow::Cow, path::PathBuf, str::FromStr}; use anyhow::Context; use serde::{Deserialize, Deserializer, Serialize}; use validator::Validate; -use yazi_shared::{fs::expand_path, timestamp_us}; +use yazi_fs::{Xdg, expand_path}; +use yazi_shared::timestamp_us; use super::PreviewWrap; -use crate::Xdg; #[rustfmt::skip] const TABS: &[&str] = &["", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "]; diff --git a/yazi-config/src/theme/filetype.rs b/yazi-config/src/theme/filetype.rs index 184e30a6..4e993953 100644 --- a/yazi-config/src/theme/filetype.rs +++ b/yazi-config/src/theme/filetype.rs @@ -1,5 +1,6 @@ use serde::{Deserialize, Deserializer}; -use yazi_shared::{fs::File, theme::{Color, Style, StyleShadow}}; +use yazi_fs::File; +use yazi_shared::theme::{Color, Style, StyleShadow}; use super::Is; use crate::Pattern; diff --git a/yazi-config/src/theme/flavor.rs b/yazi-config/src/theme/flavor.rs index e621a393..3aea90c2 100644 --- a/yazi-config/src/theme/flavor.rs +++ b/yazi-config/src/theme/flavor.rs @@ -2,7 +2,7 @@ use std::{borrow::Cow, path::PathBuf, str::FromStr}; use anyhow::{Context, Result}; use serde::{Deserialize, Serialize}; -use yazi_shared::Xdg; +use yazi_fs::Xdg; #[derive(Default, Deserialize, Serialize)] pub struct Flavor { diff --git a/yazi-config/src/theme/icons.rs b/yazi-config/src/theme/icons.rs index d5262c15..561692fb 100644 --- a/yazi-config/src/theme/icons.rs +++ b/yazi-config/src/theme/icons.rs @@ -2,7 +2,8 @@ use std::collections::HashMap; use anyhow::Result; use serde::{Deserialize, Deserializer}; -use yazi_shared::{Condition, fs::File, theme::{Color, Icon, Style}}; +use yazi_fs::File; +use yazi_shared::{Condition, theme::{Color, Icon, Style}}; use crate::{Pattern, Preset}; diff --git a/yazi-config/src/theme/is.rs b/yazi-config/src/theme/is.rs index 0441d48e..92b1813e 100644 --- a/yazi-config/src/theme/is.rs +++ b/yazi-config/src/theme/is.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use anyhow::bail; use serde::Deserialize; -use yazi_shared::fs::Cha; +use yazi_fs::Cha; #[derive(Default, Deserialize)] #[serde(try_from = "String")] diff --git a/yazi-core/src/manager/commands/bulk_rename.rs b/yazi-core/src/manager/commands/bulk_rename.rs index e8e4adf1..cf74fc41 100644 --- a/yazi-core/src/manager/commands/bulk_rename.rs +++ b/yazi-core/src/manager/commands/bulk_rename.rs @@ -5,8 +5,9 @@ use scopeguard::defer; use tokio::{fs::{self, OpenOptions}, io::{AsyncReadExt, AsyncWriteExt, stdin}}; use yazi_config::{OPEN, PREVIEW}; use yazi_dds::Pubsub; +use yazi_fs::{File, FilesOp, max_common_root, maybe_exists, paths_to_same_file}; use yazi_proxy::{AppProxy, HIDER, TasksProxy, WATCHER}; -use yazi_shared::{fs::{File, FilesOp, Url, max_common_root, maybe_exists, paths_to_same_file}, terminal_clear}; +use yazi_shared::{terminal_clear, url::Url}; use crate::manager::Manager; diff --git a/yazi-core/src/manager/commands/create.rs b/yazi-core/src/manager/commands/create.rs index 1ef423bd..9160a688 100644 --- a/yazi-core/src/manager/commands/create.rs +++ b/yazi-core/src/manager/commands/create.rs @@ -3,8 +3,9 @@ use std::collections::{HashMap, HashSet}; use anyhow::Result; use tokio::fs; use yazi_config::popup::{ConfirmCfg, InputCfg}; +use yazi_fs::{File, FilesOp, maybe_exists, ok_or_not_found, realname}; use yazi_proxy::{ConfirmProxy, InputProxy, TabProxy, WATCHER}; -use yazi_shared::{event::CmdCow, fs::{File, FilesOp, Url, UrnBuf, maybe_exists, ok_or_not_found, realname}}; +use yazi_shared::{event::CmdCow, url::{Url, UrnBuf}}; use crate::manager::Manager; diff --git a/yazi-core/src/manager/commands/hover.rs b/yazi-core/src/manager/commands/hover.rs index ef0f7e57..b24f6513 100644 --- a/yazi-core/src/manager/commands/hover.rs +++ b/yazi-core/src/manager/commands/hover.rs @@ -2,7 +2,7 @@ use std::{collections::HashSet, path::PathBuf}; use yazi_dds::Pubsub; use yazi_macro::render; -use yazi_shared::{Id, event::{CmdCow, Data}, fs::{Url, Urn}}; +use yazi_shared::{Id, event::{CmdCow, Data}, url::{Url, Urn}}; use crate::manager::Manager; diff --git a/yazi-core/src/manager/commands/open.rs b/yazi-core/src/manager/commands/open.rs index 7e8a9380..58c8ac56 100644 --- a/yazi-core/src/manager/commands/open.rs +++ b/yazi-core/src/manager/commands/open.rs @@ -3,13 +3,13 @@ use std::{borrow::Cow, ffi::OsString}; use tracing::error; use yazi_boot::ARGS; use yazi_config::{OPEN, PLUGIN, popup::PickCfg}; -use yazi_fs::Folder; +use yazi_fs::File; use yazi_macro::emit; use yazi_plugin::isolate; use yazi_proxy::{ManagerProxy, TasksProxy, options::OpenDoOpt}; -use yazi_shared::{MIME_DIR, event::{CmdCow, EventQuit}, fs::{File, Url}}; +use yazi_shared::{MIME_DIR, event::{CmdCow, EventQuit}, url::Url}; -use crate::{manager::Manager, tasks::Tasks}; +use crate::{manager::Manager, tab::Folder, tasks::Tasks}; #[derive(Clone, Copy)] struct Opt { diff --git a/yazi-core/src/manager/commands/peek.rs b/yazi-core/src/manager/commands/peek.rs index c967b0be..c4d7502b 100644 --- a/yazi-core/src/manager/commands/peek.rs +++ b/yazi-core/src/manager/commands/peek.rs @@ -1,5 +1,5 @@ use yazi_proxy::HIDER; -use yazi_shared::{event::{CmdCow, Data}, fs::Url}; +use yazi_shared::{event::{CmdCow, Data}, url::Url}; use crate::manager::Manager; diff --git a/yazi-core/src/manager/commands/remove.rs b/yazi-core/src/manager/commands/remove.rs index fd890655..8a391710 100644 --- a/yazi-core/src/manager/commands/remove.rs +++ b/yazi-core/src/manager/commands/remove.rs @@ -1,6 +1,6 @@ use yazi_config::popup::ConfirmCfg; use yazi_proxy::{ConfirmProxy, ManagerProxy}; -use yazi_shared::{event::CmdCow, fs::Url}; +use yazi_shared::{event::CmdCow, url::Url}; use crate::{manager::Manager, tasks::Tasks}; diff --git a/yazi-core/src/manager/commands/rename.rs b/yazi-core/src/manager/commands/rename.rs index 2669aecc..c43c9153 100644 --- a/yazi-core/src/manager/commands/rename.rs +++ b/yazi-core/src/manager/commands/rename.rs @@ -4,8 +4,9 @@ use anyhow::Result; use tokio::fs; use yazi_config::popup::{ConfirmCfg, InputCfg}; use yazi_dds::Pubsub; +use yazi_fs::{File, FilesOp, maybe_exists, ok_or_not_found, paths_to_same_file, realname}; use yazi_proxy::{ConfirmProxy, InputProxy, TabProxy, WATCHER}; -use yazi_shared::{event::CmdCow, fs::{File, FilesOp, Url, UrnBuf, maybe_exists, ok_or_not_found, paths_to_same_file, realname}}; +use yazi_shared::{Id, event::CmdCow, url::{Url, UrnBuf}}; use crate::manager::Manager; @@ -53,7 +54,7 @@ impl Manager { _ => None, }; - let tab = self.tabs.cursor; + let tab = self.tabs.active().id; tokio::spawn(async move { let mut result = InputProxy::show(InputCfg::rename().with_value(name).with_cursor(cursor)); let Some(Ok(name)) = result.recv().await else { @@ -73,7 +74,7 @@ impl Manager { }); } - async fn rename_do(tab: usize, old: Url, new: Url) -> Result<()> { + async fn rename_do(tab: Id, old: Url, new: Url) -> Result<()> { let Some((p_old, n_old)) = old.pair() else { return Ok(()) }; let Some((p_new, n_new)) = new.pair() else { return Ok(()) }; let _permit = WATCHER.acquire().await.unwrap(); diff --git a/yazi-core/src/manager/commands/tab_create.rs b/yazi-core/src/manager/commands/tab_create.rs index 76acc4d7..2330fc44 100644 --- a/yazi-core/src/manager/commands/tab_create.rs +++ b/yazi-core/src/manager/commands/tab_create.rs @@ -1,7 +1,7 @@ use yazi_boot::BOOT; use yazi_macro::render; use yazi_proxy::AppProxy; -use yazi_shared::{event::CmdCow, fs::Url}; +use yazi_shared::{event::CmdCow, url::Url}; use crate::{manager::Tabs, tab::Tab}; diff --git a/yazi-core/src/manager/commands/update_files.rs b/yazi-core/src/manager/commands/update_files.rs index 0560a6e1..9f4451f1 100644 --- a/yazi-core/src/manager/commands/update_files.rs +++ b/yazi-core/src/manager/commands/update_files.rs @@ -1,11 +1,11 @@ use std::borrow::Cow; -use yazi_fs::Folder; +use yazi_fs::FilesOp; use yazi_macro::render; use yazi_proxy::ManagerProxy; -use yazi_shared::{event::CmdCow, fs::FilesOp}; +use yazi_shared::event::CmdCow; -use crate::{manager::{LINKED, Manager}, tab::Tab, tasks::Tasks}; +use crate::{manager::{LINKED, Manager}, tab::{Folder, Tab}, tasks::Tasks}; pub struct Opt { op: FilesOp, @@ -64,7 +64,7 @@ impl Manager { let leave = matches!(*op, FilesOp::Deleting(_, ref urns) if urns.contains(&urn)); if let Some(f) = tab.parent.as_mut() { - render!(f.update(op.into_owned())); + render!(f.update_pub(tab.id, op.into_owned())); render!(f.hover(urn.as_urn())); } @@ -78,7 +78,7 @@ impl Manager { let calc = !matches!(*op, FilesOp::Size(..) | FilesOp::Deleting(..)); let foreign = matches!(op, Cow::Borrowed(_)); - if !tab.current.update(op.into_owned()) { + if !tab.current.update_pub(tab.id, op.into_owned()) { return; } @@ -99,7 +99,7 @@ impl Manager { let folder = tab.history.entry(url.clone()).or_insert_with(|| Folder::from(url)); let foreign = matches!(op, Cow::Borrowed(_)); - if !folder.update(op.into_owned()) { + if !folder.update_pub(tab.id, op.into_owned()) { return; } @@ -115,7 +115,7 @@ impl Manager { let folder = tab.history.entry(op.cwd().clone()).or_insert_with(|| Folder::from(op.cwd())); let hovered = folder.hovered().filter(|_| folder.tracing).map(|h| h.urn_owned()); - if folder.update(op.into_owned()) { + if folder.update_pub(tab.id, op.into_owned()) { folder.repos(hovered.as_ref().map(|u| u.as_urn())); } diff --git a/yazi-core/src/manager/commands/update_mimes.rs b/yazi-core/src/manager/commands/update_mimes.rs index 814a99b4..c411dcf8 100644 --- a/yazi-core/src/manager/commands/update_mimes.rs +++ b/yazi-core/src/manager/commands/update_mimes.rs @@ -2,7 +2,7 @@ use std::{borrow::Cow, collections::HashMap}; use tracing::error; use yazi_macro::render; -use yazi_shared::{event::CmdCow, fs::Url}; +use yazi_shared::{event::CmdCow, url::Url}; use crate::{manager::{LINKED, Manager}, tasks::Tasks}; diff --git a/yazi-core/src/manager/commands/update_paged.rs b/yazi-core/src/manager/commands/update_paged.rs index 59a0bc2b..b679c9d6 100644 --- a/yazi-core/src/manager/commands/update_paged.rs +++ b/yazi-core/src/manager/commands/update_paged.rs @@ -1,4 +1,4 @@ -use yazi_shared::{event::{CmdCow, Data}, fs::Url}; +use yazi_shared::{event::{CmdCow, Data}, url::Url}; use crate::{manager::Manager, tasks::Tasks}; diff --git a/yazi-core/src/manager/commands/update_tasks.rs b/yazi-core/src/manager/commands/update_tasks.rs index 785be069..9bc48598 100644 --- a/yazi-core/src/manager/commands/update_tasks.rs +++ b/yazi-core/src/manager/commands/update_tasks.rs @@ -1,4 +1,4 @@ -use yazi_shared::{event::CmdCow, fs::Url}; +use yazi_shared::{event::CmdCow, url::Url}; use crate::manager::Manager; diff --git a/yazi-core/src/manager/commands/update_yanked.rs b/yazi-core/src/manager/commands/update_yanked.rs index b26a3bd5..ca2fcde9 100644 --- a/yazi-core/src/manager/commands/update_yanked.rs +++ b/yazi-core/src/manager/commands/update_yanked.rs @@ -1,7 +1,7 @@ use std::collections::HashSet; use yazi_macro::render; -use yazi_shared::{event::CmdCow, fs::Url}; +use yazi_shared::{event::CmdCow, url::Url}; use crate::manager::{Manager, Yanked}; diff --git a/yazi-core/src/manager/linked.rs b/yazi-core/src/manager/linked.rs index c29fc201..2de344d2 100644 --- a/yazi-core/src/manager/linked.rs +++ b/yazi-core/src/manager/linked.rs @@ -1,6 +1,6 @@ use std::{collections::HashMap, ops::{Deref, DerefMut}}; -use yazi_shared::fs::Url; +use yazi_shared::url::Url; #[derive(Default)] pub struct Linked(HashMap /* from ==> to */); diff --git a/yazi-core/src/manager/manager.rs b/yazi-core/src/manager/manager.rs index 34f01fa4..0bf62564 100644 --- a/yazi-core/src/manager/manager.rs +++ b/yazi-core/src/manager/manager.rs @@ -1,11 +1,11 @@ use ratatui::layout::Rect; use yazi_adapter::Dimension; use yazi_config::popup::{Origin, Position}; -use yazi_fs::Folder; -use yazi_shared::{Id, fs::{File, Url}}; +use yazi_fs::File; +use yazi_shared::{Id, url::Url}; use super::{Mimetype, Tabs, Watcher, Yanked}; -use crate::tab::Tab; +use crate::tab::{Folder, Tab}; pub struct Manager { pub tabs: Tabs, diff --git a/yazi-core/src/manager/mimetype.rs b/yazi-core/src/manager/mimetype.rs index 63e44a2e..1b339293 100644 --- a/yazi-core/src/manager/mimetype.rs +++ b/yazi-core/src/manager/mimetype.rs @@ -1,6 +1,6 @@ use std::{collections::HashMap, path::PathBuf}; -use yazi_shared::fs::{Url, UrlScheme}; +use yazi_shared::url::{Url, UrlScheme}; #[derive(Default)] pub struct Mimetype(HashMap); diff --git a/yazi-core/src/manager/tabs.rs b/yazi-core/src/manager/tabs.rs index 4ddcf99e..2e53d70a 100644 --- a/yazi-core/src/manager/tabs.rs +++ b/yazi-core/src/manager/tabs.rs @@ -3,7 +3,7 @@ use std::ops::{Deref, DerefMut}; use yazi_boot::BOOT; use yazi_dds::Pubsub; use yazi_proxy::ManagerProxy; -use yazi_shared::{Id, fs::Url}; +use yazi_shared::{Id, url::Url}; use crate::tab::Tab; @@ -45,7 +45,7 @@ impl Tabs { self.cursor = idx; ManagerProxy::refresh(); ManagerProxy::peek(true); - Pubsub::pub_from_tab(idx); + Pubsub::pub_from_tab(self.active().id); } } diff --git a/yazi-core/src/manager/watcher.rs b/yazi-core/src/manager/watcher.rs index bc693561..abab6264 100644 --- a/yazi-core/src/manager/watcher.rs +++ b/yazi-core/src/manager/watcher.rs @@ -7,12 +7,13 @@ use tokio::{fs, pin, sync::{mpsc::{self, UnboundedReceiver}, watch}}; use tokio_stream::{StreamExt, wrappers::UnboundedReceiverStream}; use tracing::error; use yazi_config::PLUGIN; -use yazi_fs::{Files, Folder}; +use yazi_fs::{Cha, File, Files, FilesOp, realname_unchecked}; use yazi_plugin::isolate; use yazi_proxy::WATCHER; -use yazi_shared::{RoCell, event::CmdCow, fs::{Cha, File, FilesOp, Url, realname_unchecked}}; +use yazi_shared::{RoCell, event::CmdCow, url::Url}; use super::Linked; +use crate::tab::Folder; pub(crate) static WATCHED: RoCell>> = RoCell::new(); pub static LINKED: RoCell> = RoCell::new(); diff --git a/yazi-core/src/manager/yanked.rs b/yazi-core/src/manager/yanked.rs index ec53bdb7..f87e62df 100644 --- a/yazi-core/src/manager/yanked.rs +++ b/yazi-core/src/manager/yanked.rs @@ -1,7 +1,8 @@ use std::{collections::HashSet, ops::Deref}; use yazi_dds::Pubsub; -use yazi_shared::fs::{FilesOp, Url}; +use yazi_fs::FilesOp; +use yazi_shared::url::Url; #[derive(Default)] pub struct Yanked { diff --git a/yazi-core/src/spot/spot.rs b/yazi-core/src/spot/spot.rs index b42af36d..5c076ddd 100644 --- a/yazi-core/src/spot/spot.rs +++ b/yazi-core/src/spot/spot.rs @@ -2,8 +2,9 @@ use std::borrow::Cow; use tokio_util::sync::CancellationToken; use yazi_config::PLUGIN; +use yazi_fs::File; use yazi_plugin::{isolate, utils::SpotLock}; -use yazi_shared::fs::{File, Url}; +use yazi_shared::url::Url; #[derive(Default)] pub struct Spot { diff --git a/yazi-core/src/tab/commands/cd.rs b/yazi-core/src/tab/commands/cd.rs index d734dd42..bec41bb5 100644 --- a/yazi-core/src/tab/commands/cd.rs +++ b/yazi-core/src/tab/commands/cd.rs @@ -4,9 +4,10 @@ use tokio::{fs, pin}; use tokio_stream::{StreamExt, wrappers::UnboundedReceiverStream}; use yazi_config::popup::InputCfg; use yazi_dds::Pubsub; +use yazi_fs::expand_path; use yazi_macro::render; use yazi_proxy::{CompletionProxy, InputProxy, ManagerProxy, TabProxy}; -use yazi_shared::{Debounce, errors::InputError, event::CmdCow, fs::{Url, expand_path}}; +use yazi_shared::{Debounce, errors::InputError, event::CmdCow, url::Url}; use crate::tab::Tab; diff --git a/yazi-core/src/tab/commands/copy.rs b/yazi-core/src/tab/commands/copy.rs index 49168d10..c687ea68 100644 --- a/yazi-core/src/tab/commands/copy.rs +++ b/yazi-core/src/tab/commands/copy.rs @@ -70,7 +70,7 @@ impl Separator { fn transform + ?Sized>(self, p: &T) -> Cow { #[cfg(windows)] if self == Self::Unix { - return match yazi_shared::fs::backslash_to_slash(p.as_ref()) { + return match yazi_fs::backslash_to_slash(p.as_ref()) { Cow::Owned(p) => Cow::Owned(p.into_os_string()), Cow::Borrowed(p) => Cow::Borrowed(p.as_os_str()), }; diff --git a/yazi-core/src/tab/commands/reveal.rs b/yazi-core/src/tab/commands/reveal.rs index 8f4f9df8..a49d2199 100644 --- a/yazi-core/src/tab/commands/reveal.rs +++ b/yazi-core/src/tab/commands/reveal.rs @@ -1,5 +1,6 @@ +use yazi_fs::{File, FilesOp, expand_path}; use yazi_proxy::ManagerProxy; -use yazi_shared::{event::CmdCow, fs::{File, FilesOp, Url, expand_path}}; +use yazi_shared::{event::CmdCow, url::Url}; use crate::tab::Tab; diff --git a/yazi-core/src/tab/commands/search.rs b/yazi-core/src/tab/commands/search.rs index 6073147c..35fcf173 100644 --- a/yazi-core/src/tab/commands/search.rs +++ b/yazi-core/src/tab/commands/search.rs @@ -6,7 +6,7 @@ use tracing::error; use yazi_config::popup::InputCfg; use yazi_plugin::external; use yazi_proxy::{AppProxy, InputProxy, ManagerProxy, TabProxy, options::{SearchOpt, SearchOptVia}}; -use yazi_shared::fs::{Cha, FilesOp}; +use yazi_fs::{Cha, FilesOp}; use crate::tab::Tab; diff --git a/yazi-core/src/tab/commands/sort.rs b/yazi-core/src/tab/commands/sort.rs index d4c98ab3..efcd8c95 100644 --- a/yazi-core/src/tab/commands/sort.rs +++ b/yazi-core/src/tab/commands/sort.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use yazi_config::manager::SortBy; +use yazi_fs::SortBy; use yazi_proxy::ManagerProxy; use yazi_shared::event::CmdCow; diff --git a/yazi-core/src/tab/commands/toggle.rs b/yazi-core/src/tab/commands/toggle.rs index f8b8a288..e0f6e860 100644 --- a/yazi-core/src/tab/commands/toggle.rs +++ b/yazi-core/src/tab/commands/toggle.rs @@ -1,6 +1,6 @@ use yazi_macro::render_and; use yazi_proxy::AppProxy; -use yazi_shared::{event::CmdCow, fs::Url}; +use yazi_shared::{event::CmdCow, url::Url}; use crate::tab::Tab; diff --git a/yazi-core/src/tab/finder.rs b/yazi-core/src/tab/finder.rs index 14748580..8f0e02f3 100644 --- a/yazi-core/src/tab/finder.rs +++ b/yazi-core/src/tab/finder.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use anyhow::Result; use yazi_fs::{Files, Filter, FilterCase}; -use yazi_shared::fs::Url; +use yazi_shared::url::Url; pub struct Finder { pub filter: Filter, diff --git a/yazi-fs/src/folder.rs b/yazi-core/src/tab/folder.rs similarity index 92% rename from yazi-fs/src/folder.rs rename to yazi-core/src/tab/folder.rs index 11e7205e..70bfd36e 100644 --- a/yazi-fs/src/folder.rs +++ b/yazi-core/src/tab/folder.rs @@ -1,11 +1,10 @@ use std::mem; use yazi_config::{LAYOUT, MANAGER}; +use yazi_dds::Pubsub; +use yazi_fs::{Cha, File, Files, FilesOp, FolderStage, Step}; use yazi_proxy::ManagerProxy; -use yazi_shared::fs::{Cha, File, FilesOp, Url, Urn}; - -use super::FolderStage; -use crate::{Files, Step}; +use yazi_shared::{Id, url::{Url, Urn}}; #[derive(Default)] pub struct Folder { @@ -61,6 +60,16 @@ impl Folder { (stage, revision) != (self.stage, self.files.revision) } + pub fn update_pub(&mut self, tab: Id, op: FilesOp) -> bool { + let old = self.stage; + if !self.update(op) { + return false; + } else if self.stage != old { + Pubsub::pub_from_load(tab, &self.url, self.stage); + } + true + } + pub fn arrow(&mut self, step: impl Into) -> bool { let step = step.into() as Step; let mut b = if self.files.is_empty() { diff --git a/yazi-core/src/tab/history.rs b/yazi-core/src/tab/history.rs index 39fba485..699715d0 100644 --- a/yazi-core/src/tab/history.rs +++ b/yazi-core/src/tab/history.rs @@ -1,7 +1,8 @@ use std::{collections::HashMap, ops::{Deref, DerefMut}}; -use yazi_fs::Folder; -use yazi_shared::fs::Url; +use yazi_shared::url::Url; + +use super::Folder; #[derive(Default)] pub struct History(HashMap); diff --git a/yazi-core/src/tab/mod.rs b/yazi-core/src/tab/mod.rs index 268c5946..e925851a 100644 --- a/yazi-core/src/tab/mod.rs +++ b/yazi-core/src/tab/mod.rs @@ -1,3 +1,3 @@ yazi_macro::mod_pub!(commands); -yazi_macro::mod_flat!(backstack preference finder history mode preview selected tab); +yazi_macro::mod_flat!(backstack finder folder history mode preference preview selected tab); diff --git a/yazi-core/src/tab/preference.rs b/yazi-core/src/tab/preference.rs index e8c258fc..828d65a3 100644 --- a/yazi-core/src/tab/preference.rs +++ b/yazi-core/src/tab/preference.rs @@ -1,5 +1,5 @@ -use yazi_config::{MANAGER, manager::SortBy}; -use yazi_fs::FilesSorter; +use yazi_config::MANAGER; +use yazi_fs::{FilesSorter, SortBy}; #[derive(Clone, PartialEq)] pub struct Preference { @@ -38,15 +38,16 @@ impl Preference { f(self); *self != old } +} - #[inline] - pub(super) fn sorter(&self) -> FilesSorter { +impl From<&Preference> for FilesSorter { + fn from(value: &Preference) -> Self { FilesSorter { - by: self.sort_by, - sensitive: self.sort_sensitive, - reverse: self.sort_reverse, - dir_first: self.sort_dir_first, - translit: self.sort_translit, + by: value.sort_by, + sensitive: value.sort_sensitive, + reverse: value.sort_reverse, + dir_first: value.sort_dir_first, + translit: value.sort_translit, } } } diff --git a/yazi-core/src/tab/preview.rs b/yazi-core/src/tab/preview.rs index 35bd3ae1..86d90e09 100644 --- a/yazi-core/src/tab/preview.rs +++ b/yazi-core/src/tab/preview.rs @@ -5,10 +5,10 @@ use tokio_stream::{StreamExt, wrappers::UnboundedReceiverStream}; use tokio_util::sync::CancellationToken; use yazi_adapter::ADAPTOR; use yazi_config::PLUGIN; -use yazi_fs::Files; +use yazi_fs::{Cha, File, Files, FilesOp}; use yazi_macro::render; use yazi_plugin::{external::Highlighter, isolate, utils::PreviewLock}; -use yazi_shared::{MIME_DIR, fs::{Cha, File, FilesOp, Url}}; +use yazi_shared::{MIME_DIR, url::Url}; #[derive(Default)] pub struct Preview { diff --git a/yazi-core/src/tab/selected.rs b/yazi-core/src/tab/selected.rs index 73c51b67..1a47bbee 100644 --- a/yazi-core/src/tab/selected.rs +++ b/yazi-core/src/tab/selected.rs @@ -1,6 +1,7 @@ use std::{collections::HashMap, ops::Deref}; -use yazi_shared::{fs::{FilesOp, Url}, timestamp_us}; +use yazi_fs::FilesOp; +use yazi_shared::{timestamp_us, url::Url}; #[derive(Default)] pub struct Selected { diff --git a/yazi-core/src/tab/tab.rs b/yazi-core/src/tab/tab.rs index e6e3aa2d..3f6f6285 100644 --- a/yazi-core/src/tab/tab.rs +++ b/yazi-core/src/tab/tab.rs @@ -5,11 +5,11 @@ use ratatui::layout::Rect; use tokio::task::JoinHandle; use yazi_adapter::Dimension; use yazi_config::{LAYOUT, popup::{Origin, Position}}; -use yazi_fs::{Folder, FolderStage}; +use yazi_fs::{File, FolderStage}; use yazi_macro::render; -use yazi_shared::{Id, Ids, fs::{File, Url}}; +use yazi_shared::{Id, Ids, url::Url}; -use super::{Backstack, Finder, History, Mode, Preference, Preview}; +use super::{Backstack, Finder, Folder, History, Mode, Preference, Preview}; use crate::{spot::Spot, tab::Selected}; pub struct Tab { @@ -126,7 +126,7 @@ impl Tab { let hovered = f.hovered().filter(|_| f.tracing).map(|h| h.urn_owned()); f.files.set_show_hidden(self.pref.show_hidden); - f.files.set_sorter(self.pref.sorter()); + f.files.set_sorter(<_>::from(&self.pref)); render!(f.files.catchup_revision()); render!(f.repos(hovered.as_ref().map(|u| u.as_urn()))); diff --git a/yazi-core/src/tasks/file.rs b/yazi-core/src/tasks/file.rs index c09068d5..65bff641 100644 --- a/yazi-core/src/tasks/file.rs +++ b/yazi-core/src/tasks/file.rs @@ -1,7 +1,7 @@ use std::collections::HashSet; use tracing::debug; -use yazi_shared::fs::Url; +use yazi_shared::url::Url; use super::Tasks; diff --git a/yazi-core/src/tasks/preload.rs b/yazi-core/src/tasks/preload.rs index 5da21798..a40b05e5 100644 --- a/yazi-core/src/tasks/preload.rs +++ b/yazi-core/src/tasks/preload.rs @@ -1,6 +1,6 @@ -use yazi_config::{PLUGIN, manager::SortBy, plugin::MAX_PREWORKERS}; -use yazi_fs::Files; -use yazi_shared::{MIME_DIR, fs::File}; +use yazi_config::{PLUGIN, plugin::MAX_PREWORKERS}; +use yazi_fs::{File, Files, SortBy}; +use yazi_shared::MIME_DIR; use super::Tasks; use crate::manager::Mimetype; diff --git a/yazi-core/src/tasks/process.rs b/yazi-core/src/tasks/process.rs index d7116488..977db837 100644 --- a/yazi-core/src/tasks/process.rs +++ b/yazi-core/src/tasks/process.rs @@ -1,7 +1,7 @@ use std::{borrow::Cow, collections::HashMap, ffi::OsString, mem}; use yazi_config::{OPEN, open::Opener}; -use yazi_shared::fs::Url; +use yazi_shared::url::Url; use super::Tasks; diff --git a/yazi-dds/Cargo.toml b/yazi-dds/Cargo.toml index 80475d37..ea1aafcd 100644 --- a/yazi-dds/Cargo.toml +++ b/yazi-dds/Cargo.toml @@ -14,6 +14,7 @@ vendored-lua = [ "mlua/vendored" ] [dependencies] yazi-boot = { path = "../yazi-boot", version = "0.3.3" } +yazi-fs = { path = "../yazi-fs", version = "0.3.3" } yazi-macro = { path = "../yazi-macro", version = "0.3.3" } yazi-shared = { path = "../yazi-shared", version = "0.3.3" } diff --git a/yazi-dds/src/body/body.rs b/yazi-dds/src/body/body.rs index a8ea4da5..cbe0dfac 100644 --- a/yazi-dds/src/body/body.rs +++ b/yazi-dds/src/body/body.rs @@ -2,7 +2,7 @@ use anyhow::{Result, bail}; use mlua::{ExternalResult, IntoLua, Lua, Value}; use serde::Serialize; -use super::{BodyBulk, BodyBye, BodyCd, BodyCustom, BodyDelete, BodyHey, BodyHi, BodyHover, BodyMove, BodyRename, BodyTab, BodyTrash, BodyYank}; +use super::{BodyBulk, BodyBye, BodyCd, BodyCustom, BodyDelete, BodyHey, BodyHi, BodyHover, BodyLoad, BodyMove, BodyRename, BodyTab, BodyTrash, BodyYank}; use crate::Payload; #[derive(Debug, Serialize)] @@ -11,9 +11,10 @@ pub enum Body<'a> { Hi(BodyHi<'a>), Hey(BodyHey), Bye(BodyBye), - Cd(BodyCd<'a>), - Hover(BodyHover<'a>), Tab(BodyTab), + Cd(BodyCd<'a>), + Load(BodyLoad<'a>), + Hover(BodyHover<'a>), Rename(BodyRename<'a>), Bulk(BodyBulk<'a>), Yank(BodyYank<'a>), @@ -29,9 +30,10 @@ impl Body<'static> { "hi" => Self::Hi(serde_json::from_str(body)?), "hey" => Self::Hey(serde_json::from_str(body)?), "bye" => Self::Bye(serde_json::from_str(body)?), - "cd" => Self::Cd(serde_json::from_str(body)?), - "hover" => Self::Hover(serde_json::from_str(body)?), "tab" => Self::Tab(serde_json::from_str(body)?), + "cd" => Self::Cd(serde_json::from_str(body)?), + "load" => Self::Load(serde_json::from_str(body)?), + "hover" => Self::Hover(serde_json::from_str(body)?), "rename" => Self::Rename(serde_json::from_str(body)?), "bulk" => Self::Bulk(serde_json::from_str(body)?), "@yank" => Self::Yank(serde_json::from_str(body)?), @@ -53,9 +55,10 @@ impl Body<'static> { "hi" | "hey" | "bye" - | "cd" - | "hover" | "tab" + | "cd" + | "load" + | "hover" | "rename" | "bulk" | "@yank" @@ -85,9 +88,10 @@ impl<'a> Body<'a> { Self::Hi(_) => "hi", Self::Hey(_) => "hey", Self::Bye(_) => "bye", - Self::Cd(_) => "cd", - Self::Hover(_) => "hover", Self::Tab(_) => "tab", + Self::Cd(_) => "cd", + Self::Load(_) => "load", + Self::Hover(_) => "hover", Self::Rename(_) => "rename", Self::Bulk(_) => "bulk", Self::Yank(_) => "@yank", @@ -114,6 +118,7 @@ impl IntoLua for Body<'static> { Self::Hey(b) => b.into_lua(lua), Self::Bye(b) => b.into_lua(lua), Self::Cd(b) => b.into_lua(lua), + Self::Load(b) => b.into_lua(lua), Self::Hover(b) => b.into_lua(lua), Self::Tab(b) => b.into_lua(lua), Self::Rename(b) => b.into_lua(lua), diff --git a/yazi-dds/src/body/bulk.rs b/yazi-dds/src/body/bulk.rs index 3f17fb14..96bf4922 100644 --- a/yazi-dds/src/body/bulk.rs +++ b/yazi-dds/src/body/bulk.rs @@ -2,7 +2,7 @@ use std::{borrow::Cow, collections::{HashMap, hash_map}}; use mlua::{AnyUserData, IntoLua, IntoLuaMulti, Lua, MetaMethod, UserData, UserDataRefMut, Value}; use serde::{Deserialize, Serialize}; -use yazi_shared::fs::Url; +use yazi_shared::url::Url; use super::Body; diff --git a/yazi-dds/src/body/cd.rs b/yazi-dds/src/body/cd.rs index f0bc9095..05d117cb 100644 --- a/yazi-dds/src/body/cd.rs +++ b/yazi-dds/src/body/cd.rs @@ -2,7 +2,7 @@ use std::borrow::Cow; use mlua::{IntoLua, Lua, Value}; use serde::{Deserialize, Serialize}; -use yazi_shared::{Id, fs::Url}; +use yazi_shared::{Id, url::Url}; use super::Body; diff --git a/yazi-dds/src/body/delete.rs b/yazi-dds/src/body/delete.rs index 002ffe47..6bedd0cd 100644 --- a/yazi-dds/src/body/delete.rs +++ b/yazi-dds/src/body/delete.rs @@ -2,7 +2,7 @@ use std::borrow::Cow; use mlua::{IntoLua, Lua, Value}; use serde::{Deserialize, Serialize}; -use yazi_shared::fs::Url; +use yazi_shared::url::Url; use super::Body; diff --git a/yazi-dds/src/body/hover.rs b/yazi-dds/src/body/hover.rs index 3ec67435..395d601c 100644 --- a/yazi-dds/src/body/hover.rs +++ b/yazi-dds/src/body/hover.rs @@ -2,7 +2,7 @@ use std::borrow::Cow; use mlua::{IntoLua, Lua, Value}; use serde::{Deserialize, Serialize}; -use yazi_shared::{Id, fs::Url}; +use yazi_shared::{Id, url::Url}; use super::Body; diff --git a/yazi-dds/src/body/load.rs b/yazi-dds/src/body/load.rs new file mode 100644 index 00000000..ab31a33f --- /dev/null +++ b/yazi-dds/src/body/load.rs @@ -0,0 +1,45 @@ +use std::borrow::Cow; + +use mlua::{IntoLua, Lua, Value}; +use serde::{Deserialize, Serialize}; +use yazi_fs::FolderStage; +use yazi_shared::{Id, url::Url}; + +use super::Body; + +#[derive(Debug, Serialize, Deserialize)] +pub struct BodyLoad<'a> { + pub tab: Id, + pub url: Cow<'a, Url>, + pub stage: FolderStage, +} + +impl<'a> BodyLoad<'a> { + #[inline] + pub fn borrowed(tab: Id, url: &'a Url, stage: FolderStage) -> Body<'a> { + Self { tab, url: Cow::Borrowed(url), stage }.into() + } +} + +impl BodyLoad<'static> { + #[inline] + pub fn dummy(tab: Id, url: &Url, stage: FolderStage) -> Body<'static> { + Self { tab, url: Cow::Owned(url.clone()), stage }.into() + } +} + +impl<'a> From> for Body<'a> { + fn from(value: BodyLoad<'a>) -> Self { Self::Load(value) } +} + +impl IntoLua for BodyLoad<'static> { + fn into_lua(self, lua: &Lua) -> mlua::Result { + lua + .create_table_from([ + ("tab", self.tab.get().into_lua(lua)?), + ("url", lua.create_any_userdata(self.url.into_owned())?.into_lua(lua)?), + ("stage", lua.create_any_userdata(self.stage)?.into_lua(lua)?), + ])? + .into_lua(lua) + } +} diff --git a/yazi-dds/src/body/mod.rs b/yazi-dds/src/body/mod.rs index a10d53ff..72c24a86 100644 --- a/yazi-dds/src/body/mod.rs +++ b/yazi-dds/src/body/mod.rs @@ -1,5 +1,5 @@ #![allow(clippy::module_inception)] yazi_macro::mod_flat!( - body bulk bye cd custom delete hey hi hover move_ rename tab trash yank + body bulk bye cd custom delete hey hi hover load move_ rename tab trash yank ); diff --git a/yazi-dds/src/body/move_.rs b/yazi-dds/src/body/move_.rs index 5721f058..b9025bd5 100644 --- a/yazi-dds/src/body/move_.rs +++ b/yazi-dds/src/body/move_.rs @@ -2,7 +2,7 @@ use std::borrow::Cow; use mlua::{IntoLua, Lua, Value}; use serde::{Deserialize, Serialize}; -use yazi_shared::fs::Url; +use yazi_shared::url::Url; use super::Body; diff --git a/yazi-dds/src/body/rename.rs b/yazi-dds/src/body/rename.rs index c19c7f3a..84207807 100644 --- a/yazi-dds/src/body/rename.rs +++ b/yazi-dds/src/body/rename.rs @@ -2,27 +2,27 @@ use std::borrow::Cow; use mlua::{IntoLua, Lua, Value}; use serde::{Deserialize, Serialize}; -use yazi_shared::fs::Url; +use yazi_shared::{Id, url::Url}; use super::Body; #[derive(Debug, Serialize, Deserialize)] pub struct BodyRename<'a> { - pub tab: usize, + pub tab: Id, pub from: Cow<'a, Url>, pub to: Cow<'a, Url>, } impl<'a> BodyRename<'a> { #[inline] - pub fn borrowed(tab: usize, from: &'a Url, to: &'a Url) -> Body<'a> { + pub fn borrowed(tab: Id, from: &'a Url, to: &'a Url) -> Body<'a> { Self { tab, from: Cow::Borrowed(from), to: Cow::Borrowed(to) }.into() } } impl BodyRename<'static> { #[inline] - pub fn dummy(tab: usize, from: &Url, to: &Url) -> Body<'static> { + pub fn dummy(tab: Id, from: &Url, to: &Url) -> Body<'static> { Self { tab, from: Cow::Owned(from.clone()), to: Cow::Owned(to.clone()) }.into() } } @@ -35,7 +35,7 @@ impl IntoLua for BodyRename<'static> { fn into_lua(self, lua: &Lua) -> mlua::Result { lua .create_table_from([ - ("tab", self.tab.into_lua(lua)?), + ("tab", self.tab.get().into_lua(lua)?), ("from", lua.create_any_userdata(self.from.into_owned())?.into_lua(lua)?), ("to", lua.create_any_userdata(self.to.into_owned())?.into_lua(lua)?), ])? diff --git a/yazi-dds/src/body/tab.rs b/yazi-dds/src/body/tab.rs index dc873c46..fcc95849 100644 --- a/yazi-dds/src/body/tab.rs +++ b/yazi-dds/src/body/tab.rs @@ -1,16 +1,17 @@ use mlua::{IntoLua, Lua, Value}; use serde::{Deserialize, Serialize}; +use yazi_shared::Id; use super::Body; #[derive(Debug, Serialize, Deserialize)] pub struct BodyTab { - pub idx: usize, + pub id: Id, } impl BodyTab { #[inline] - pub fn owned(idx: usize) -> Body<'static> { Self { idx }.into() } + pub fn owned(id: Id) -> Body<'static> { Self { id }.into() } } impl From for Body<'_> { @@ -19,6 +20,6 @@ impl From for Body<'_> { impl IntoLua for BodyTab { fn into_lua(self, lua: &Lua) -> mlua::Result { - lua.create_table_from([("idx", self.idx)])?.into_lua(lua) + lua.create_table_from([("idx", self.id.get())])?.into_lua(lua) } } diff --git a/yazi-dds/src/body/trash.rs b/yazi-dds/src/body/trash.rs index 02e1cea5..022f3a9b 100644 --- a/yazi-dds/src/body/trash.rs +++ b/yazi-dds/src/body/trash.rs @@ -2,7 +2,7 @@ use std::borrow::Cow; use mlua::{IntoLua, Lua, Value}; use serde::{Deserialize, Serialize}; -use yazi_shared::fs::Url; +use yazi_shared::url::Url; use super::Body; diff --git a/yazi-dds/src/body/yank.rs b/yazi-dds/src/body/yank.rs index 64ba3df1..31c71756 100644 --- a/yazi-dds/src/body/yank.rs +++ b/yazi-dds/src/body/yank.rs @@ -2,7 +2,7 @@ use std::{borrow::Cow, collections::HashSet}; use mlua::{IntoLua, Lua, MetaMethod, UserData, Value}; use serde::{Deserialize, Serialize}; -use yazi_shared::fs::Url; +use yazi_shared::url::Url; use super::Body; diff --git a/yazi-dds/src/payload.rs b/yazi-dds/src/payload.rs index fd6b3ca8..d819dd18 100644 --- a/yazi-dds/src/payload.rs +++ b/yazi-dds/src/payload.rs @@ -82,6 +82,7 @@ impl Display for Payload<'_> { Body::Hey(b) => serde_json::to_string(b), Body::Bye(b) => serde_json::to_string(b), Body::Cd(b) => serde_json::to_string(b), + Body::Load(b) => serde_json::to_string(b), Body::Hover(b) => serde_json::to_string(b), Body::Tab(b) => serde_json::to_string(b), Body::Rename(b) => serde_json::to_string(b), diff --git a/yazi-dds/src/pubsub.rs b/yazi-dds/src/pubsub.rs index 807294e5..a1113775 100644 --- a/yazi-dds/src/pubsub.rs +++ b/yazi-dds/src/pubsub.rs @@ -3,9 +3,10 @@ use std::collections::{HashMap, HashSet}; use mlua::Function; use parking_lot::RwLock; use yazi_boot::BOOT; -use yazi_shared::{Id, RoCell, fs::Url}; +use yazi_fs::FolderStage; +use yazi_shared::{Id, RoCell, url::Url}; -use crate::{Client, ID, PEERS, body::{Body, BodyBulk, BodyCd, BodyDelete, BodyHi, BodyHover, BodyMove, BodyMoveItem, BodyRename, BodyTab, BodyTrash, BodyYank}}; +use crate::{Client, ID, PEERS, body::{Body, BodyBulk, BodyCd, BodyDelete, BodyHi, BodyHover, BodyLoad, BodyMove, BodyMoveItem, BodyRename, BodyTab, BodyTrash, BodyYank}}; pub static LOCAL: RoCell>>> = RoCell::new(); @@ -84,6 +85,18 @@ impl Pubsub { true } + pub fn pub_from_tab(idx: Id) { + if LOCAL.read().contains_key("tab") { + Self::pub_(BodyTab::owned(idx)); + } + if PEERS.read().values().any(|p| p.able("tab")) { + Client::push(BodyTab::owned(idx)); + } + if BOOT.local_events.contains("tab") { + BodyTab::owned(idx).with_receiver(*ID).flush(); + } + } + pub fn pub_from_cd(tab: Id, url: &Url) { if LOCAL.read().contains_key("cd") { Self::pub_(BodyCd::dummy(tab)); @@ -96,6 +109,18 @@ impl Pubsub { } } + pub fn pub_from_load(tab: Id, url: &Url, stage: FolderStage) { + if LOCAL.read().contains_key("load") { + Self::pub_(BodyLoad::dummy(tab, url, stage)); + } + if PEERS.read().values().any(|p| p.able("load")) { + Client::push(BodyLoad::borrowed(tab, url, stage)); + } + if BOOT.local_events.contains("load") { + BodyLoad::borrowed(tab, url, stage).with_receiver(*ID).flush(); + } + } + pub fn pub_from_hover(tab: Id, url: Option<&Url>) { if LOCAL.read().contains_key("hover") { Self::pub_(BodyHover::dummy(tab)); @@ -108,19 +133,7 @@ impl Pubsub { } } - pub fn pub_from_tab(idx: usize) { - if LOCAL.read().contains_key("tab") { - Self::pub_(BodyTab::owned(idx)); - } - if PEERS.read().values().any(|p| p.able("tab")) { - Client::push(BodyTab::owned(idx)); - } - if BOOT.local_events.contains("tab") { - BodyTab::owned(idx).with_receiver(*ID).flush(); - } - } - - pub fn pub_from_rename(tab: usize, from: &Url, to: &Url) { + pub fn pub_from_rename(tab: Id, from: &Url, to: &Url) { if LOCAL.read().contains_key("rename") { Self::pub_(BodyRename::dummy(tab, from, to)); } diff --git a/yazi-dds/src/pump.rs b/yazi-dds/src/pump.rs index 652cdaf8..335ae521 100644 --- a/yazi-dds/src/pump.rs +++ b/yazi-dds/src/pump.rs @@ -4,7 +4,7 @@ use parking_lot::Mutex; use tokio::{pin, select, sync::mpsc}; use tokio_stream::{StreamExt, wrappers::UnboundedReceiverStream}; use tokio_util::sync::CancellationToken; -use yazi_shared::{RoCell, fs::Url}; +use yazi_shared::{RoCell, url::Url}; use crate::{Pubsub, body::BodyMoveItem}; diff --git a/yazi-dds/src/sendable.rs b/yazi-dds/src/sendable.rs index 42563379..e1948497 100644 --- a/yazi-dds/src/sendable.rs +++ b/yazi-dds/src/sendable.rs @@ -35,7 +35,7 @@ impl Sendable { Value::Function(_) => Err("function is not supported".into_lua_err())?, Value::Thread(_) => Err("thread is not supported".into_lua_err())?, Value::UserData(ud) => { - if let Ok(t) = ud.take::() { + if let Ok(t) = ud.take::() { Data::Url(t) } else if let Ok(t) = ud.take::() { Data::Any(Box::new(t)) @@ -188,7 +188,7 @@ impl Sendable { Value::Function(_) => Err("function is not supported".into_lua_err())?, Value::Thread(_) => Err("thread is not supported".into_lua_err())?, Value::UserData(ud) => { - if let Ok(t) = ud.take::() { + if let Ok(t) = ud.take::() { DataKey::Url(t) } else { Err("unsupported userdata included".into_lua_err())? diff --git a/yazi-fm/Cargo.toml b/yazi-fm/Cargo.toml index 9b225ab1..ff25bc99 100644 --- a/yazi-fm/Cargo.toml +++ b/yazi-fm/Cargo.toml @@ -41,7 +41,7 @@ tokio-stream = { workspace = true } # Logging tracing = { workspace = true } tracing-appender = "0.2.3" -tracing-subscriber = { version = "0.3.18", features = [ "env-filter" ] } +tracing-subscriber = { version = "0.3.19", features = [ "env-filter" ] } [target."cfg(unix)".dependencies] libc = { workspace = true } diff --git a/yazi-fm/src/app/commands/accept_payload.rs b/yazi-fm/src/app/commands/accept_payload.rs index 78dd7779..96b63351 100644 --- a/yazi-fm/src/app/commands/accept_payload.rs +++ b/yazi-fm/src/app/commands/accept_payload.rs @@ -1,7 +1,7 @@ use mlua::IntoLua; use tracing::error; use yazi_dds::{LOCAL, Payload, REMOTE}; -use yazi_plugin::LUA; +use yazi_plugin::{LUA, RtRef}; use yazi_shared::event::CmdCow; use crate::{app::App, lives::Lives}; @@ -13,22 +13,25 @@ impl App { }; let kind = payload.body.kind().to_owned(); - let map = if payload.receiver == 0 || payload.receiver != payload.sender { + let lock = if payload.receiver == 0 || payload.receiver != payload.sender { REMOTE.read() } else { LOCAL.read() }; - let Some(map) = map.get(&kind).filter(|&m| !m.is_empty()) else { + let Some(handlers) = lock.get(&kind).filter(|&m| !m.is_empty()).cloned() else { return; }; + drop(lock); _ = Lives::scope(&self.cx, || { let body = payload.body.into_lua(&LUA)?; - for f in map.values() { - if let Err(e) = f.call::<()>(body.clone()) { - error!("Failed to call `{kind}` handler: {e}"); + for (id, cb) in handlers { + LUA.named_registry_value::("rt")?.push(&id); + if let Err(e) = cb.call::<()>(body.clone()) { + error!("Failed to run `{kind}` event handler in your `{id}` plugin: {e}"); } + LUA.named_registry_value::("rt")?.pop(); } Ok(()) }); diff --git a/yazi-fm/src/context.rs b/yazi-fm/src/context.rs index 8e4c1b4d..122c2891 100644 --- a/yazi-fm/src/context.rs +++ b/yazi-fm/src/context.rs @@ -1,6 +1,5 @@ use ratatui::layout::Rect; -use yazi_core::{completion::Completion, confirm::Confirm, help::Help, input::Input, manager::Manager, notify::Notify, pick::Pick, tab::Tab, tasks::Tasks, which::Which}; -use yazi_fs::Folder; +use yazi_core::{completion::Completion, confirm::Confirm, help::Help, input::Input, manager::Manager, notify::Notify, pick::Pick, tab::{Folder, Tab}, tasks::Tasks, which::Which}; pub struct Ctx { pub manager: Manager, diff --git a/yazi-fm/src/lives/file.rs b/yazi-fm/src/lives/file.rs index f07854fd..32f8d2c4 100644 --- a/yazi-fm/src/lives/file.rs +++ b/yazi-fm/src/lives/file.rs @@ -10,32 +10,32 @@ use crate::Ctx; pub(super) struct File { idx: usize, - folder: *const yazi_fs::Folder, + folder: *const yazi_core::tab::Folder, tab: *const yazi_core::tab::Tab, } impl Deref for File { - type Target = yazi_shared::fs::File; + type Target = yazi_fs::File; fn deref(&self) -> &Self::Target { &self.folder().files[self.idx] } } -impl AsRef for File { - fn as_ref(&self) -> &yazi_shared::fs::File { self } +impl AsRef for File { + fn as_ref(&self) -> &yazi_fs::File { self } } impl File { #[inline] pub(super) fn make( idx: usize, - folder: &yazi_fs::Folder, + folder: &yazi_core::tab::Folder, tab: &yazi_core::tab::Tab, ) -> mlua::Result { Lives::scoped_userdata(Self { idx, folder, tab }) } #[inline] - fn folder(&self) -> &yazi_fs::Folder { unsafe { &*self.folder } } + fn folder(&self) -> &yazi_core::tab::Folder { unsafe { &*self.folder } } #[inline] fn tab(&self) -> &yazi_core::tab::Tab { unsafe { &*self.tab } } diff --git a/yazi-fm/src/lives/files.rs b/yazi-fm/src/lives/files.rs index af747a1d..64a2de95 100644 --- a/yazi-fm/src/lives/files.rs +++ b/yazi-fm/src/lives/files.rs @@ -6,7 +6,7 @@ use super::{File, Filter, Lives}; pub(super) struct Files { window: Range, - folder: *const yazi_fs::Folder, + folder: *const yazi_core::tab::Folder, tab: *const yazi_core::tab::Tab, } @@ -20,14 +20,14 @@ impl Files { #[inline] pub(super) fn make( window: Range, - folder: &yazi_fs::Folder, + folder: &yazi_core::tab::Folder, tab: &yazi_core::tab::Tab, ) -> mlua::Result { Lives::scoped_userdata(Self { window, folder, tab }) } #[inline] - fn folder(&self) -> &yazi_fs::Folder { unsafe { &*self.folder } } + fn folder(&self) -> &yazi_core::tab::Folder { unsafe { &*self.folder } } #[inline] fn tab(&self) -> &yazi_core::tab::Tab { unsafe { &*self.tab } } diff --git a/yazi-fm/src/lives/folder.rs b/yazi-fm/src/lives/folder.rs index 3c13ca5c..92270d57 100644 --- a/yazi-fm/src/lives/folder.rs +++ b/yazi-fm/src/lives/folder.rs @@ -8,12 +8,12 @@ use super::{File, Files, Lives}; pub(super) struct Folder { window: Range, - inner: *const yazi_fs::Folder, + inner: *const yazi_core::tab::Folder, tab: *const yazi_core::tab::Tab, } impl Deref for Folder { - type Target = yazi_fs::Folder; + type Target = yazi_core::tab::Folder; fn deref(&self) -> &Self::Target { unsafe { &*self.inner } } } @@ -22,7 +22,7 @@ impl Folder { #[inline] pub(super) fn make( window: Option>, - inner: &yazi_fs::Folder, + inner: &yazi_core::tab::Folder, tab: &yazi_core::tab::Tab, ) -> mlua::Result { let window = match window { diff --git a/yazi-fm/src/lives/selected.rs b/yazi-fm/src/lives/selected.rs index d2de2a38..d1998410 100644 --- a/yazi-fm/src/lives/selected.rs +++ b/yazi-fm/src/lives/selected.rs @@ -7,23 +7,23 @@ use super::{Iter, Lives}; #[derive(Clone, Copy)] pub(super) struct Selected { - inner: *const HashMap, + inner: *const HashMap, } impl Deref for Selected { - type Target = HashMap; + type Target = HashMap; fn deref(&self) -> &Self::Target { self.inner() } } impl Selected { #[inline] - pub(super) fn make(inner: &HashMap) -> mlua::Result { + pub(super) fn make(inner: &HashMap) -> mlua::Result { Lives::scoped_userdata(Self { inner }) } #[inline] - fn inner(&self) -> &'static HashMap { unsafe { &*self.inner } } + fn inner(&self) -> &'static HashMap { unsafe { &*self.inner } } } impl UserData for Selected { @@ -32,7 +32,7 @@ impl UserData for Selected { methods.add_meta_method(MetaMethod::Pairs, |lua, me, ()| { let iter = lua.create_function( - |lua, mut iter: UserDataRefMut, _>>| { + |lua, mut iter: UserDataRefMut, _>>| { if let Some(next) = iter.next() { (next.0, Url::cast(lua, next.1.clone())?).into_lua_multi(lua) } else { diff --git a/yazi-fm/src/lives/yanked.rs b/yazi-fm/src/lives/yanked.rs index 0ca5262e..e0316dc4 100644 --- a/yazi-fm/src/lives/yanked.rs +++ b/yazi-fm/src/lives/yanked.rs @@ -35,7 +35,7 @@ impl UserData for Yanked { methods.add_meta_method(MetaMethod::Pairs, |lua, me, ()| { let iter = lua.create_function( - |lua, mut iter: UserDataRefMut, _>>| { + |lua, mut iter: UserDataRefMut, _>>| { if let Some(next) = iter.next() { (next.0, Url::cast(lua, next.1.clone())?).into_lua_multi(lua) } else { diff --git a/yazi-fm/src/logs.rs b/yazi-fm/src/logs.rs index 772b6d1d..bc540aae 100644 --- a/yazi-fm/src/logs.rs +++ b/yazi-fm/src/logs.rs @@ -3,7 +3,8 @@ use std::{env, fs::File}; use anyhow::Context; use tracing_appender::non_blocking::WorkerGuard; use tracing_subscriber::EnvFilter; -use yazi_shared::{RoCell, Xdg}; +use yazi_fs::Xdg; +use yazi_shared::RoCell; static _GUARD: RoCell = RoCell::new(); diff --git a/yazi-fs/Cargo.toml b/yazi-fs/Cargo.toml index 269d11ff..856010df 100644 --- a/yazi-fs/Cargo.toml +++ b/yazi-fs/Cargo.toml @@ -9,13 +9,21 @@ homepage = "https://yazi-rs.github.io" repository = "https://github.com/sxyazi/yazi" [dependencies] -yazi-config = { path = "../yazi-config", version = "0.3.3" } yazi-macro = { path = "../yazi-macro", version = "0.3.3" } -yazi-proxy = { path = "../yazi-proxy", version = "0.3.3" } yazi-shared = { path = "../yazi-shared", version = "0.3.3" } # External dependencies -anyhow = { workspace = true } -futures = { workspace = true } -regex = { workspace = true } -tokio = { workspace = true } +anyhow = { workspace = true } +bitflags = { workspace = true } +dirs = { workspace = true } +futures = { workspace = true } +regex = { workspace = true } +tokio = { workspace = true } +serde = { workspace = true } + +[target."cfg(unix)".dependencies] +libc = { workspace = true } +uzers = { workspace = true } + +[target.'cfg(windows)'.dependencies] +windows-sys = { version = "0.59.0", features = [ "Win32_Storage_FileSystem" ] } diff --git a/yazi-shared/src/fs/cha.rs b/yazi-fs/src/cha.rs similarity index 98% rename from yazi-shared/src/fs/cha.rs rename to yazi-fs/src/cha.rs index 8f9597fb..e2747833 100644 --- a/yazi-shared/src/fs/cha.rs +++ b/yazi-fs/src/cha.rs @@ -147,7 +147,7 @@ impl Cha { let mut attached = ChaKind::empty(); #[cfg(unix)] - if super::Urn::new(path).is_hidden() { + if yazi_shared::url::Urn::new(path).is_hidden() { attached |= ChaKind::HIDDEN; } #[cfg(windows)] diff --git a/yazi-shared/src/fs/file.rs b/yazi-fs/src/file.rs similarity index 94% rename from yazi-shared/src/fs/file.rs rename to yazi-fs/src/file.rs index 7e90809f..01a3c982 100644 --- a/yazi-shared/src/fs/file.rs +++ b/yazi-fs/src/file.rs @@ -2,9 +2,9 @@ use std::{ffi::OsStr, fs::{FileType, Metadata}, ops::Deref}; use anyhow::Result; use tokio::fs; +use yazi_shared::{SyncCell, theme::IconCache, url::{Url, Urn, UrnBuf}}; -use super::{Urn, UrnBuf}; -use crate::{SyncCell, fs::{Cha, Url}, theme::IconCache}; +use crate::Cha; #[derive(Clone, Debug, Default)] pub struct File { diff --git a/yazi-fs/src/files.rs b/yazi-fs/src/files.rs index 482e5750..e8207114 100644 --- a/yazi-fs/src/files.rs +++ b/yazi-fs/src/files.rs @@ -1,11 +1,12 @@ use std::{collections::{HashMap, HashSet}, mem, ops::Deref}; use tokio::{fs::{self, DirEntry}, select, sync::mpsc::{self, UnboundedReceiver}}; -use yazi_config::{MANAGER, manager::SortBy}; -use yazi_shared::{Id, fs::{Cha, FILES_TICKET, File, FilesOp, Url, Urn, UrnBuf, maybe_exists}}; +use yazi_shared::{Id, url::{Url, Urn, UrnBuf}}; use super::{FilesSorter, Filter}; +use crate::{Cha, FILES_TICKET, File, FilesOp, SortBy, maybe_exists}; +#[derive(Default)] pub struct Files { hidden: Vec, items: Vec, @@ -20,24 +21,6 @@ pub struct Files { show_hidden: bool, } -impl Default for Files { - fn default() -> Self { - Self { - items: Default::default(), - hidden: Default::default(), - ticket: Default::default(), - version: Default::default(), - revision: Default::default(), - - sizes: Default::default(), - - sorter: Default::default(), - filter: Default::default(), - show_hidden: MANAGER.show_hidden, - } - } -} - impl Deref for Files { type Target = Vec; diff --git a/yazi-shared/src/fs/fns.rs b/yazi-fs/src/fns.rs similarity index 100% rename from yazi-shared/src/fs/fns.rs rename to yazi-fs/src/fns.rs diff --git a/yazi-fs/src/lib.rs b/yazi-fs/src/lib.rs index 16f1b1e0..235160e5 100644 --- a/yazi-fs/src/lib.rs +++ b/yazi-fs/src/lib.rs @@ -1,3 +1,3 @@ -#![allow(clippy::if_same_then_else)] +#![allow(clippy::if_same_then_else, clippy::option_map_unit_fn)] -yazi_macro::mod_flat!(files filter folder sorter stage step); +yazi_macro::mod_flat!(cha file files filter fns op path sorter sorting stage step xdg); diff --git a/yazi-shared/src/fs/op.rs b/yazi-fs/src/op.rs similarity index 94% rename from yazi-shared/src/fs/op.rs rename to yazi-fs/src/op.rs index 84d03cce..2e142fed 100644 --- a/yazi-shared/src/fs/op.rs +++ b/yazi-fs/src/op.rs @@ -1,7 +1,8 @@ use std::collections::{HashMap, HashSet}; -use super::{Cha, File, UrnBuf}; -use crate::{Id, Ids, Layer, event::Cmd, fs::Url}; +use yazi_shared::{Id, Ids, Layer, event::Cmd, url::{Url, UrnBuf}}; + +use super::{Cha, File}; pub static FILES_TICKET: Ids = Ids::new(); @@ -38,8 +39,11 @@ impl FilesOp { #[inline] pub fn emit(self) { - crate::event::Event::Call(Cmd::new("update_files").with_any("op", self).into(), Layer::Manager) - .emit(); + yazi_shared::event::Event::Call( + Cmd::new("update_files").with_any("op", self).into(), + Layer::Manager, + ) + .emit(); } pub fn prepare(cwd: &Url) -> Id { diff --git a/yazi-shared/src/fs/path.rs b/yazi-fs/src/path.rs similarity index 99% rename from yazi-shared/src/fs/path.rs rename to yazi-fs/src/path.rs index a9681b5b..9eba494c 100644 --- a/yazi-shared/src/fs/path.rs +++ b/yazi-fs/src/path.rs @@ -1,9 +1,7 @@ use std::{borrow::Cow, env, ffi::OsString, future::Future, io, path::{Component, Path, PathBuf}}; use tokio::fs; - -use super::Loc; -use crate::fs::Url; +use yazi_shared::url::{Loc, Url}; pub fn current_cwd() -> Option { env::var_os("PWD") diff --git a/yazi-fs/src/sorter.rs b/yazi-fs/src/sorter.rs index 86315bcd..b1ccad25 100644 --- a/yazi-fs/src/sorter.rs +++ b/yazi-fs/src/sorter.rs @@ -1,7 +1,8 @@ use std::{cmp::Ordering, collections::HashMap, mem}; -use yazi_config::manager::SortBy; -use yazi_shared::{LcgRng, fs::{File, UrnBuf}, natsort, translit::Transliterator}; +use yazi_shared::{LcgRng, natsort, translit::Transliterator, url::UrnBuf}; + +use crate::{File, SortBy}; #[derive(Clone, Copy, Default, PartialEq)] pub struct FilesSorter { diff --git a/yazi-config/src/manager/sorting.rs b/yazi-fs/src/sorting.rs similarity index 100% rename from yazi-config/src/manager/sorting.rs rename to yazi-fs/src/sorting.rs diff --git a/yazi-fs/src/stage.rs b/yazi-fs/src/stage.rs index 89f3ac50..009dd980 100644 --- a/yazi-fs/src/stage.rs +++ b/yazi-fs/src/stage.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize, ser::SerializeMap}; + #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] pub enum FolderStage { #[default] @@ -5,3 +7,32 @@ pub enum FolderStage { Loaded, Failed(std::io::ErrorKind), } + +impl Serialize for FolderStage { + fn serialize(&self, serializer: S) -> Result { + let mut map = serializer.serialize_map(Some(2))?; + match self { + Self::Loading => map.serialize_entry("state", "loading")?, + Self::Loaded => map.serialize_entry("state", "loaded")?, + Self::Failed(_) => map.serialize_entry("state", "failed")?, + } + map.end() + } +} + +impl<'de> Deserialize<'de> for FolderStage { + fn deserialize>(deserializer: D) -> Result { + #[derive(Deserialize)] + struct Shadow { + state: String, + } + + let shadow = Shadow::deserialize(deserializer)?; + match shadow.state.as_str() { + "loading" => Ok(Self::Loading), + "loaded" => Ok(Self::Loaded), + "failed" => Ok(Self::Failed(std::io::ErrorKind::Other)), + _ => Err(serde::de::Error::custom("invalid folder stage")), + } + } +} diff --git a/yazi-shared/src/xdg.rs b/yazi-fs/src/xdg.rs similarity index 92% rename from yazi-shared/src/xdg.rs rename to yazi-fs/src/xdg.rs index f8e13c8f..4e287e27 100644 --- a/yazi-shared/src/xdg.rs +++ b/yazi-fs/src/xdg.rs @@ -1,6 +1,6 @@ use std::{env, path::PathBuf}; -use crate::fs::expand_path; +use crate::expand_path; pub struct Xdg; @@ -48,7 +48,7 @@ impl Xdg { #[cfg(unix)] let s = { use uzers::Users; - format!("yazi-{}", crate::USERS_CACHE.get_current_uid()) + format!("yazi-{}", yazi_shared::USERS_CACHE.get_current_uid()) }; #[cfg(windows)] diff --git a/yazi-plugin/Cargo.toml b/yazi-plugin/Cargo.toml index 741cdcad..8e1c97e7 100644 --- a/yazi-plugin/Cargo.toml +++ b/yazi-plugin/Cargo.toml @@ -17,6 +17,7 @@ yazi-adapter = { path = "../yazi-adapter", version = "0.3.3" } yazi-boot = { path = "../yazi-boot", version = "0.3.3" } yazi-config = { path = "../yazi-config", version = "0.3.3" } yazi-dds = { path = "../yazi-dds", version = "0.3.3" } +yazi-fs = { path = "../yazi-fs", version = "0.3.3" } yazi-macro = { path = "../yazi-macro", version = "0.3.3" } yazi-proxy = { path = "../yazi-proxy", version = "0.3.3" } yazi-shared = { path = "../yazi-shared", version = "0.3.3" } @@ -33,7 +34,6 @@ mlua = { workspace = true } parking_lot = { workspace = true } ratatui = { workspace = true } serde_json = { workspace = true } -shell-words = { workspace = true } syntect = { version = "5.2.0", default-features = false, features = [ "parsing", "plist-load", "regex-onig" ] } tokio = { workspace = true } tokio-stream = { workspace = true } diff --git a/yazi-plugin/src/bindings/cha.rs b/yazi-plugin/src/bindings/cha.rs index 8ccca8ce..b67c3248 100644 --- a/yazi-plugin/src/bindings/cha.rs +++ b/yazi-plugin/src/bindings/cha.rs @@ -1,20 +1,20 @@ use std::{ops::Deref, time::{Duration, SystemTime, UNIX_EPOCH}}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Table, UserData, UserDataFields, UserDataMethods}; -use yazi_shared::fs::ChaKind; +use yazi_fs::ChaKind; use crate::RtRef; #[derive(Clone, Copy, FromLua)] -pub struct Cha(yazi_shared::fs::Cha); +pub struct Cha(yazi_fs::Cha); impl Deref for Cha { - type Target = yazi_shared::fs::Cha; + type Target = yazi_fs::Cha; fn deref(&self) -> &Self::Target { &self.0 } } -impl> From for Cha { +impl> From for Cha { fn from(cha: T) -> Self { Self(cha.into()) } } @@ -56,7 +56,7 @@ impl Cha { let kind = ChaKind::from_bits(t.raw_get("kind")?).ok_or_else(|| "Invalid kind".into_lua_err())?; - Self::from(yazi_shared::fs::Cha { + Self::from(yazi_fs::Cha { kind, len: t.raw_get("len").unwrap_or_default(), atime: parse_time(t.raw_get("atime").ok())?, @@ -140,7 +140,7 @@ impl UserData for Cha { methods.add_method("perm", |_, _me, ()| { Ok( #[cfg(unix)] - Some(yazi_shared::fs::permissions(_me.mode, _me.is_dummy())), + Some(yazi_fs::permissions(_me.mode, _me.is_dummy())), #[cfg(windows)] None::, ) @@ -151,7 +151,7 @@ impl UserData for Cha { warn_deprecated(lua.named_registry_value::("rt")?.current()); Ok( #[cfg(unix)] - Some(yazi_shared::fs::permissions(_me.mode, _me.is_dummy())), + Some(yazi_fs::permissions(_me.mode, _me.is_dummy())), #[cfg(windows)] None::, ) diff --git a/yazi-plugin/src/external/fd.rs b/yazi-plugin/src/external/fd.rs index 61480e9a..f5097d67 100644 --- a/yazi-plugin/src/external/fd.rs +++ b/yazi-plugin/src/external/fd.rs @@ -2,7 +2,8 @@ use std::process::Stdio; use anyhow::Result; use tokio::{io::{AsyncBufReadExt, BufReader}, process::{Child, Command}, sync::mpsc::{self, UnboundedReceiver}}; -use yazi_shared::fs::{File, Url}; +use yazi_fs::File; +use yazi_shared::url::Url; pub struct FdOpt { pub cwd: Url, diff --git a/yazi-plugin/src/external/rg.rs b/yazi-plugin/src/external/rg.rs index 7ff71f2c..5e28cdef 100644 --- a/yazi-plugin/src/external/rg.rs +++ b/yazi-plugin/src/external/rg.rs @@ -2,7 +2,8 @@ use std::process::Stdio; use anyhow::Result; use tokio::{io::{AsyncBufReadExt, BufReader}, process::Command, sync::mpsc::{self, UnboundedReceiver}}; -use yazi_shared::fs::{File, Url}; +use yazi_fs::File; +use yazi_shared::url::Url; pub struct RgOpt { pub cwd: Url, diff --git a/yazi-plugin/src/file/file.rs b/yazi-plugin/src/file/file.rs index e90e6990..dbabc8cc 100644 --- a/yazi-plugin/src/file/file.rs +++ b/yazi-plugin/src/file/file.rs @@ -2,14 +2,14 @@ use mlua::{AnyUserData, Lua, Table, UserDataRef}; use crate::{bindings::{Cast, Cha}, impl_file_fields, impl_file_methods}; -pub type FileRef = UserDataRef; +pub type FileRef = UserDataRef; pub struct File; impl File { #[inline] pub fn register(lua: &Lua) -> mlua::Result<()> { - lua.register_userdata_type::(|reg| { + lua.register_userdata_type::(|reg| { impl_file_fields!(reg); impl_file_methods!(reg); }) @@ -19,7 +19,7 @@ impl File { lua.globals().raw_set( "File", lua.create_function(|lua, t: Table| { - Self::cast(lua, yazi_shared::fs::File { + Self::cast(lua, yazi_fs::File { url: t.raw_get::("url")?.take()?, cha: *t.raw_get::("cha")?, ..Default::default() @@ -29,6 +29,6 @@ impl File { } } -impl> Cast for File { +impl> Cast for File { fn cast(lua: &Lua, data: T) -> mlua::Result { lua.create_any_userdata(data.into()) } } diff --git a/yazi-plugin/src/fs/fs.rs b/yazi-plugin/src/fs/fs.rs index 33c9813b..596ce1f7 100644 --- a/yazi-plugin/src/fs/fs.rs +++ b/yazi-plugin/src/fs/fs.rs @@ -1,7 +1,7 @@ use globset::GlobBuilder; use mlua::{ExternalError, ExternalResult, Function, IntoLua, IntoLuaMulti, Lua, MetaMethod, Table, Value}; use tokio::fs; -use yazi_shared::fs::remove_dir_clean; +use yazi_fs::remove_dir_clean; use crate::{Error, bindings::{Cast, Cha}, file::File, url::{Url, UrlRef}}; @@ -104,13 +104,13 @@ fn read_dir(lua: &Lua) -> mlua::Result { continue; } - let url = yazi_shared::fs::Url::from(path); + let url = yazi_shared::url::Url::from(path); let file = if !resolve { - yazi_shared::fs::File::from_dummy(url, next.file_type().await.ok()) + yazi_fs::File::from_dummy(url, next.file_type().await.ok()) } else if let Ok(meta) = next.metadata().await { - yazi_shared::fs::File::from_meta(url, meta).await + yazi_fs::File::from_meta(url, meta).await } else { - yazi_shared::fs::File::from_dummy(url, next.file_type().await.ok()) + yazi_fs::File::from_dummy(url, next.file_type().await.ok()) }; files.push(File::cast(&lua, file)?); } @@ -126,7 +126,7 @@ fn read_dir(lua: &Lua) -> mlua::Result { fn unique_name(lua: &Lua) -> mlua::Result { lua.create_async_function(|lua, url: UrlRef| async move { - match yazi_shared::fs::unique_name(url.clone(), async { false }).await { + match yazi_fs::unique_name(url.clone(), async { false }).await { Ok(u) => (Url::cast(&lua, u)?, Value::Nil).into_lua_multi(&lua), Err(e) => (Value::Nil, Error::Io(e)).into_lua_multi(&lua), } diff --git a/yazi-plugin/src/isolate/fetch.rs b/yazi-plugin/src/isolate/fetch.rs index 932447ab..32c9252a 100644 --- a/yazi-plugin/src/isolate/fetch.rs +++ b/yazi-plugin/src/isolate/fetch.rs @@ -7,7 +7,7 @@ use yazi_shared::event::CmdCow; use super::slim_lua; use crate::{bindings::Cast, elements::Rect, file::File, loader::LOADER}; -pub async fn fetch(cmd: CmdCow, files: Vec) -> mlua::Result { +pub async fn fetch(cmd: CmdCow, files: Vec) -> mlua::Result { if files.is_empty() { return Ok(1); } diff --git a/yazi-plugin/src/isolate/peek.rs b/yazi-plugin/src/isolate/peek.rs index abcdb21a..8c6312b2 100644 --- a/yazi-plugin/src/isolate/peek.rs +++ b/yazi-plugin/src/isolate/peek.rs @@ -14,7 +14,7 @@ use crate::{RtRef, bindings::Cast, elements::Rect, file::File, loader::LOADER}; pub fn peek( cmd: &'static Cmd, - file: yazi_shared::fs::File, + file: yazi_fs::File, mime: Cow<'static, str>, skip: usize, ) -> CancellationToken { @@ -74,12 +74,7 @@ pub fn peek( ct } -pub fn peek_sync( - cmd: &'static Cmd, - file: yazi_shared::fs::File, - mime: Cow<'static, str>, - skip: usize, -) { +pub fn peek_sync(cmd: &'static Cmd, file: yazi_fs::File, mime: Cow<'static, str>, skip: usize) { let cb: PluginCallback = Box::new(move |lua, plugin| { let job = lua.create_table_from([ ("area", Rect::from(LAYOUT.get().preview).into_lua(lua)?), diff --git a/yazi-plugin/src/isolate/preload.rs b/yazi-plugin/src/isolate/preload.rs index 508049f5..8f569fdd 100644 --- a/yazi-plugin/src/isolate/preload.rs +++ b/yazi-plugin/src/isolate/preload.rs @@ -7,7 +7,7 @@ use yazi_shared::event::Cmd; use super::slim_lua; use crate::{bindings::Cast, elements::Rect, file::File, loader::LOADER}; -pub async fn preload(cmd: &'static Cmd, file: yazi_shared::fs::File) -> mlua::Result { +pub async fn preload(cmd: &'static Cmd, file: yazi_fs::File) -> mlua::Result { LOADER.ensure(&cmd.name).await.into_lua_err()?; tokio::task::spawn_blocking(move || { diff --git a/yazi-plugin/src/isolate/seek.rs b/yazi-plugin/src/isolate/seek.rs index a85305a3..73d73989 100644 --- a/yazi-plugin/src/isolate/seek.rs +++ b/yazi-plugin/src/isolate/seek.rs @@ -5,7 +5,7 @@ use yazi_shared::event::Cmd; use crate::{bindings::Cast, elements::Rect, file::File}; -pub fn seek_sync(cmd: &Cmd, file: yazi_shared::fs::File, units: i16) { +pub fn seek_sync(cmd: &Cmd, file: yazi_fs::File, units: i16) { let cb: PluginCallback = Box::new(move |lua, plugin| { let job = lua.create_table_from([ ("file", File::cast(lua, file)?.into_lua(lua)?), diff --git a/yazi-plugin/src/isolate/spot.rs b/yazi-plugin/src/isolate/spot.rs index 227c2637..e238c5cc 100644 --- a/yazi-plugin/src/isolate/spot.rs +++ b/yazi-plugin/src/isolate/spot.rs @@ -12,7 +12,7 @@ use crate::{bindings::Cast, file::File, loader::LOADER}; pub fn spot( cmd: &'static Cmd, - file: yazi_shared::fs::File, + file: yazi_fs::File, mime: Cow<'static, str>, skip: usize, ) -> CancellationToken { diff --git a/yazi-plugin/src/url/url.rs b/yazi-plugin/src/url/url.rs index af0bbdad..508e4fbd 100644 --- a/yazi-plugin/src/url/url.rs +++ b/yazi-plugin/src/url/url.rs @@ -2,13 +2,13 @@ use mlua::{AnyUserData, ExternalError, Lua, MetaMethod, UserDataFields, UserData use crate::bindings::Cast; -pub type UrlRef = UserDataRef; +pub type UrlRef = UserDataRef; pub struct Url; impl Url { pub fn register(lua: &Lua) -> mlua::Result<()> { - lua.register_userdata_type::(|reg| { + lua.register_userdata_type::(|reg| { reg.add_method("frag", |lua, me, ()| lua.create_string(me.frag())); reg.add_field_method_get("is_regular", |_, me| Ok(me.is_regular())); reg.add_field_method_get("is_search", |_, me| Ok(me.is_search())); @@ -28,7 +28,7 @@ impl Url { reg.add_method("join", |lua, me, other: Value| { Self::cast(lua, match other { Value::String(s) => me.join(s.to_str()?.as_ref()), - Value::UserData(ud) => me.join(&*ud.borrow::()?), + Value::UserData(ud) => me.join(&*ud.borrow::()?), _ => Err("must be a string or a Url".into_lua_err())?, }) }); @@ -38,24 +38,24 @@ impl Url { reg.add_method("starts_with", |_, me, base: Value| { Ok(match base { Value::String(s) => me.starts_with(s.to_str()?.as_ref()), - Value::UserData(ud) => me.starts_with(&*ud.borrow::()?), + Value::UserData(ud) => me.starts_with(&*ud.borrow::()?), _ => Err("must be a string or a Url".into_lua_err())?, }) }); reg.add_method("ends_with", |_, me, child: Value| { Ok(match child { Value::String(s) => me.ends_with(s.to_str()?.as_ref()), - Value::UserData(ud) => me.ends_with(&*ud.borrow::()?), + Value::UserData(ud) => me.ends_with(&*ud.borrow::()?), _ => Err("must be a string or a Url".into_lua_err())?, }) }); reg.add_method("strip_prefix", |lua, me, base: Value| { let path = match base { Value::String(s) => me.strip_prefix(s.to_str()?.as_ref()), - Value::UserData(ud) => me.strip_prefix(&*ud.borrow::()?), + Value::UserData(ud) => me.strip_prefix(&*ud.borrow::()?), _ => Err("must be a string or a Url".into_lua_err())?, }; - path.ok().map(|p| Self::cast(lua, yazi_shared::fs::Url::from(p))).transpose() + path.ok().map(|p| Self::cast(lua, yazi_shared::url::Url::from(p))).transpose() }); reg.add_meta_method(MetaMethod::Eq, |_, me, other: UrlRef| Ok(me == &*other)); @@ -72,12 +72,12 @@ impl Url { lua.globals().raw_set( "Url", lua.create_function(|lua, url: mlua::String| { - Self::cast(lua, yazi_shared::fs::Url::from(url.to_str()?.as_ref())) + Self::cast(lua, yazi_shared::url::Url::from(url.to_str()?.as_ref())) })?, ) } } -impl> Cast for Url { +impl> Cast for Url { fn cast(lua: &Lua, data: T) -> mlua::Result { lua.create_any_userdata(data.into()) } } diff --git a/yazi-plugin/src/utils/preview.rs b/yazi-plugin/src/utils/preview.rs index 382ade42..2802f47c 100644 --- a/yazi-plugin/src/utils/preview.rs +++ b/yazi-plugin/src/utils/preview.rs @@ -7,8 +7,8 @@ use super::Utils; use crate::{elements::{Area, Rect, Renderable, Text, WRAP, WRAP_NO}, external::Highlighter, file::FileRef}; pub struct PreviewLock { - pub url: yazi_shared::fs::Url, - pub cha: yazi_shared::fs::Cha, + pub url: yazi_shared::url::Url, + pub cha: yazi_fs::Cha, pub mime: String, pub skip: usize, diff --git a/yazi-plugin/src/utils/spot.rs b/yazi-plugin/src/utils/spot.rs index 40b0fafa..a08a55bd 100644 --- a/yazi-plugin/src/utils/spot.rs +++ b/yazi-plugin/src/utils/spot.rs @@ -7,8 +7,8 @@ use super::Utils; use crate::{elements::Renderable, file::FileRef}; pub struct SpotLock { - pub url: yazi_shared::fs::Url, - pub cha: yazi_shared::fs::Cha, + pub url: yazi_shared::url::Url, + pub cha: yazi_fs::Cha, pub mime: String, pub skip: usize, diff --git a/yazi-proxy/src/manager.rs b/yazi-proxy/src/manager.rs index c5e1aad5..0a654e55 100644 --- a/yazi-proxy/src/manager.rs +++ b/yazi-proxy/src/manager.rs @@ -1,5 +1,5 @@ use yazi_macro::emit; -use yazi_shared::{Id, Layer, event::Cmd, fs::Url}; +use yazi_shared::{Id, Layer, event::Cmd, url::Url}; use crate::options::OpenDoOpt; diff --git a/yazi-proxy/src/options/open.rs b/yazi-proxy/src/options/open.rs index 48a7c60a..0882ff4b 100644 --- a/yazi-proxy/src/options/open.rs +++ b/yazi-proxy/src/options/open.rs @@ -1,7 +1,7 @@ use std::borrow::Cow; use yazi_config::open::Opener; -use yazi_shared::{event::CmdCow, fs::Url}; +use yazi_shared::{event::CmdCow, url::Url}; // --- Open #[derive(Default)] diff --git a/yazi-proxy/src/tab.rs b/yazi-proxy/src/tab.rs index b47b05ce..210ed663 100644 --- a/yazi-proxy/src/tab.rs +++ b/yazi-proxy/src/tab.rs @@ -1,5 +1,5 @@ use yazi_macro::emit; -use yazi_shared::{Layer, event::Cmd, fs::Url}; +use yazi_shared::{Layer, event::Cmd, url::Url}; use crate::options::SearchOpt; diff --git a/yazi-proxy/src/tasks.rs b/yazi-proxy/src/tasks.rs index 428a82c0..44dc76fe 100644 --- a/yazi-proxy/src/tasks.rs +++ b/yazi-proxy/src/tasks.rs @@ -3,7 +3,7 @@ use std::{borrow::Cow, ffi::OsString}; use tokio::sync::oneshot; use yazi_config::open::Opener; use yazi_macro::emit; -use yazi_shared::{Layer, event::Cmd, fs::Url}; +use yazi_shared::{Layer, event::Cmd, url::Url}; use crate::options::{OpenWithOpt, ProcessExecOpt}; diff --git a/yazi-scheduler/Cargo.toml b/yazi-scheduler/Cargo.toml index 330b89bd..50dd3767 100644 --- a/yazi-scheduler/Cargo.toml +++ b/yazi-scheduler/Cargo.toml @@ -11,6 +11,7 @@ repository = "https://github.com/sxyazi/yazi" [dependencies] yazi-config = { path = "../yazi-config", version = "0.3.3" } yazi-dds = { path = "../yazi-dds", version = "0.3.3" } +yazi-fs = { path = "../yazi-fs", version = "0.3.3" } yazi-macro = { path = "../yazi-macro", version = "0.3.3" } yazi-plugin = { path = "../yazi-plugin", version = "0.3.3" } yazi-proxy = { path = "../yazi-proxy", version = "0.3.3" } diff --git a/yazi-scheduler/src/file/file.rs b/yazi-scheduler/src/file/file.rs index e46cdae5..1cf403a9 100644 --- a/yazi-scheduler/src/file/file.rs +++ b/yazi-scheduler/src/file/file.rs @@ -4,7 +4,8 @@ use anyhow::{Result, anyhow}; use tokio::{fs::{self, DirEntry}, io::{self, ErrorKind::{AlreadyExists, NotFound}}, sync::mpsc}; use tracing::warn; use yazi_config::TASKS; -use yazi_shared::fs::{Cha, Url, calculate_size, copy_with_progress, maybe_exists, ok_or_not_found, path_relative_to}; +use yazi_fs::{Cha, calculate_size, copy_with_progress, maybe_exists, ok_or_not_found, path_relative_to}; +use yazi_shared::url::Url; use super::{FileOp, FileOpDelete, FileOpHardlink, FileOpLink, FileOpPaste, FileOpTrash}; use crate::{LOW, NORMAL, TaskOp, TaskProg}; diff --git a/yazi-scheduler/src/file/op.rs b/yazi-scheduler/src/file/op.rs index b88019d7..dd0c474c 100644 --- a/yazi-scheduler/src/file/op.rs +++ b/yazi-scheduler/src/file/op.rs @@ -1,4 +1,5 @@ -use yazi_shared::fs::{Cha, Url}; +use yazi_fs::Cha; +use yazi_shared::url::Url; #[derive(Debug)] pub enum FileOp { diff --git a/yazi-scheduler/src/prework/op.rs b/yazi-scheduler/src/prework/op.rs index 3532dd6a..0a749f09 100644 --- a/yazi-scheduler/src/prework/op.rs +++ b/yazi-scheduler/src/prework/op.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use yazi_config::plugin::{Fetcher, Preloader}; -use yazi_shared::{Throttle, fs::Url}; +use yazi_shared::{Throttle, url::Url}; #[derive(Debug)] pub enum PreworkOp { @@ -24,14 +24,14 @@ impl PreworkOp { pub struct PreworkOpFetch { pub id: usize, pub plugin: &'static Fetcher, - pub targets: Vec, + pub targets: Vec, } #[derive(Clone, Debug)] pub struct PreworkOpLoad { pub id: usize, pub plugin: &'static Preloader, - pub target: yazi_shared::fs::File, + pub target: yazi_fs::File, } #[derive(Debug)] diff --git a/yazi-scheduler/src/prework/prework.rs b/yazi-scheduler/src/prework/prework.rs index 5bb75c2a..084b8944 100644 --- a/yazi-scheduler/src/prework/prework.rs +++ b/yazi-scheduler/src/prework/prework.rs @@ -5,8 +5,9 @@ use parking_lot::{Mutex, RwLock}; use tokio::sync::mpsc; use tracing::error; use yazi_config::Priority; +use yazi_fs::{FilesOp, calculate_size}; use yazi_plugin::isolate; -use yazi_shared::{event::CmdCow, fs::{FilesOp, Url, calculate_size}}; +use yazi_shared::{event::CmdCow, url::Url}; use super::{PreworkOp, PreworkOpFetch, PreworkOpLoad, PreworkOpSize}; use crate::{HIGH, NORMAL, TaskOp, TaskProg}; diff --git a/yazi-scheduler/src/scheduler.rs b/yazi-scheduler/src/scheduler.rs index 6299c603..4527b462 100644 --- a/yazi-scheduler/src/scheduler.rs +++ b/yazi-scheduler/src/scheduler.rs @@ -6,8 +6,9 @@ use parking_lot::Mutex; use tokio::{fs, select, sync::{mpsc::{self, UnboundedReceiver}, oneshot}, task::JoinHandle}; use yazi_config::{TASKS, open::Opener, plugin::{Fetcher, Preloader}}; use yazi_dds::Pump; +use yazi_fs::{must_be_dir, remove_dir_clean, unique_name}; use yazi_proxy::{ManagerProxy, options::PluginOpt}; -use yazi_shared::{Throttle, fs::{Url, must_be_dir, remove_dir_clean, unique_name}}; +use yazi_shared::{Throttle, url::Url}; use super::{Ongoing, TaskProg, TaskStage}; use crate::{HIGH, LOW, NORMAL, TaskKind, TaskOp, file::{File, FileOpDelete, FileOpHardlink, FileOpLink, FileOpPaste, FileOpTrash}, plugin::{Plugin, PluginOpEntry}, prework::{Prework, PreworkOpFetch, PreworkOpLoad, PreworkOpSize}, process::{Process, ProcessOpBg, ProcessOpBlock, ProcessOpOrphan}}; @@ -219,7 +220,7 @@ impl Scheduler { self.plugin.macro_(PluginOpEntry { id, opt }).ok(); } - pub fn fetch_paged(&self, fetcher: &'static Fetcher, targets: Vec) { + pub fn fetch_paged(&self, fetcher: &'static Fetcher, targets: Vec) { let id = self.ongoing.lock().add( TaskKind::Preload, format!("Run fetcher `{}` with {} target(s)", fetcher.run.name, targets.len()), @@ -231,7 +232,7 @@ impl Scheduler { }); } - pub fn preload_paged(&self, preloader: &'static Preloader, target: &yazi_shared::fs::File) { + pub fn preload_paged(&self, preloader: &'static Preloader, target: &yazi_fs::File) { let id = self.ongoing.lock().add(TaskKind::Preload, format!("Run preloader `{}`", preloader.run.name)); diff --git a/yazi-shared/Cargo.toml b/yazi-shared/Cargo.toml index 12568fe1..ddacc32a 100644 --- a/yazi-shared/Cargo.toml +++ b/yazi-shared/Cargo.toml @@ -14,24 +14,21 @@ yazi-macro = { path = "../yazi-macro", version = "0.3.3" } # External dependencies anyhow = { workspace = true } -bitflags = { workspace = true } crossterm = { workspace = true } -dirs = { workspace = true } futures = { workspace = true } -libc = { workspace = true } parking_lot = { workspace = true } percent-encoding = "2.3.1" ratatui = { workspace = true } -regex = { workspace = true } serde = { workspace = true } shell-words = { workspace = true } tokio = { workspace = true } [target."cfg(unix)".dependencies] +libc = { workspace = true } uzers = { workspace = true } [target.'cfg(windows)'.dependencies] -windows-sys = { version = "0.59.0", features = [ "Win32_Storage_FileSystem", "Win32_UI_Shell" ] } +windows-sys = { version = "0.59.0", features = [ "Win32_UI_Shell" ] } [target.'cfg(target_os = "macos")'.dependencies] crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] } diff --git a/yazi-shared/src/event/cmd.rs b/yazi-shared/src/event/cmd.rs index 7b823417..2ece1917 100644 --- a/yazi-shared/src/event/cmd.rs +++ b/yazi-shared/src/event/cmd.rs @@ -4,7 +4,7 @@ use anyhow::{Result, bail}; use serde::{Deserialize, de}; use super::{Data, DataKey}; -use crate::fs::Url; +use crate::url::Url; #[derive(Debug, Default)] pub struct Cmd { diff --git a/yazi-shared/src/event/cow.rs b/yazi-shared/src/event/cow.rs index 916eaf40..6f6e710c 100644 --- a/yazi-shared/src/event/cow.rs +++ b/yazi-shared/src/event/cow.rs @@ -1,7 +1,7 @@ use std::{borrow::Cow, ops::Deref}; use super::{Cmd, Data, DataKey}; -use crate::fs::Url; +use crate::url::Url; #[derive(Debug)] pub enum CmdCow { diff --git a/yazi-shared/src/event/data.rs b/yazi-shared/src/event/data.rs index fc938aab..d2e3ff2b 100644 --- a/yazi-shared/src/event/data.rs +++ b/yazi-shared/src/event/data.rs @@ -2,7 +2,7 @@ use std::{any::Any, borrow::Cow, collections::HashMap}; use serde::{Deserialize, Serialize, de}; -use crate::{OrderedFloat, fs::Url}; +use crate::{OrderedFloat, url::Url}; // --- Data #[derive(Debug, Serialize, Deserialize)] diff --git a/yazi-shared/src/fs/mod.rs b/yazi-shared/src/fs/mod.rs deleted file mode 100644 index c8b18d8d..00000000 --- a/yazi-shared/src/fs/mod.rs +++ /dev/null @@ -1 +0,0 @@ -yazi_macro::mod_flat!(cha file fns loc op path url urn); diff --git a/yazi-shared/src/lib.rs b/yazi-shared/src/lib.rs index 24bb6f8d..2260781c 100644 --- a/yazi-shared/src/lib.rs +++ b/yazi-shared/src/lib.rs @@ -1,8 +1,8 @@ #![allow(clippy::option_map_unit_fn)] -yazi_macro::mod_pub!(errors event fs shell theme translit); +yazi_macro::mod_pub!(errors event shell theme translit url); -yazi_macro::mod_flat!(chars condition debounce either env id layer natsort number os rand ro_cell sync_cell terminal throttle time xdg); +yazi_macro::mod_flat!(chars condition debounce either env id layer natsort number os rand ro_cell sync_cell terminal throttle time); pub fn init() { #[cfg(unix)] diff --git a/yazi-shared/src/shell/windows.rs b/yazi-shared/src/shell/windows.rs index bed10dc5..ab436dba 100644 --- a/yazi-shared/src/shell/windows.rs +++ b/yazi-shared/src/shell/windows.rs @@ -91,7 +91,11 @@ pub fn split(s: &str) -> std::io::Result> { fn split_slice(s: &[u16]) -> std::io::Result> { use std::mem::MaybeUninit; - use windows_sys::Win32::{Foundation::LocalFree, UI::Shell::CommandLineToArgvW}; + use windows_sys::{Win32::{Foundation::LocalFree, UI::Shell::CommandLineToArgvW}, core::PCWSTR}; + + extern "C" { + fn wcslen(s: PCWSTR) -> usize; + } let mut argc = MaybeUninit::::uninit(); let argv_p = unsafe { CommandLineToArgvW(s.as_ptr(), argc.as_mut_ptr()) }; @@ -102,7 +106,7 @@ fn split_slice(s: &[u16]) -> std::io::Result> { let argv = unsafe { std::slice::from_raw_parts(argv_p, argc.assume_init() as usize) }; let mut res = vec![]; for &arg in argv { - let len = unsafe { libc::wcslen(arg) }; + let len = unsafe { wcslen(arg) }; res.push(String::from_utf16_lossy(unsafe { std::slice::from_raw_parts(arg, len) })); } diff --git a/yazi-shared/src/fs/loc.rs b/yazi-shared/src/url/loc.rs similarity index 99% rename from yazi-shared/src/fs/loc.rs rename to yazi-shared/src/url/loc.rs index 332c48d5..c94193c6 100644 --- a/yazi-shared/src/fs/loc.rs +++ b/yazi-shared/src/url/loc.rs @@ -1,6 +1,6 @@ use std::{cmp, ffi::{OsStr, OsString}, fmt::{self, Debug, Formatter}, hash::{Hash, Hasher}, ops::Deref, path::{Path, PathBuf}}; -use super::{Urn, UrnBuf}; +use crate::url::{Urn, UrnBuf}; #[derive(Clone, Default)] pub struct Loc { diff --git a/yazi-shared/src/url/mod.rs b/yazi-shared/src/url/mod.rs new file mode 100644 index 00000000..a2f1a4a6 --- /dev/null +++ b/yazi-shared/src/url/mod.rs @@ -0,0 +1 @@ +yazi_macro::mod_flat!(loc url urn); diff --git a/yazi-shared/src/fs/url.rs b/yazi-shared/src/url/url.rs similarity index 99% rename from yazi-shared/src/fs/url.rs rename to yazi-shared/src/url/url.rs index 28114467..144b853d 100644 --- a/yazi-shared/src/fs/url.rs +++ b/yazi-shared/src/url/url.rs @@ -3,7 +3,8 @@ use std::{ffi::OsStr, fmt::{Debug, Display, Formatter}, ops::Deref, path::{Path, use percent_encoding::{AsciiSet, CONTROLS, percent_decode_str, percent_encode}; use serde::{Deserialize, Serialize}; -use super::{Loc, UrnBuf}; +use super::UrnBuf; +use crate::url::Loc; const ENCODE_SET: &AsciiSet = &CONTROLS.add(b'#'); diff --git a/yazi-shared/src/fs/urn.rs b/yazi-shared/src/url/urn.rs similarity index 100% rename from yazi-shared/src/fs/urn.rs rename to yazi-shared/src/url/urn.rs