From b1ec6db345f1b2fe67ccf39fd0d2b77d85cb18c5 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 4 Aug 2026 05:09:06 +0900 Subject: feat(plugin): expose the composer object graph to plugins over RPC Widen the R table beyond Composer/IO with InstallationManager, RepositoryManager, repository and package entities, interned by pointer identity through a shared register_entity. Script events answer getComposer/getIO, Composer hands out its graph getters, repositories list their packages as per-variant stubs, package getters cover the extension-installer surface (getRequires only while empty: the Link snapshot encoding does not exist yet), and getInstallPath resolves its package argument back through the R table. Everything else stays an explicit error. Co-Authored-By: Claude Fable 5 --- .../src/event_dispatcher/event_dispatcher.rs | 33 ++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'crates/shirabe/src/event_dispatcher') diff --git a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs index 80131e25..0bfdd7c7 100644 --- a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs +++ b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs @@ -1727,8 +1727,37 @@ pub(crate) fn dispatch_event_method( "isDevMode is only available on script events".to_string(), )), }, - // TODO(plugin): getComposer/getIO/stopPropagation and the rest need full proxying - // of the object graph an event exposes, which does not exist yet. + "getComposer" => match event.as_any().downcast_ref::() { + Some(script_event) => { + let composer = script_event.get_composer().upgrade().ok_or_else(|| { + runtime_throw("the Composer instance of this event is gone".to_string()) + })?; + let rhandle = crate::plugin::php_plugin_proxy::register_composer_entity(&composer); + Ok(crate::plugin::php_plugin_proxy::rust_handle_value( + rhandle, + "Composer\\Composer", + )) + } + None => Err(runtime_throw( + "getComposer is only available on script events".to_string(), + )), + }, + "getIO" => match event.as_any().downcast_ref::() { + Some(script_event) => { + let io = script_event.get_io(); + let class = crate::plugin::php_plugin_proxy::io_stub_class(&io) + .map_err(|error| runtime_throw(error.to_string()))?; + let rhandle = crate::plugin::php_plugin_proxy::register_io_entity(&io); + Ok(crate::plugin::php_plugin_proxy::rust_handle_value( + rhandle, class, + )) + } + None => Err(runtime_throw( + "getIO is only available on script events".to_string(), + )), + }, + // TODO(plugin): stopPropagation and the rest need full proxying of the object graph + // an event exposes, which does not exist yet. other => Err(runtime_throw(format!( "the Event method `{other}` is not available over RPC yet" ))), -- cgit v1.3.1