//! Plugin / extension system for calcpad-engine.
//!
//! This module provides a trait-based plugin API, a registry for managing
//! loaded plugins, and a Rhai scripting integration for lightweight custom
//! functions.
//!
//! # Architecture
//!
//! ```text
//!  ┌─────────────────────────────────────────────────────┐
//!  │                  PluginRegistry                     │
//!  │  ┌───────────┐  ┌───────────┐  ┌───────────┐       │
//!  │  │ Plugin A   │  │ Plugin B   │  │ ScriptPlugin │    │
//!  │  │ (Rust)     │  │ (Rust)     │  │ (.rhai)      │    │
//!  │  └─────┬─────┘  └─────┬─────┘  └──────┬────┘       │
//!  │        │              │               │             │
//!  │        └──────────────┴───────────────┘             │
//!  │              CalcPadPlugin trait                     │
//!  │   functions: HashMap<String, PluginFn>              │
//!  │   units:     HashMap<String, f64>                   │
//!  │   variables: HashMap<String, f64>                   │
//!  └─────────────────────────────────────────────────────┘
//! ```
//!
//! # Quick start
//!
//! ```rust
//! use calcpad_engine::plugins::{
//!     CalcPadPlugin, PluginFunctionRegistry, PluginValue, PluginRegistry,
//! };
//!
//! struct MyPlugin;
//!
//! impl CalcPadPlugin for MyPlugin {
//!     fn name(&self) -> &str { "my_plugin" }
//!
//!     fn register_functions(&self, reg: &mut PluginFunctionRegistry) {
//!         reg.register("double", |args| {
//!             if args.len() != 1 {
//!                 return Err("double() requires 1 argument".into());
//!             }
//!             Ok(PluginValue::new(args[0].number * 2.0))
//!         });
//!     }
//! }
//!
//! let mut registry = PluginRegistry::new();
//! registry.add(MyPlugin).unwrap();
//! let result = registry.call_function("double", &[PluginValue::new(21.0)]).unwrap();
//! assert_eq!(result.number, 42.0);
//! ```

pub mod api;
pub mod registry;
pub mod scripting;

// Re-export the most commonly used types at the `plugins` level.
pub use api::{
    CalcPadPlugin, PluginError, PluginFn, PluginFunctionRegistry,
    PluginUnitRegistry, PluginValue, PluginVariableRegistry, PluginWarning,
};
pub use registry::PluginRegistry;
pub use scripting::{load_scripts_from_dir, ScriptError, ScriptLoadResult, ScriptPlugin};
