====== Pregled arhitekture ====== Ovaj dokument opisuje cjelokupnu arhitekturu WvdS FPC RAD Studio Suite. ===== Dizajnerske odluke ===== ==== Zašto Pascal za VS Code Extensions? ==== **Motivacija:** * Jedinstvena baza koda za sve targete (GUI, TUI, Web, Extensions) * Striktna tipizacija smanjuje runtime-greške * Korištenje know-howa razvojnih programera iz postojećih Pascal-projekata * pas2js omogućuje visokokvalitetni JavaScript-izlaz **Razmatrane alternative:** ^ Alternativa ^ Odluka ^ Obrazloženje ^ | TypeScript | Odbijeno | Dva jezika, veća složenost | | Rust + WASM | Odbijeno | Složen Interop s VSCode API | | Delphi | Odbijeno | Komercijalno, nema pas2js-alternative | ==== Zašto PXAML umjesto LFM? ==== **Motivacija:** * Kontrola verzija: XML je diff-prijateljski * Multi-Target: Isti markup za GUI, TUI, Web * Tooling: Standardni XML-parseri dostupni * Poznato: WPF/XAML-sintaksa za one koji prelaze ===== Slojevita arhitektura ===== ┌─────────────────────────────────────────────────────────────────────┐ │ Extension Layer │ │ (extension_main.pas - Entry Point, Command Handler, UI Integration) │ ├─────────────────────────────────────────────────────────────────────┤ │ Service Layer │ │ (*.Service.pas - Poslovna logika, validacija, operacije) │ ├─────────────────────────────────────────────────────────────────────┤ │ Model Layer │ │ (*.Models.pas - Records, tipovi, enumi, bez logike) │ ├─────────────────────────────────────────────────────────────────────┤ │ Infrastructure Layer │ │ (WvdS.VSCode.*, WvdS.Node.* - API Wrapper, Platform Abstraction) │ └─────────────────────────────────────────────────────────────────────┘ ==== Odgovornosti ==== ^ Sloj ^ Sadržaj ^ Ovisnosti ^ | Extension | UI-Interakcija, Command-Registracija | Service, Model, Infrastructure | | Service | Poslovna logika, validacija | Model | | Model | Strukture podataka | Nema | | Infrastructure | VSCode/Node APIs | Samo vanjski APIs | ==== Pravila ==== DOZVOLJENO: Extension -> Service -> Model ZABRANJENO: Service -> Extension (Obrnuto) ZABRANJENO: Model -> Service (Logika u Modelu) ===== Graf ovisnosti ===== wvds.vscode.packaging │ ▼ wvds.vscode.ui.preview ─► wvds.vscode.build │ │ ▼ │ wvds.vscode.ui.designer │ │ │ └───────┬──────────────┘ ▼ wvds.vscode.projects │ ▼ wvds.vscode.ui.meta │ ▼ wvds.vscode.core (Baza) ==== Extension-ovisnosti u detalje ==== ^ Extension ^ Ovisnosti ^ Uloga ^ | core | - | Baza: Toolchain, Logging, Shared Services | | build | core | Kompilacija, Uses-Formatter | | projects | core | Upravljanje projektima, Templates | | ui.meta | core | Komponenten-Registry | | ui.designer | core | PXAML-Editor | | ui.preview | core, ui.designer | Live-Preview | | packaging | core, build | VSIX-kreiranje | ===== Monorepo-Struktura ===== ==== sources/ - Single Source of Truth ==== sources/ ├── common/ # Shared Code │ ├── core/ # Bazne Units (bez ovisnosti) │ │ ├── WvdS.System.pas │ │ ├── WvdS.Collections.pas │ │ └── WvdS.Strings.pas │ │ │ ├── ui/ # UI Framework │ │ ├── controls/ # Bazni Controls │ │ ├── components/ # Composite Components │ │ ├── runtime/ # PXAML Runtime │ │ └── targets/ # Renderer │ │ ├── tui/ # Terminal UI │ │ ├── gui/ # Desktop GUI │ │ └── web/ # Browser │ │ │ └── web/ # Host Bridges │ ├── nodejs/ # Node.js APIs │ └── vscode/ # VSCode APIs │ ├── extensions/ # VSIX-paketi │ └── wvds.vscode.{name}/ │ ├── pas/ # Pascal-izvorni kod │ ├── dist/ # Kompilirani JS │ ├── templates/ # HTML-Templates │ ├── images/ # Icons, grafike │ ├── package.json # Extension-Manifest │ └── build.cfg # Build-Konfiguracija │ ├── applications/ # Standalone-Apps ├── tools/ # CLI-Tools └── packages/ # IDE-Packages ==== binaries/ - Build-Output ==== binaries/ ├── out/{app}/{target}/{mode}/ # Build-artefakti │ ├── gen/ # Generirani kod │ ├── bin/ # Izvršne datoteke │ └── assets/ # Resursi │ ├── cache/ # Compiler-Cache (.ppu, .o) ├── dist/ # Release-artefakti (.vsix) └── logs/ # Build-protokoli ===== Extension-Anatomija ===== ==== Struktura direktorija ==== wvds.vscode.{name}/ ├── pas/ │ ├── extension_main.pas # Entry Point (OBAVEZNO) │ ├── {Feature}.Models.pas # Strukture podataka │ ├── {Feature}.Service.pas # Poslovna logika │ └── {Feature}.Dialog.pas # UI-Komponente (opcionalno) │ ├── dist/ │ ├── extension_main.js # Kompilirani JS │ └── extension_main.js.map # Source Map │ ├── templates/ │ └── *.html # WebView-Templates │ ├── images/ │ └── icon.png # Extension-Icon │ ├── package.json # VSCode-Manifest ├── build.cfg # Build-Konfiguracija └── README.md # Dokumentacija ==== 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 // Inicijalizacija servisa Initialize{Feature}Service; // Registracija naredbi RegisterCommand('wvds.{feature}.{action}', @Handle{Action}); // Output Channel ShowInfoMessage('WvdS {Name} aktiviran'); 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. ===== Komunikacija između Extensiona ===== ==== Via Shared Services ==== Extensioni komuniciraju preko Core-Extensiona: // U Extension A CoreService.PublishEvent('build.completed', BuildResult); // U Extension B CoreService.SubscribeEvent('build.completed', @OnBuildCompleted); ==== Via VSCode API ==== Za labavu povezanost: // Pozivanje naredbi ExecuteCommand('wvds.build.run'); // Events OnDidChangeConfiguration(@HandleConfigChange); ===== Build-Pipeline ===== ┌──────────────────────────────────────────────────────────────┐ │ BUILD PIPELINE │ ├──────────────────────────────────────────────────────────────┤ │ │ │ 1. Policy-Check (wvds-lint) │ │ - Nema .ts datoteka? │ │ - Nema duplikata? │ │ - Wrapperi samo u common? │ │ │ │ 2. pas2js Kompilacija │ │ - Unit-razlučivanje │ │ - Type-Checking │ │ - JavaScript-generiranje │ │ │ │ 3. Obrada asseta │ │ - Kopiranje HTML-Templates │ │ - Optimizacija slika │ │ - Validacija package.json │ │ │ │ 4. Output │ │ - dist/extension_main.js │ │ - dist/extension_main.js.map │ │ │ │ 5. VSIX-Packaging (opcionalno) │ │ - vsce package │ │ - binaries/dist/*.vsix │ │ │ └──────────────────────────────────────────────────────────────┘ ===== Vidi također ===== * [[.:pxaml-pipeline|PXAML-Pipeline]] * [[.:extension-architektur|Extension-Arhitektura u detalje]] * [[.:targets|Build-Targets]] * [[.:extension-entwicklung|Razvoj Extensiona]]