From d1a27bca1f1e7a2f70f63c4c11c32d1381d606a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E9=9B=85=20misaki=20masa?= Date: Sun, 19 Apr 2026 16:51:56 +0800 Subject: [PATCH] feat: warn `ya.mgr_emit()` of its deprecation (#3902) --- yazi-plugin/src/utils/call.rs | 14 ++++++++++++++ yazi-plugin/src/utils/utils.rs | 1 + 2 files changed, 15 insertions(+) diff --git a/yazi-plugin/src/utils/call.rs b/yazi-plugin/src/utils/call.rs index e22a9b1f..102b824d 100644 --- a/yazi-plugin/src/utils/call.rs +++ b/yazi-plugin/src/utils/call.rs @@ -1,5 +1,6 @@ use mlua::{ExternalError, Function, Lua, Table}; use tokio::sync::mpsc; +use yazi_binding::deprecate; use yazi_dds::Sendable; use yazi_macro::emit; use yazi_shared::{Layer, Source, event::Action}; @@ -15,6 +16,19 @@ impl Utils { }) } + pub(super) fn mgr_emit(lua: &Lua) -> mlua::Result { + lua.create_function(|lua, (name, args): (String, Table)| { + deprecate!(lua, "ya.mgr_emit() has been deprecated since v25.5.28 and will soon-to-be removed in a future release. \n\nUse ya.emit() in your {} instead, see #2653 for details: https://github.com/sxyazi/yazi/pull/2653"); + emit!(Call(Action { + name: name.into(), + args: Sendable::table_to_args(lua, args)?, + layer: Layer::Mgr, + source: Source::Emit, + })); + Ok(()) + }) + } + pub(super) fn exec(lua: &Lua) -> mlua::Result { lua.create_async_function(|lua, (name, args): (String, Table)| async move { let mut action = Action::new(name, Source::Emit, Some(Layer::Mgr))?; diff --git a/yazi-plugin/src/utils/utils.rs b/yazi-plugin/src/utils/utils.rs index 1c886df0..10245716 100644 --- a/yazi-plugin/src/utils/utils.rs +++ b/yazi-plugin/src/utils/utils.rs @@ -17,6 +17,7 @@ pub fn compose( // Call b"emit" => Utils::emit(lua)?, + b"mgr_emit" => Utils::mgr_emit(lua)?, b"exec" => Utils::exec(lua)?, // Image