feat: custom search engine Lua API (#2452)

This commit is contained in:
三咲雅 · Misaki Masa 2025-03-07 16:41:15 +08:00 committed by sxyazi
parent dc46e90b0a
commit a2bbd29289
No known key found for this signature in database
26 changed files with 216 additions and 119 deletions

34
Cargo.lock generated
View file

@ -2595,9 +2595,9 @@ dependencies = [
[[package]]
name = "time"
version = "0.3.38"
version = "0.3.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb041120f25f8fbe8fd2dbe4671c7c2ed74d83be2e7a77529bf7e0790ae3f472"
checksum = "dad298b01a40a23aac4580b67e3dbedb7cc8402f3592d7f49469de2ea4aecdd8"
dependencies = [
"deranged",
"itoa",
@ -3321,7 +3321,7 @@ checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51"
[[package]]
name = "yazi-adapter"
version = "25.3.2"
version = "25.3.7"
dependencies = [
"ansi-to-tui",
"anyhow",
@ -3342,7 +3342,7 @@ dependencies = [
[[package]]
name = "yazi-boot"
version = "25.3.2"
version = "25.3.7"
dependencies = [
"clap",
"clap_complete",
@ -3360,7 +3360,7 @@ dependencies = [
[[package]]
name = "yazi-cli"
version = "25.3.2"
version = "25.3.7"
dependencies = [
"anyhow",
"clap",
@ -3383,7 +3383,7 @@ dependencies = [
[[package]]
name = "yazi-codegen"
version = "25.3.2"
version = "25.3.7"
dependencies = [
"quote",
"syn",
@ -3391,7 +3391,7 @@ dependencies = [
[[package]]
name = "yazi-config"
version = "25.3.2"
version = "25.3.7"
dependencies = [
"anyhow",
"bitflags 2.9.0",
@ -3411,7 +3411,7 @@ dependencies = [
[[package]]
name = "yazi-core"
version = "25.3.2"
version = "25.3.7"
dependencies = [
"anyhow",
"bitflags 2.9.0",
@ -3445,7 +3445,7 @@ dependencies = [
[[package]]
name = "yazi-dds"
version = "25.3.2"
version = "25.3.7"
dependencies = [
"anyhow",
"mlua",
@ -3466,7 +3466,7 @@ dependencies = [
[[package]]
name = "yazi-ffi"
version = "25.3.2"
version = "25.3.7"
dependencies = [
"anyhow",
"core-foundation-sys",
@ -3477,7 +3477,7 @@ dependencies = [
[[package]]
name = "yazi-fm"
version = "25.3.2"
version = "25.3.7"
dependencies = [
"anyhow",
"better-panic",
@ -3513,7 +3513,7 @@ dependencies = [
[[package]]
name = "yazi-fs"
version = "25.3.2"
version = "25.3.7"
dependencies = [
"anyhow",
"arc-swap",
@ -3539,11 +3539,11 @@ dependencies = [
[[package]]
name = "yazi-macro"
version = "25.3.2"
version = "25.3.7"
[[package]]
name = "yazi-plugin"
version = "25.3.2"
version = "25.3.7"
dependencies = [
"ansi-to-tui",
"anyhow",
@ -3584,7 +3584,7 @@ checksum = "f4b6c8e12e39ac0f79fa96f36e5b88e0da8d230691abd729eec709b43c74f632"
[[package]]
name = "yazi-proxy"
version = "25.3.2"
version = "25.3.7"
dependencies = [
"anyhow",
"mlua",
@ -3597,7 +3597,7 @@ dependencies = [
[[package]]
name = "yazi-scheduler"
version = "25.3.2"
version = "25.3.7"
dependencies = [
"anyhow",
"async-priority-channel",
@ -3620,7 +3620,7 @@ dependencies = [
[[package]]
name = "yazi-shared"
version = "25.3.2"
version = "25.3.7"
dependencies = [
"anyhow",
"crossterm",

View file

@ -1,6 +1,6 @@
[package]
name = "yazi-adapter"
version = "25.3.2"
version = "25.3.7"
edition = "2021"
license = "MIT"
authors = [ "sxyazi <sxyazi@gmail.com>" ]
@ -9,9 +9,9 @@ homepage = "https://yazi-rs.github.io"
repository = "https://github.com/sxyazi/yazi"
[dependencies]
yazi-config = { path = "../yazi-config", version = "25.3.2" }
yazi-macro = { path = "../yazi-macro", version = "25.3.2" }
yazi-shared = { path = "../yazi-shared", version = "25.3.2" }
yazi-config = { path = "../yazi-config", version = "25.3.7" }
yazi-macro = { path = "../yazi-macro", version = "25.3.7" }
yazi-shared = { path = "../yazi-shared", version = "25.3.7" }
# External dependencies
ansi-to-tui = { workspace = true }

View file

@ -1,6 +1,6 @@
[package]
name = "yazi-boot"
version = "25.3.2"
version = "25.3.7"
edition = "2021"
license = "MIT"
authors = [ "sxyazi <sxyazi@gmail.com>" ]
@ -9,11 +9,11 @@ homepage = "https://yazi-rs.github.io"
repository = "https://github.com/sxyazi/yazi"
[dependencies]
yazi-adapter = { path = "../yazi-adapter", version = "25.3.2" }
yazi-config = { path = "../yazi-config", version = "25.3.2" }
yazi-fs = { path = "../yazi-fs", version = "25.3.2" }
yazi-macro = { path = "../yazi-macro", version = "25.3.2" }
yazi-shared = { path = "../yazi-shared", version = "25.3.2" }
yazi-adapter = { path = "../yazi-adapter", version = "25.3.7" }
yazi-config = { path = "../yazi-config", version = "25.3.7" }
yazi-fs = { path = "../yazi-fs", version = "25.3.7" }
yazi-macro = { path = "../yazi-macro", version = "25.3.7" }
yazi-shared = { path = "../yazi-shared", version = "25.3.7" }
# External dependencies
clap = { workspace = true }

View file

@ -1,6 +1,6 @@
[package]
name = "yazi-cli"
version = "25.3.2"
version = "25.3.7"
edition = "2021"
license = "MIT"
authors = [ "sxyazi <sxyazi@gmail.com>" ]
@ -9,11 +9,11 @@ homepage = "https://yazi-rs.github.io"
repository = "https://github.com/sxyazi/yazi"
[dependencies]
yazi-boot = { path = "../yazi-boot", version = "25.3.2" }
yazi-dds = { path = "../yazi-dds", version = "25.3.2" }
yazi-fs = { path = "../yazi-fs", version = "25.3.2" }
yazi-macro = { path = "../yazi-macro", version = "25.3.2" }
yazi-shared = { path = "../yazi-shared", version = "25.3.2" }
yazi-boot = { path = "../yazi-boot", version = "25.3.7" }
yazi-dds = { path = "../yazi-dds", version = "25.3.7" }
yazi-fs = { path = "../yazi-fs", version = "25.3.7" }
yazi-macro = { path = "../yazi-macro", version = "25.3.7" }
yazi-shared = { path = "../yazi-shared", version = "25.3.7" }
# External dependencies
anyhow = { workspace = true }
@ -26,7 +26,7 @@ toml = { workspace = true }
twox-hash = { workspace = true }
[build-dependencies]
yazi-shared = { path = "../yazi-shared", version = "25.3.2" }
yazi-shared = { path = "../yazi-shared", version = "25.3.7" }
# External build dependencies
anyhow = { workspace = true }

View file

@ -1,6 +1,6 @@
[package]
name = "yazi-codegen"
version = "25.3.2"
version = "25.3.7"
edition = "2021"
license = "MIT"
authors = [ "sxyazi <sxyazi@gmail.com>" ]

View file

@ -1,6 +1,6 @@
[package]
name = "yazi-config"
version = "25.3.2"
version = "25.3.7"
edition = "2021"
license = "MIT"
authors = [ "sxyazi <sxyazi@gmail.com>" ]
@ -9,9 +9,9 @@ homepage = "https://yazi-rs.github.io"
repository = "https://github.com/sxyazi/yazi"
[dependencies]
yazi-fs = { path = "../yazi-fs", version = "25.3.2" }
yazi-macro = { path = "../yazi-macro", version = "25.3.2" }
yazi-shared = { path = "../yazi-shared", version = "25.3.2" }
yazi-fs = { path = "../yazi-fs", version = "25.3.7" }
yazi-macro = { path = "../yazi-macro", version = "25.3.7" }
yazi-shared = { path = "../yazi-shared", version = "25.3.7" }
# External dependencies
anyhow = { workspace = true }

View file

@ -1,6 +1,6 @@
[package]
name = "yazi-core"
version = "25.3.2"
version = "25.3.7"
edition = "2021"
license = "MIT"
authors = [ "sxyazi <sxyazi@gmail.com>" ]
@ -9,17 +9,17 @@ homepage = "https://yazi-rs.github.io"
repository = "https://github.com/sxyazi/yazi"
[dependencies]
yazi-adapter = { path = "../yazi-adapter", version = "25.3.2" }
yazi-boot = { path = "../yazi-boot", version = "25.3.2" }
yazi-codegen = { path = "../yazi-codegen", version = "25.3.2" }
yazi-config = { path = "../yazi-config", version = "25.3.2" }
yazi-dds = { path = "../yazi-dds", version = "25.3.2" }
yazi-fs = { path = "../yazi-fs", version = "25.3.2" }
yazi-macro = { path = "../yazi-macro", version = "25.3.2" }
yazi-plugin = { path = "../yazi-plugin", version = "25.3.2" }
yazi-proxy = { path = "../yazi-proxy", version = "25.3.2" }
yazi-scheduler = { path = "../yazi-scheduler", version = "25.3.2" }
yazi-shared = { path = "../yazi-shared", version = "25.3.2" }
yazi-adapter = { path = "../yazi-adapter", version = "25.3.7" }
yazi-boot = { path = "../yazi-boot", version = "25.3.7" }
yazi-codegen = { path = "../yazi-codegen", version = "25.3.7" }
yazi-config = { path = "../yazi-config", version = "25.3.7" }
yazi-dds = { path = "../yazi-dds", version = "25.3.7" }
yazi-fs = { path = "../yazi-fs", version = "25.3.7" }
yazi-macro = { path = "../yazi-macro", version = "25.3.7" }
yazi-plugin = { path = "../yazi-plugin", version = "25.3.7" }
yazi-proxy = { path = "../yazi-proxy", version = "25.3.7" }
yazi-scheduler = { path = "../yazi-scheduler", version = "25.3.7" }
yazi-shared = { path = "../yazi-shared", version = "25.3.7" }
# External dependencies
anyhow = { workspace = true }

View file

@ -1,6 +1,6 @@
[package]
name = "yazi-dds"
version = "25.3.2"
version = "25.3.7"
edition = "2021"
license = "MIT"
authors = [ "sxyazi <sxyazi@gmail.com>" ]
@ -13,10 +13,10 @@ default = [ "vendored-lua" ]
vendored-lua = [ "mlua/vendored" ]
[dependencies]
yazi-boot = { path = "../yazi-boot", version = "25.3.2" }
yazi-fs = { path = "../yazi-fs", version = "25.3.2" }
yazi-macro = { path = "../yazi-macro", version = "25.3.2" }
yazi-shared = { path = "../yazi-shared", version = "25.3.2" }
yazi-boot = { path = "../yazi-boot", version = "25.3.7" }
yazi-fs = { path = "../yazi-fs", version = "25.3.7" }
yazi-macro = { path = "../yazi-macro", version = "25.3.7" }
yazi-shared = { path = "../yazi-shared", version = "25.3.7" }
# External dependencies
anyhow = { workspace = true }

View file

@ -43,6 +43,8 @@ impl Sendable {
Value::UserData(ud) => {
if let Ok(t) = ud.take::<yazi_shared::url::Url>() {
Data::Url(t)
} else if let Ok(t) = ud.take::<yazi_fs::FilesOp>() {
Data::Any(Box::new(t))
} else if let Ok(t) = ud.take::<super::body::BodyYankIter>() {
Data::Any(Box::new(t))
} else {
@ -72,13 +74,13 @@ impl Sendable {
Value::Table(tbl)
}
Data::Url(u) => Value::UserData(lua.create_any_userdata(u)?),
Data::Any(a) => {
if let Ok(t) = a.downcast::<super::body::BodyYankIter>() {
Value::UserData(lua.create_userdata(*t)?)
} else {
Err("unsupported userdata included".into_lua_err())?
}
}
Data::Any(a) => Value::UserData(if a.is::<yazi_fs::FilesOp>() {
lua.create_any_userdata(*a.downcast::<yazi_fs::FilesOp>().unwrap())?
} else if a.is::<super::body::BodyYankIter>() {
lua.create_userdata(*a.downcast::<super::body::BodyYankIter>().unwrap())?
} else {
Err("unsupported userdata included".into_lua_err())?
}),
data => Self::data_to_value_ref(lua, &data)?,
})
}
@ -107,13 +109,13 @@ impl Sendable {
}
Data::Url(u) => Value::UserData(lua.create_any_userdata(u.clone())?),
Data::Bytes(b) => Value::String(lua.create_string(b)?),
Data::Any(a) => {
if let Some(t) = a.downcast_ref::<super::body::BodyYankIter>() {
Value::UserData(lua.create_userdata(t.clone())?)
} else {
Err("unsupported userdata included".into_lua_err())?
}
}
Data::Any(a) => Value::UserData(if let Some(t) = a.downcast_ref::<yazi_fs::FilesOp>() {
lua.create_any_userdata(t.clone())?
} else if let Some(t) = a.downcast_ref::<super::body::BodyYankIter>() {
lua.create_userdata(t.clone())?
} else {
Err("unsupported userdata included".into_lua_err())?
}),
})
}

View file

@ -1,6 +1,6 @@
[package]
name = "yazi-ffi"
version = "25.3.2"
version = "25.3.7"
edition = "2021"
license = "MIT"
authors = [ "sxyazi <sxyazi@gmail.com>" ]
@ -9,7 +9,7 @@ homepage = "https://yazi-rs.github.io"
repository = "https://github.com/sxyazi/yazi"
[dependencies]
yazi-macro = { path = "../yazi-macro", version = "25.3.2" }
yazi-macro = { path = "../yazi-macro", version = "25.3.7" }
# External dependencies
anyhow = { workspace = true }

View file

@ -1,6 +1,6 @@
[package]
name = "yazi-fm"
version = "25.3.2"
version = "25.3.7"
edition = "2021"
license = "MIT"
authors = [ "sxyazi <sxyazi@gmail.com>" ]
@ -13,17 +13,17 @@ default = [ "vendored-lua" ]
vendored-lua = [ "mlua/vendored" ]
[dependencies]
yazi-adapter = { path = "../yazi-adapter", version = "25.3.2" }
yazi-boot = { path = "../yazi-boot", version = "25.3.2" }
yazi-codegen = { path = "../yazi-codegen", version = "25.3.2" }
yazi-config = { path = "../yazi-config", version = "25.3.2" }
yazi-core = { path = "../yazi-core", version = "25.3.2" }
yazi-dds = { path = "../yazi-dds", version = "25.3.2" }
yazi-fs = { path = "../yazi-fs", version = "25.3.2" }
yazi-macro = { path = "../yazi-macro", version = "25.3.2" }
yazi-plugin = { path = "../yazi-plugin", version = "25.3.2" }
yazi-proxy = { path = "../yazi-proxy", version = "25.3.2" }
yazi-shared = { path = "../yazi-shared", version = "25.3.2" }
yazi-adapter = { path = "../yazi-adapter", version = "25.3.7" }
yazi-boot = { path = "../yazi-boot", version = "25.3.7" }
yazi-codegen = { path = "../yazi-codegen", version = "25.3.7" }
yazi-config = { path = "../yazi-config", version = "25.3.7" }
yazi-core = { path = "../yazi-core", version = "25.3.7" }
yazi-dds = { path = "../yazi-dds", version = "25.3.7" }
yazi-fs = { path = "../yazi-fs", version = "25.3.7" }
yazi-macro = { path = "../yazi-macro", version = "25.3.7" }
yazi-plugin = { path = "../yazi-plugin", version = "25.3.7" }
yazi-proxy = { path = "../yazi-proxy", version = "25.3.7" }
yazi-shared = { path = "../yazi-shared", version = "25.3.7" }
# External dependencies
anyhow = { workspace = true }

View file

@ -1,6 +1,6 @@
[package]
name = "yazi-fs"
version = "25.3.2"
version = "25.3.7"
edition = "2021"
license = "MIT"
authors = [ "sxyazi <sxyazi@gmail.com>" ]
@ -9,9 +9,9 @@ homepage = "https://yazi-rs.github.io"
repository = "https://github.com/sxyazi/yazi"
[dependencies]
yazi-ffi = { path = "../yazi-ffi", version = "25.3.2" }
yazi-macro = { path = "../yazi-macro", version = "25.3.2" }
yazi-shared = { path = "../yazi-shared", version = "25.3.2" }
yazi-ffi = { path = "../yazi-ffi", version = "25.3.7" }
yazi-macro = { path = "../yazi-macro", version = "25.3.7" }
yazi-shared = { path = "../yazi-shared", version = "25.3.7" }
# External dependencies
anyhow = { workspace = true }

View file

@ -1,6 +1,6 @@
[package]
name = "yazi-macro"
version = "25.3.2"
version = "25.3.7"
edition = "2021"
license = "MIT"
authors = [ "sxyazi <sxyazi@gmail.com>" ]

View file

@ -1,6 +1,6 @@
[package]
name = "yazi-plugin"
version = "25.3.2"
version = "25.3.7"
edition = "2021"
license = "MIT"
authors = [ "sxyazi <sxyazi@gmail.com>" ]
@ -13,14 +13,14 @@ default = [ "vendored-lua" ]
vendored-lua = [ "mlua/vendored" ]
[dependencies]
yazi-adapter = { path = "../yazi-adapter", version = "25.3.2" }
yazi-boot = { path = "../yazi-boot", version = "25.3.2" }
yazi-config = { path = "../yazi-config", version = "25.3.2" }
yazi-dds = { path = "../yazi-dds", version = "25.3.2" }
yazi-fs = { path = "../yazi-fs", version = "25.3.2" }
yazi-macro = { path = "../yazi-macro", version = "25.3.2" }
yazi-proxy = { path = "../yazi-proxy", version = "25.3.2" }
yazi-shared = { path = "../yazi-shared", version = "25.3.2" }
yazi-adapter = { path = "../yazi-adapter", version = "25.3.7" }
yazi-boot = { path = "../yazi-boot", version = "25.3.7" }
yazi-config = { path = "../yazi-config", version = "25.3.7" }
yazi-dds = { path = "../yazi-dds", version = "25.3.7" }
yazi-fs = { path = "../yazi-fs", version = "25.3.7" }
yazi-macro = { path = "../yazi-macro", version = "25.3.7" }
yazi-proxy = { path = "../yazi-proxy", version = "25.3.7" }
yazi-shared = { path = "../yazi-shared", version = "25.3.7" }
# External dependencies
ansi-to-tui = { workspace = true }

View file

@ -1,4 +1,4 @@
use mlua::{AnyUserData, IntoLua, Lua, Table, UserDataRef};
use mlua::{AnyUserData, ExternalError, FromLua, IntoLua, Lua, Table, UserDataRef, Value};
use crate::{bindings::Cha, impl_file_fields, impl_file_methods};
@ -29,8 +29,17 @@ impl File {
}
}
impl FromLua for File {
fn from_lua(value: Value, _: &Lua) -> mlua::Result<Self> {
match value {
Value::UserData(ud) => ud.take().map(Self),
_ => Err("Expected a File".into_lua_err()),
}
}
}
impl IntoLua for File {
fn into_lua(self, lua: &Lua) -> mlua::Result<mlua::Value> {
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> {
lua.create_any_userdata(self.0)?.into_lua(lua)
}
}

View file

@ -8,6 +8,7 @@ use crate::{Composer, Error, bindings::Cha, file::File, url::{Url, UrlRef}};
pub fn compose(lua: &Lua) -> mlua::Result<Value> {
Composer::make(lua, 10, |lua, key| {
match key {
b"op" => op(lua)?,
b"cwd" => cwd(lua)?,
b"cha" => cha(lua)?,
b"write" => write(lua)?,
@ -22,6 +23,14 @@ pub fn compose(lua: &Lua) -> mlua::Result<Value> {
})
}
fn op(lua: &Lua) -> mlua::Result<Function> {
lua.create_function(|lua, (name, t): (mlua::String, Table)| match name.as_bytes().as_ref() {
b"part" => super::FilesOp::part(lua, t),
b"done" => super::FilesOp::done(lua, t),
_ => Err("Unknown operation".into_lua_err())?,
})
}
fn cwd(lua: &Lua) -> mlua::Result<Function> {
lua.create_function(|lua, ()| match std::env::current_dir() {
Ok(p) => (Url::from(p), Value::Nil).into_lua_multi(lua),

View file

@ -1,3 +1,3 @@
#![allow(clippy::module_inception)]
yazi_macro::mod_flat!(fs);
yazi_macro::mod_flat!(fs op);

33
yazi-plugin/src/fs/op.rs Normal file
View file

@ -0,0 +1,33 @@
use mlua::{IntoLua, Lua, Table};
use crate::{Id, bindings::Cha, file::File, url::Url};
pub(super) struct FilesOp(yazi_fs::FilesOp);
impl FilesOp {
pub(super) fn part(_: &Lua, t: Table) -> mlua::Result<Self> {
let id: Id = t.raw_get("id")?;
let url: Url = t.raw_get("url")?;
let files: Table = t.raw_get("files")?;
Ok(Self(yazi_fs::FilesOp::Part(
url.0,
files.sequence_values::<File>().map(|f| f.map(|f| f.0)).collect::<mlua::Result<Vec<_>>>()?,
*id,
)))
}
pub(super) fn done(_: &Lua, t: Table) -> mlua::Result<Self> {
let id: Id = t.raw_get("id")?;
let cha: Cha = t.raw_get("cha")?;
let url: Url = t.raw_get("url")?;
Ok(Self(yazi_fs::FilesOp::Done(url.0, *cha, *id)))
}
}
impl IntoLua for FilesOp {
fn into_lua(self, lua: &Lua) -> mlua::Result<mlua::Value> {
lua.create_any_userdata(self.0)?.into_lua(lua)
}
}

15
yazi-plugin/src/id.rs Normal file
View file

@ -0,0 +1,15 @@
use std::ops::Deref;
use mlua::{FromLua, UserData};
#[derive(Clone, Copy, FromLua)]
pub struct Id(pub yazi_shared::Id);
impl Deref for Id {
type Target = yazi_shared::Id;
#[inline]
fn deref(&self) -> &Self::Target { &self.0 }
}
impl UserData for Id {}

View file

@ -4,7 +4,7 @@ mod macros;
yazi_macro::mod_pub!(bindings config elements external file fs isolate loader process pubsub url utils);
yazi_macro::mod_flat!(clipboard composer error lua runtime);
yazi_macro::mod_flat!(clipboard composer error id lua runtime);
pub fn init() -> anyhow::Result<()> {
CLIPBOARD.with(<_>::default);

View file

@ -1,4 +1,4 @@
use mlua::{ExternalError, IntoLua, Lua, MetaMethod, UserDataFields, UserDataMethods, UserDataRef, Value};
use mlua::{AnyUserData, ExternalError, FromLua, IntoLua, Lua, MetaMethod, UserDataFields, UserDataMethods, UserDataRef, Value};
pub type UrlRef = UserDataRef<yazi_shared::url::Url>;
@ -54,6 +54,10 @@ impl Url {
Ok(path.ok().map(Self::from))
});
reg.add_function_mut("into_search", |_, (ud, frag): (AnyUserData, mlua::String)| {
Ok(Self(ud.take::<yazi_shared::url::Url>()?.into_search(&frag.to_str()?)))
});
reg.add_meta_method(MetaMethod::Eq, |_, me, other: UrlRef| Ok(me == &*other));
reg.add_meta_method(MetaMethod::ToString, |lua, me, ()| {
lua.create_string(me.as_os_str().as_encoded_bytes())
@ -67,7 +71,13 @@ impl Url {
pub fn install(lua: &Lua) -> mlua::Result<()> {
lua.globals().raw_set(
"Url",
lua.create_function(|_, url: mlua::String| Ok(Self::from(url.to_str()?.as_ref())))?,
lua.create_function(|_, value: Value| {
Ok(match value {
Value::String(s) => Self::from(s.to_str()?.as_ref()),
Value::UserData(ud) => Self(ud.borrow::<yazi_shared::url::Url>()?.clone()),
_ => Err("Expected a string or a Url".into_lua_err())?,
})
})?,
)
}
}
@ -76,6 +86,15 @@ impl<T: Into<yazi_shared::url::Url>> From<T> for Url {
fn from(value: T) -> Self { Self(value.into()) }
}
impl FromLua for Url {
fn from_lua(value: Value, _: &Lua) -> mlua::Result<Self> {
match value {
Value::UserData(ud) => ud.take().map(Self),
_ => Err("Expected a Url".into_lua_err()),
}
}
}
impl IntoLua for Url {
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> {
lua.create_any_userdata(self.0)?.into_lua(lua)

View file

@ -2,9 +2,18 @@ use mlua::{AnyUserData, ExternalError, Function, Lua};
use yazi_proxy::{AppProxy, HIDER};
use super::Utils;
use crate::bindings::{Permit, PermitRef};
use crate::{Id, bindings::{Permit, PermitRef}};
impl Utils {
pub(super) fn id(lua: &Lua) -> mlua::Result<Function> {
lua.create_function(|_, type_: mlua::String| {
Ok(Id(match type_.as_bytes().as_ref() {
b"ft" => yazi_fs::FILES_TICKET.next(),
_ => Err("Invalid id type".into_lua_err())?,
}))
})
}
pub(super) fn hide(lua: &Lua) -> mlua::Result<Function> {
lua.create_async_function(|lua, ()| async move {
if lua.named_registry_value::<PermitRef<fn()>>("HIDE_PERMIT").is_ok_and(|h| h.is_some()) {

View file

@ -8,6 +8,7 @@ pub fn compose(lua: &Lua, isolate: bool) -> mlua::Result<Value> {
Composer::make(lua, 45, move |lua, key| {
match key {
// App
b"id" => Utils::id(lua)?,
b"hide" => Utils::hide(lua)?,
// Cache

View file

@ -1,6 +1,6 @@
[package]
name = "yazi-proxy"
version = "25.3.2"
version = "25.3.7"
edition = "2021"
license = "MIT"
authors = [ "sxyazi <sxyazi@gmail.com>" ]
@ -13,9 +13,9 @@ default = [ "vendored-lua" ]
vendored-lua = [ "mlua/vendored" ]
[dependencies]
yazi-config = { path = "../yazi-config", version = "25.3.2" }
yazi-macro = { path = "../yazi-macro", version = "25.3.2" }
yazi-shared = { path = "../yazi-shared", version = "25.3.2" }
yazi-config = { path = "../yazi-config", version = "25.3.7" }
yazi-macro = { path = "../yazi-macro", version = "25.3.7" }
yazi-shared = { path = "../yazi-shared", version = "25.3.7" }
# External dependencies
anyhow = { workspace = true }

View file

@ -1,6 +1,6 @@
[package]
name = "yazi-scheduler"
version = "25.3.2"
version = "25.3.7"
edition = "2021"
license = "MIT"
authors = [ "sxyazi <sxyazi@gmail.com>" ]
@ -9,13 +9,13 @@ homepage = "https://yazi-rs.github.io"
repository = "https://github.com/sxyazi/yazi"
[dependencies]
yazi-config = { path = "../yazi-config", version = "25.3.2" }
yazi-dds = { path = "../yazi-dds", version = "25.3.2" }
yazi-fs = { path = "../yazi-fs", version = "25.3.2" }
yazi-macro = { path = "../yazi-macro", version = "25.3.2" }
yazi-plugin = { path = "../yazi-plugin", version = "25.3.2" }
yazi-proxy = { path = "../yazi-proxy", version = "25.3.2" }
yazi-shared = { path = "../yazi-shared", version = "25.3.2" }
yazi-config = { path = "../yazi-config", version = "25.3.7" }
yazi-dds = { path = "../yazi-dds", version = "25.3.7" }
yazi-fs = { path = "../yazi-fs", version = "25.3.7" }
yazi-macro = { path = "../yazi-macro", version = "25.3.7" }
yazi-plugin = { path = "../yazi-plugin", version = "25.3.7" }
yazi-proxy = { path = "../yazi-proxy", version = "25.3.7" }
yazi-shared = { path = "../yazi-shared", version = "25.3.7" }
# External dependencies
anyhow = { workspace = true }

View file

@ -1,6 +1,6 @@
[package]
name = "yazi-shared"
version = "25.3.2"
version = "25.3.7"
edition = "2021"
license = "MIT"
authors = [ "sxyazi <sxyazi@gmail.com>" ]
@ -10,7 +10,7 @@ repository = "https://github.com/sxyazi/yazi"
rust-version = "1.83.0"
[dependencies]
yazi-macro = { path = "../yazi-macro", version = "25.3.2" }
yazi-macro = { path = "../yazi-macro", version = "25.3.7" }
# External dependencies
anyhow = { workspace = true }