1.0.0 • Published 8 months ago
@cadcamfun/cad-cam-fun-plugin-sdk v1.0.0
CAD/CAM FUN Plugin SDK
Official SDK for building plugins for the CAD/CAM FUN platform.
Installation
npm install @cad-cam-fun/plugin-sdkor
yarn add @cad-cam-fun/plugin-sdkQuick Start
import { definePlugin, createExtension } from '@cad-cam-fun/plugin-sdk';
export default definePlugin((api) => {
// Register sidebar extension
api.registerExtension(
createExtension({
type: 'sidebar',
component: () => import('./components/Sidebar'),
metadata: {
title: 'My Plugin',
icon: 'settings'
}
})
);
return {
onEnable: () => {
console.log('Plugin enabled');
},
onDisable: () => {
console.log('Plugin disabled');
}
};
});Plugin Structure
A typical plugin consists of:
- Main Entry Point: Defines the plugin and its lifecycle methods
- UI Components: React components for user interface extensions
- Business Logic: Code for manipulating elements, layers, etc.
Extension Points
You can extend the CAD/CAM FUN platform at these extension points:
- sidebar: Add a panel to the sidebar
- toolbar: Add buttons to the toolbar
- rightSidebar: Add content to the right sidebar
- modal: Create modal dialogs
- overlay: Add an overlay to the canvas
- contextMenu: Add items to context menus
- cadTool: Add custom CAD tools
- camOperation: Add custom CAM operations
- importer: Add file import capabilities
- exporter: Add file export capabilities
- renderer: Customize rendering
Available Hooks
// Access the plugin API
const api = usePluginAPI();
// Access canvas elements
const { elements, createElement, updateElement, deleteElement } = useElements();
// Access current selection
const { selectedIds, selectedElements } = useSelection();
// Access layers
const { layers } = useLayers();
// Access viewport
const viewport = useViewport();
// Subscribe to events
usePluginEvent('element:created', (event) => {
console.log('Element created:', event.id);
});
// Access plugin settings
const { settings, updateSettings } = usePluginSettings();Documentation
For full documentation, visit our documentation site.
Examples
Check out the examples directory for sample plugins.
Development
# Install dependencies
npm install
# Build the SDK
npm run build
# Watch for changes
npm run dev
# Run tests
npm testLicense
MIT © CAD/CAM FUN Team
1.0.0
8 months ago