Skip to content

Commit 0ce6d38

Browse files
committed
Add comprehensive README documentation for Extension framework
1 parent 8f6a54d commit 0ce6d38

1 file changed

Lines changed: 197 additions & 0 deletions

File tree

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
# GeneralUpdate Extension Framework
2+
3+
A comprehensive plugin manager framework for WPF/Avalonia desktop applications, inspired by VS Code Extension Mechanism and VSIX design.
4+
5+
## Overview
6+
7+
This framework provides a complete plugin/extension system with support for:
8+
- Multi-language runtime support (C#, Lua, Python, Node.js, native executables)
9+
- Advanced update mechanisms (full, incremental, differential, rollback)
10+
- Enterprise-level features (offline installation, repository mirrors, security policies)
11+
- Comprehensive UI extension points
12+
- Strong security and sandboxing
13+
14+
## Architecture
15+
16+
The framework is organized into the following namespaces:
17+
18+
### MyApp.Extensions (Core)
19+
Core models and interfaces for extension management.
20+
21+
**Key Types:**
22+
- `ExtensionManifest` - Extension metadata and configuration
23+
- `ExtensionState` - Extension lifecycle states (Installed, Enabled, Disabled, etc.)
24+
- `SemVersion` - Semantic versioning support
25+
- `ExtensionDependency` - Dependency management
26+
- `ExtensionPermission` - Permission system
27+
28+
**Key Interfaces:**
29+
- `IExtensionManager` - Install, uninstall, enable, disable, update extensions
30+
- `IExtensionLoader` - Load and activate extensions
31+
- `IExtensionRepository` - Query and download extensions
32+
- `IExtensionLifecycle` - Extension lifecycle hooks
33+
- `IExtensionDependencyResolver` - Dependency resolution
34+
- `ISignatureValidator` - Package signature validation
35+
- `IExtensionProcessHost` - Process isolation
36+
- `IExtensionSandbox` - Permission and resource isolation
37+
38+
### MyApp.Extensions.Packaging
39+
VSIX-inspired package specification and structure.
40+
41+
**Key Types:**
42+
- `PackageManifest` - Package metadata with runtime config, dependencies, permissions
43+
- `PackageFileEntry` - File indexing within packages
44+
- `PackageSignature` - Digital signatures and certificates
45+
- `PackageFormatVersion` - Standardized package versioning
46+
47+
**Package Structure Convention:**
48+
```
49+
extension-package/
50+
├── manifest.json
51+
├── assets/
52+
├── runtime/
53+
├── patches/
54+
└── signature/
55+
```
56+
57+
### MyApp.Extensions.Updates
58+
Advanced update mechanisms for extensions.
59+
60+
**Key Types:**
61+
- `UpdateChannel` - Stable/PreRelease/Dev channels
62+
- `UpdateMetadata` - Available updates and compatibility
63+
- `UpdatePackageInfo` - Full/Delta/Diff package details
64+
- `DeltaPatchInfo` - Incremental update information
65+
- `RollbackInfo` - Rollback configuration
66+
67+
**Key Interfaces:**
68+
- `IUpdateService` - Check for updates, download, install, rollback
69+
- `IDeltaUpdateService` - Generate and apply delta patches
70+
71+
### MyApp.Extensions.Runtime
72+
Multi-language runtime support for extensions.
73+
74+
**Key Types:**
75+
- `RuntimeType` - Enum: DotNet, Lua, Python, Node, Exe, Custom
76+
- `RuntimeEnvironmentInfo` - Runtime configuration and environment
77+
78+
**Key Interfaces:**
79+
- `IRuntimeHost` - Start/stop runtime, invoke methods, health checks
80+
- `IRuntimeResolver` - Resolve runtime hosts by type
81+
82+
### MyApp.Extensions.UI
83+
UI extension points for WPF/Avalonia applications.
84+
85+
**Key Interfaces:**
86+
- `ICommandContribution` - Register commands
87+
- `IMenuContribution` - Add menu items
88+
- `IPanelContribution` - Contribute panels/views
89+
- `IShortcutContribution` - Keyboard shortcuts
90+
- `IThemeContribution` - Custom themes
91+
92+
**Key Types:**
93+
- `UIContributionManifest` - Unified UI contribution metadata
94+
95+
### MyApp.Extensions.Security
96+
Enterprise-level security and offline support.
97+
98+
**Key Types:**
99+
- `EnterprisePolicy` - Allowed/blocked sources, certificate requirements
100+
- `OfflinePackageIndex` - Local package management
101+
102+
**Key Interfaces:**
103+
- `IRepositoryMirror` - Enterprise repository mirror management
104+
- `IOfflineInstaller` - Offline installation support
105+
106+
### MyApp.Extensions.SDK
107+
Developer-facing APIs for extension authors.
108+
109+
**Key Types:**
110+
- `ExtensionActivationEvent` - Trigger-based activation (onCommand, onLanguage, onView, etc.)
111+
112+
**Key Interfaces:**
113+
- `IExtensionContext` - Extension runtime context and storage
114+
- `IExtensionAPI` - Host application services and commands
115+
116+
## Usage Example
117+
118+
```csharp
119+
// Install an extension
120+
var manager = GetService<IExtensionManager>();
121+
await manager.InstallAsync("path/to/extension.vsix");
122+
123+
// Check for updates
124+
var updateService = GetService<IUpdateService>();
125+
var updateMetadata = await updateService.CheckForUpdatesAsync("extension-id");
126+
127+
// Load and activate extension
128+
var loader = GetService<IExtensionLoader>();
129+
var manifest = await loader.LoadAsync("path/to/extension");
130+
await loader.ActivateAsync(manifest.Id);
131+
132+
// Runtime support
133+
var resolver = GetService<IRuntimeResolver>();
134+
var pythonHost = resolver.Resolve(RuntimeType.Python);
135+
await pythonHost.StartAsync(runtimeEnv);
136+
var result = await pythonHost.InvokeAsync("main", args);
137+
```
138+
139+
## Extension Development
140+
141+
Extensions can be developed in any supported language and must include a `manifest.json`:
142+
143+
```json
144+
{
145+
"id": "my-extension",
146+
"name": "My Extension",
147+
"version": "1.0.0",
148+
"author": "Author Name",
149+
"runtime": "python",
150+
"entrypoint": "main.py",
151+
"dependencies": [],
152+
"permissions": [
153+
{
154+
"type": "FileSystem",
155+
"scope": "read",
156+
"reason": "Read configuration files"
157+
}
158+
],
159+
"activationEvents": [
160+
"onCommand:myextension.command",
161+
"onStartup"
162+
]
163+
}
164+
```
165+
166+
## Extension Activation Events
167+
168+
Similar to VS Code, extensions can be activated based on:
169+
- `onStartup` - On application startup
170+
- `onCommand:commandId` - When a command is invoked
171+
- `onLanguage:languageId` - When a language file is opened
172+
- `onView:viewId` - When a view is opened
173+
- `onFileSystem:pattern` - When a file pattern is accessed
174+
175+
## Security
176+
177+
The framework includes comprehensive security features:
178+
- Digital signature validation
179+
- Certificate chain verification
180+
- Permission-based sandbox
181+
- Enterprise policy enforcement
182+
- Trusted source management
183+
184+
## Enterprise Features
185+
186+
- **Repository Mirrors**: Set up internal mirrors for extension repositories
187+
- **Offline Installation**: Deploy extensions without internet access
188+
- **Policy Enforcement**: Control which extensions can be installed
189+
- **Approval Workflows**: Require approval before installation
190+
191+
## License
192+
193+
This framework is part of the GeneralUpdate project and follows the same licensing terms.
194+
195+
## Contributing
196+
197+
Contributions are welcome! Please refer to the main GeneralUpdate repository for contribution guidelines.

0 commit comments

Comments
 (0)