diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-04 05:09:06 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-04 05:43:34 +0900 |
| commit | b1ec6db345f1b2fe67ccf39fd0d2b77d85cb18c5 (patch) | |
| tree | 47df5e2da9485836c5d176890e48627b145ec854 /crates/shirabe/src/event_dispatcher/event_dispatcher.rs | |
| parent | 80631930a6ca7b64d96a89de61c8b63f302161a8 (diff) | |
| download | php-shirabe-b1ec6db345f1b2fe67ccf39fd0d2b77d85cb18c5.tar.gz php-shirabe-b1ec6db345f1b2fe67ccf39fd0d2b77d85cb18c5.tar.zst php-shirabe-b1ec6db345f1b2fe67ccf39fd0d2b77d85cb18c5.zip | |
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 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/event_dispatcher/event_dispatcher.rs')
| -rw-r--r-- | crates/shirabe/src/event_dispatcher/event_dispatcher.rs | 33 |
1 files changed, 31 insertions, 2 deletions
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::<ScriptEvent>() { + 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::<ScriptEvent>() { + 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" ))), |
