refactor(plugin): drop built-in plugins, external-only

OpenCADStudio no longer bundles plugins — every add-on is an external
cdylib loaded from the plugins folder or installed via the marketplace.

- Remove the demo plugin and the in-tree ocs_example_plugin crate.
- Remove the inventory-based built-in registration path (PluginRegistration,
  all_plugins, installed_manifests); registry now serves core ribbon tabs
  plus loaded external plugins, and try_dispatch routes only to externals.
- Plugin Manager drops the 'compiled into this build' section; the
  enable/disable toggle moves onto loaded external cards.
- Prune the now-dead HostSession/DocumentTab helpers and re-exports.

Part of the #100 extensibility epic (phase 2).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-17 15:50:52 +03:00
1 parent 020a3a4c84
commit eb53e445ab
22 files changed
+65 -585

No files matched your search

-17
View File
@@ -1,17 +0,0 @@
use crate::plugin::host::HostApi;
pub fn handle(host: &mut dyn HostApi, cmd: &str) -> bool {
// "DP_IMPORT <path>" arrives from ModuleEvent::PluginFileDialog with the
// path in its original case (the command line is bypassed).
if let Some(path) = cmd.strip_prefix("DP_IMPORT ") {
host.push_info(&format!("demo_plugin imported: {path}"));
return true;
}
match cmd {
"DP_HELLO" => {
host.push_info("Hello from demo_plugin (plugin host OK).");
true
}
_ => false,
}
}
-14
View File
@@ -1,14 +0,0 @@
use crate::plugin::manifest::{ApiVersion, PluginManifest};
pub const PLUGIN_ID: &str = "opencad.demo_plugin";
pub static MANIFEST: PluginManifest = PluginManifest {
id: PLUGIN_ID,
name: "Demo Plugin",
version: "0.1.0",
description: "Minimal add-on for plugin-host integration tests",
api_version: ApiVersion::CURRENT,
ribbon_order: 99,
xdata_apps: &[],
command_prefixes: &["DP_"],
};
-62
View File
@@ -1,62 +0,0 @@
// Minimal in-tree add-on — validates plugin host on `feature/plugin-host`.
pub mod dispatch;
pub mod manifest;
pub mod plugin;
pub mod register;
use crate::modules::{CadModule, IconKind, ModuleEvent, RibbonGroup, RibbonItem, ToolDef};
inventory::submit!(crate::command::CommandRegistration {
names: &["DP_HELLO", "DP_IMPORT"]
});
pub struct DemoPluginModule;
impl CadModule for DemoPluginModule {
fn id(&self) -> &'static str {
"demo_plugin"
}
fn title(&self) -> &'static str {
"Demo Plugin"
}
fn ribbon_groups(&self) -> Vec<RibbonGroup> {
vec![RibbonGroup {
title: "Smoke",
tools: vec![
RibbonItem::LargeTool(ToolDef {
id: "DP_HELLO",
label: "Hello",
icon: IconKind::Glyph("★"),
event: ModuleEvent::Command("DP_HELLO".to_string()),
}),
// Exercises ModuleEvent::PluginFileDialog: the host opens a
// native picker and dispatches "DP_IMPORT <path>" back here.
RibbonItem::LargeTool(ToolDef {
id: "DP_IMPORT",
label: "Import",
icon: IconKind::Glyph("📂"),
event: ModuleEvent::PluginFileDialog {
command: "DP_IMPORT".to_string(),
title: "Import Demo File".to_string(),
filter_name: "Text".to_string(),
extensions: vec!["txt".to_string(), "csv".to_string()],
},
}),
],
}]
}
}
#[cfg(test)]
mod tests {
use crate::plugin::all_ribbon_modules;
#[test]
fn ribbon_tab_is_registered() {
let titles: Vec<&str> = all_ribbon_modules().iter().map(|m| m.title()).collect();
assert!(titles.contains(&"Demo Plugin"), "tabs: {titles:?}");
}
}
-21
View File
@@ -1,21 +0,0 @@
use crate::plugin::host::{BuiltinPlugin, HostApi};
use crate::plugin::manifest::PluginManifest;
use super::dispatch;
use super::manifest;
pub struct DemoPlugin;
impl BuiltinPlugin for DemoPlugin {
fn manifest(&self) -> &'static PluginManifest {
&manifest::MANIFEST
}
fn ribbon(&self) -> Box<dyn crate::modules::CadModule> {
Box::new(super::DemoPluginModule)
}
fn dispatch(&self, host: &mut dyn HostApi, cmd: &str) -> bool {
dispatch::handle(host, cmd)
}
}
-13
View File
@@ -1,13 +0,0 @@
[plugin]
id = "opencad.demo_plugin"
name = "Demo Plugin"
version = "0.1.0"
description = "Minimal add-on for plugin-host integration tests"
author = "Open CAD Studio contributors"
license = "GPL-3.0-only"
[opencad]
api_version = 1
ribbon_order = 99
command_prefixes = ["DP_"]
xdata_apps = []
-7
View File
@@ -1,7 +0,0 @@
use super::plugin::DemoPlugin;
inventory::submit! {
crate::plugin::registry::PluginRegistration {
construct: || Box::new(DemoPlugin),
}
}
-1
View File
@@ -29,7 +29,6 @@ pub mod draw;
pub mod insert;
pub mod model;
pub mod layout;
pub mod demo_plugin;
pub mod manage;
pub mod view;