mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-23 10:45:57 +00:00
- Add @super-productivity/plugin-api package with TypeScript definitions - Define core plugin interfaces, types, and manifest structure - Add plugin hooks system for event-driven architecture - Create plugin API type definitions and constants - Add documentation and development guidelines
3.3 KiB
3.3 KiB
Plugin API Development Guide
For Plugin Developers
Installation
npm install @super-productivity/plugin-api
TypeScript Setup
Create a tsconfig.json in your plugin project:
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"lib": ["ES2020", "DOM"],
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src/**/*"],
"exclude": ["node_modules"]
}
Basic Plugin Structure
my-plugin/
├── src/
│ └── plugin.ts
├── dist/
│ └── plugin.js
├── manifest.json
├── index.html (optional)
├── icon.svg (optional)
├── package.json
└── tsconfig.json
Development Workflow
- Write TypeScript code with full type safety
- Compile to JavaScript for Super Productivity
- Test in Super Productivity plugin system
Example Build Script
Add to your package.json:
{
"scripts": {
"build": "tsc",
"build:watch": "tsc --watch",
"dev": "tsc --watch"
},
"devDependencies": {
"@super-productivity/plugin-api": "^1.0.0",
"typescript": "^5.0.0"
}
}
Plugin Template
See example/my-plugin.ts for a complete TypeScript plugin example.
For Core Developers
Updating the API
When adding new features to the plugin system:
- Update
src/types.tswith new interfaces/types - Update
src/index.tsto export new types - Update
README.mdwith usage examples - Version bump the package
- Rebuild and test
- Publish to npm
Syncing with Main Project
The main Super Productivity project should eventually import types from this package instead of maintaining local definitions:
// Before:
import { PluginManifest } from './plugin-api.model';
// After:
import type { PluginManifest } from '@super-productivity/plugin-api';
Testing Changes
- Build the package:
npm run build - Test locally:
npm linkin this directory - In test project:
npm link @super-productivity/plugin-api - Verify types work correctly
Release Process
- Update version:
npm version patch|minor|major - Build:
npm run build - Test:
npm pack --dry-run - Publish:
npm publish --access public
Available Types Reference
Core Interfaces
PluginAPI- Main API interfacePluginManifest- Plugin configurationPluginBaseCfg- Runtime configuration
Hook Types
PluginHooks- Available hook eventsPluginHookHandler- Hook function signature
Data Types
TaskData- Task informationProjectData- Project informationTagData- Tag informationPluginCreateTaskData- Task creation data
UI Types
DialogCfg- Dialog configurationDialogButtonCfg- Dialog button configurationSnackCfg- Notification configurationNotifyCfg- System notification configurationPluginMenuEntryCfg- Menu entry configurationPluginShortcutCfg- Keyboard shortcut configurationPluginHeaderBtnCfg- Header button configuration
Best Practices
- Always use TypeScript for plugin development
- Import types only to avoid runtime dependencies
- Follow semantic versioning for plugin releases
- Test thoroughly before publishing
- Document your plugins for other developers