cad-editor/docs/plugin-template
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Hakan Seven 5ccf5cfe36 feat(plugin): lift host surface behind a HostApi trait (phase 1b)
Plugins targeted the host's concrete HostSession type. Add a HostApi
trait in ocs_plugin_api behind an optional `host` feature (the only thing
that pulls acadrust, so the core crate stays dependency-free). HostSession
implements it and BuiltinPlugin::dispatch now takes `&mut dyn HostApi`, so
an out-of-tree add-on compiles against the contract crate alone. Per-tab
plugin state is reached through object-safe plugin_state* helpers.

Completes the phase-1 host-surface extraction in the #100 epic.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-17 11:31:05 +03:00
..
dispatch.rs feat(plugin): lift host surface behind a HostApi trait (phase 1b) 2026-06-17 11:31:05 +03:00
manifest.rs Add plugin host architecture and Storm Sewer add-on package 2026-06-09 13:41:21 -04:00
mod.rs Add plugin host architecture and Storm Sewer add-on package 2026-06-09 13:41:21 -04:00
PLUGIN.md Add plugin host architecture and Storm Sewer add-on package 2026-06-09 13:41:21 -04:00
plugin.rs feat(plugin): lift host surface behind a HostApi trait (phase 1b) 2026-06-17 11:31:05 +03:00
plugin.toml Add plugin host architecture and Storm Sewer add-on package 2026-06-09 13:41:21 -04:00
README.md Add plugin host architecture and Storm Sewer add-on package 2026-06-09 13:41:21 -04:00
register.rs Add plugin host architecture and Storm Sewer add-on package 2026-06-09 13:41:21 -04:00

Add-on plugin template

Copy this folder to src/modules/<your_module>/ and rename placeholders.

Quick start

  1. Copy files into src/modules/my_plugin/.
  2. Replace MY_PLUGIN, my_plugin, opencad.my_plugin, MP_ throughout.
  3. Add pub mod my_plugin; to src/modules/mod.rs.
  4. cargo build — ribbon tab and commands register automatically.

Required files

File Purpose
plugin.toml Metadata (QGIS-style); excludes dir from build.rs ribbon scan
manifest.rs Compile-time PluginManifest — keep in sync with plugin.toml
register.rs inventory::submit!(PluginRegistration { … }) only
plugin.rs Thin BuiltinPlugin impl
dispatch.rs All command handlers
mod.rs CadModule ribbon + CommandRegistration for autocomplete
PLUGIN.md XDATA schemas and command reference

Optional

File Purpose
state.rs Per-document tab state via host.ensure_plugin_state(PLUGIN_ID, …)
crates/my_engine/ Headless domain logic (no iced/acadrust)

See docs/plugin-architecture.md for the full spec.