Commit graph

9 commits

Author SHA1 Message Date
Johannes Millan
091ecf72c1 feat(plugin): add comprehensive unit tests for PluginService
- Created complete test suite for PluginService with 28 tests
- Fixed type import issues for PluginNodeScriptRequest, PluginNodeScriptResult, PluginSidePanelBtnCfg
- Resolved window.ea type conflicts between test.ts and window-ea.d.ts
- Updated plugin-api package to avoid duplicate global declarations
- Fixed rxjs compatibility issues by using v6-compatible patterns
- Added proper HTTP request mocking for built-in plugin loading
- Fixed side panel and plugin management test setup
- Tests cover: initialization, side panel management, plugin loading/unloading, ZIP handling, error scenarios

Currently: 17 passing, 11 failing tests (significant progress from initial compilation errors)
2025-06-19 14:25:43 +02:00
Johannes Millan
4401e40058 feat(plugin): implement side panel functionality for plugins
- Add sidePanel flag to PluginManifest type
- Create PluginSidePanelBtnCfg interface for side panel buttons
- Implement plugin-side-panel-btns component for rendering buttons in main header
- Add plugin-panel-container component for rendering plugin iframes in right panel
- Update RightPanelComponent to support plugin panels
- Add activeSidePanelPlugin$ observable to PluginService
- Create reusable iframe utilities to avoid code duplication
- Update plugin API to support registerSidePanelButton method
- Skip menu entry registration for plugins with sidePanel flag
- Add test-side-panel-plugin to demonstrate functionality

When a plugin has 'sidePanel': true in its manifest, it will:
1. Not create a menu entry (unless explicitly registered)
2. Allow registration of side panel buttons via registerSidePanelButton
3. Load its iframe in the RightPanelComponent when activated
2025-06-19 14:25:43 +02:00
Johannes Millan
5b05192e2e refactor(plugin): improve type safety by removing 'as any' castings
- Create window-ea.d.ts to properly type window.ea (ElectronAPI)
- Replace all 'as any' castings with proper types
- Update all any[] to unknown[] for better type safety
- Import proper types (PluginManifest) in electron files
- Update plugin-api types to use unknown instead of any
- Fix app.getPath type casting with proper parameter types
- Rebuild plugin-api dist files with updated types
2025-06-19 14:25:43 +02:00
Johannes Millan
83ba3450fc feat(plugin): improve Node.js execution security and error handling
- Enhanced sandboxing with frozen prototypes and constructor removal
- Added comprehensive input validation for script requests
- Improved error handling with line/column information
- Added resource usage tracking (memory monitoring)
- Added cleanup method for plugin resources
- Better path traversal protection with ID sanitization
- Enhanced dangerous globals removal (fs, crypto, etc.)
- Added structured error types with error codes
- Built and updated plugin-api dist files
2025-06-19 14:25:43 +02:00
Johannes Millan
dfec172788 feat(plugin): add Node.js script execution API for plugins
- Implement secure Node.js script executor in Electron main process
- Add sandboxed execution environment with memory/timeout limits
- Create two-stage consent dialog for nodeExecution permission
- Add plugin registration/unregistration with main process
- Integrate executeNodeScript method into plugin API
- Add IPC handlers for plugin-to-main communication
- Ensure consent is checked when enabling plugins
- Add proper cleanup on plugin unload

Security features:
- Dangerous globals removed from execution context
- Plugin-specific working directories
- Configurable memory and timeout limits
- Persistent consent storage
- Only available in Electron environment
2025-06-19 14:25:43 +02:00
Johannes Millan
5a4f51b69b refactor(plugin): consolidate type definitions into plugin-api package
Moved all plugin-related type definitions from plugin-api.model.ts
to the @super-productivity/plugin-api package to eliminate duplication
and maintain a single source of truth for plugin types.

- Moved TaskCopy, ProjectCopy, TagCopy type aliases to plugin-api
- Moved PluginHeaderBtnCfg interface to plugin-api package
- Moved SnackCfgLimited type alias to plugin-api package
- Updated all imports to use types from the plugin-api package
- Simplified plugin-api.model.ts to just re-export from package
2025-06-19 14:25:42 +02:00
Johannes Millan
9fa0540296 fix(plugin-api): export PluginHooks as value not just type
- PluginHooks is an enum that needs to be used as a value in runtime code
- Changed from type-only export to regular export to fix TypeScript errors
- Keeps Hooks as type-only export since it's just a type alias
2025-06-19 14:25:42 +02:00
Johannes Millan
8477724b97 feat(plugin): feat add current task change hook 2025-06-19 14:25:42 +02:00
Johannes Millan
1255301b0b feat(plugin): prepare api package 2025-06-19 14:25:42 +02:00