The attribute plugin is not available, 2fa disabled
Inhaltsverzeichnis
Architecture Overview
This document describes the overall architecture of the WvdS FPC RAD Studio Suite.
Design Decisions
Why Pascal for VS Code Extensions?
Motivation:
- Unified codebase for all targets (GUI, TUI, Web, Extensions)
- Strong typing reduces runtime errors
- Leverage developer expertise from existing Pascal projects
- pas2js enables high-quality JavaScript output
Alternatives considered:
| Alternative | Decision | Rationale |
|---|---|---|
| TypeScript | Rejected | Two languages, more complexity |
| Rust + WASM | Rejected | Complex interop with VSCode API |
| Delphi | Rejected | Commercial, no pas2js alternative |
Why PXAML Instead of LFM?
Motivation:
- Version control: XML is diff-friendly
- Multi-target: Same markup for GUI, TUI, Web
- Tooling: Standard XML parsers available
- Familiar: WPF/XAML syntax for developers transitioning
Layered Architecture
┌─────────────────────────────────────────────────────────────────────┐ │ Extension Layer │ │ (extension_main.pas - Entry Point, Command Handler, UI Integration) │ ├─────────────────────────────────────────────────────────────────────┤ │ Service Layer │ │ (*.Service.pas - Business logic, validation, operations) │ ├─────────────────────────────────────────────────────────────────────┤ │ Model Layer │ │ (*.Models.pas - Records, types, enums, no logic) │ ├─────────────────────────────────────────────────────────────────────┤ │ Infrastructure Layer │ │ (WvdS.VSCode.*, WvdS.Node.* - API Wrapper, Platform Abstraction) │ └─────────────────────────────────────────────────────────────────────┘
Responsibilities
| Layer | Content | Dependencies |
|---|---|---|
| Extension | UI interaction, command registration | Service, Model, Infrastructure |
| Service | Business logic, validation | Model |
| Model | Data structures | None |
| Infrastructure | VSCode/Node APIs | Only external APIs |
Rules
ALLOWED: Extension -> Service -> Model FORBIDDEN: Service -> Extension (inversion) FORBIDDEN: Model -> Service (logic in Model)
Dependency Graph
wvds.vscode.packaging
│
▼
wvds.vscode.ui.preview ─► wvds.vscode.build
│ │
▼ │
wvds.vscode.ui.designer │
│ │
└───────┬──────────────┘
▼
wvds.vscode.projects
│
▼
wvds.vscode.ui.meta
│
▼
wvds.vscode.core (Base)
Extension Dependencies in Detail
| Extension | Dependencies | Role |
|---|---|---|
| core | - | Base: Toolchain, Logging, Shared Services |
| build | core | Compilation, Uses Formatter |
| projects | core | Project management, templates |
| ui.meta | core | Component registry |
| ui.designer | core | PXAML Editor |
| ui.preview | core, ui.designer | Live preview |
| packaging | core, build | VSIX creation |
Monorepo Structure
sources/ - Single Source of Truth
sources/
├── common/ # Shared Code
│ ├── core/ # Base units (no dependencies)
│ │ ├── WvdS.System.pas
│ │ ├── WvdS.Collections.pas
│ │ └── WvdS.Strings.pas
│ │
│ ├── ui/ # UI Framework
│ │ ├── controls/ # Base controls
│ │ ├── components/ # Composite components
│ │ ├── runtime/ # PXAML Runtime
│ │ └── targets/ # Renderers
│ │ ├── tui/ # Terminal UI
│ │ ├── gui/ # Desktop GUI
│ │ └── web/ # Browser
│ │
│ └── web/ # Host Bridges
│ ├── nodejs/ # Node.js APIs
│ └── vscode/ # VSCode APIs
│
├── extensions/ # VSIX packages
│ └── wvds.vscode.{name}/
│ ├── pas/ # Pascal source code
│ ├── dist/ # Compiled JS
│ ├── templates/ # HTML templates
│ ├── images/ # Icons, graphics
│ ├── package.json # Extension manifest
│ └── build.cfg # Build configuration
│
├── applications/ # Standalone apps
├── tools/ # CLI tools
└── packages/ # IDE Packages
binaries/ - Build Output
binaries/
├── out/{app}/{target}/{mode}/ # Build artifacts
│ ├── gen/ # Generated code
│ ├── bin/ # Executables
│ └── assets/ # Resources
│
├── cache/ # Compiler cache (.ppu, .o)
├── dist/ # Release artifacts (.vsix)
└── logs/ # Build logs
Extension Anatomy
Directory Structure
wvds.vscode.{name}/
├── pas/
│ ├── extension_main.pas # Entry Point (REQUIRED)
│ ├── {Feature}.Models.pas # Data structures
│ ├── {Feature}.Service.pas # Business logic
│ └── {Feature}.Dialog.pas # UI components (optional)
│
├── dist/
│ ├── extension_main.js # Compiled JS
│ └── extension_main.js.map # Source Map
│
├── templates/
│ └── *.html # WebView templates
│
├── images/
│ └── icon.png # Extension icon
│
├── package.json # VSCode manifest
├── build.cfg # Build configuration
└── README.md # Documentation
extension_main.pas Pattern
unit extension_main; {$mode objfpc}{$H+} interface uses JS, VSCode.API, VSCode.Commands, VSCode.ExtensionExports, {Feature}.Service, {Feature}.Models; procedure Activate(AContext: TExtensionContext); procedure Deactivate; implementation procedure DoActivate(AContext: TExtensionContext); begin // Initialize services Initialize{Feature}Service; // Register commands RegisterCommand('wvds.{feature}.{action}', @Handle{Action}); // Output Channel ShowInfoMessage('WvdS {Name} activated'); end; procedure Activate(AContext: TExtensionContext); begin try DoActivate(AContext); except on E: Exception do ShowErrorMessage(Format(rsActivationFailed, [E.Message])); end; end; procedure Deactivate; begin // Cleanup end; initialization ExportActivateDeactivate(@Activate, @Deactivate); end.
Communication Between Extensions
Via Shared Services
Extensions communicate through the Core extension:
// In Extension A CoreService.PublishEvent('build.completed', BuildResult); // In Extension B CoreService.SubscribeEvent('build.completed', @OnBuildCompleted);
Via VSCode API
For loose coupling:
// Call commands ExecuteCommand('wvds.build.run'); // Events OnDidChangeConfiguration(@HandleConfigChange);
Build Pipeline
┌──────────────────────────────────────────────────────────────┐ │ BUILD PIPELINE │ ├──────────────────────────────────────────────────────────────┤ │ │ │ 1. Policy Check (wvds-lint) │ │ - No .ts files? │ │ - No duplicates? │ │ - Wrappers only in common? │ │ │ │ 2. pas2js Compilation │ │ - Unit resolution │ │ - Type checking │ │ - JavaScript generation │ │ │ │ 3. Asset Processing │ │ - Copy HTML templates │ │ - Optimize images │ │ - Validate package.json │ │ │ │ 4. Output │ │ - dist/extension_main.js │ │ - dist/extension_main.js.map │ │ │ │ 5. VSIX Packaging (optional) │ │ - vsce package │ │ - binaries/dist/*.vsix │ │ │ └──────────────────────────────────────────────────────────────┘
See Also
Zuletzt geändert: on 2026/01/29 at 10:25 PM