feat(plugins): expose document path to plugins via HostApi

OpenCADStudio/plugins#901 (comment)

- Add HostApi::document_path(tab_id) returning Option<PathBuf>.
- Add PluginRequest::DocumentPath and PluginResponse::DocumentPath for
  out-of-process plugins.
- Implement the request in the IPC server and in both V3/V4 plugin-side
  HostApi proxies.
- Implement HostSession::document_path by looking up the tab by id and
  returning its current_path.
This commit is contained in:
Sebastian committed 2026-08-29 11:09:31 +02:00
1 parent 3024869de0
commit 09ba67bfd1
6 files changed
+58

No files matched your search

+10
View File
@@ -12,6 +12,7 @@
//! [`ensure_plugin_state`] helpers for the ergonomic typed access.
use std::any::Any;
use std::path::PathBuf;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
@@ -531,6 +532,15 @@ pub trait HostApi {
fn add_entities(&mut self, entities: Vec<EntityType>) -> Vec<Handle> {
entities.into_iter().map(|e| self.add_entity(e)).collect()
}
/// Return the filesystem path of the document in tab `tab_id`, if any.
/// Added after API v4; appended at the very end so older plugins compiled
/// without it keep stable vtable indices. The default returns `None`;
/// in-process hosts should override it to expose the real path.
fn document_path(&self, tab_id: u64) -> Option<PathBuf> {
let _ = tab_id;
None
}
}
/// Simplified, read-only entity kind exposed by [`DocumentReader`].