How afrit-bagani/vscode-icons works
Architectural Overview
• The extension runs entirely in VSCode’s Extension Host process. There is no external server or database—everything is packaged and executed locally.
• There are two main runtime phases:
a. Activation & Initialization
b. Theme Generation & Event Handling
A. VSCode Shell
• Extension Host (host process)
• VSCode API (commands, window, workspace, configuration)
B. Extension Core
• extensionManager.ts – entry point, handles activation/deactivation
• compositionRootService.ts – dependency injection container, wires services
• configManager.ts – reads/writes user settings
• i18n.languageResourceManager – loads localized strings via Crowdin resources
• projectAutoDetectionManager (pad) – inspects workspace to auto‑apply presets
• notificationManager – shows VSCode notifications
• fsAsync, errorHandler, debugger – common utilities
• iconsManifest sources (default and custom definitions)
• locale/ – translation files for UI strings
D. Dev/Build Toolchain (side‑component)
• webpack.config.ts – bundles TS to JS
• build.ts, bundle.ts – CLI scripts for packaging
• npm scripts, tsconfig.json
• Continuous Integration workflows (GitHub Actions)
Component Interactions & Data Flow
• On Extension Activation (VSCode fires ‘activate’):
→ extensionManager invokes compositionRootService
→ Services (configManager, i18n, iconsManifest) are instantiated
→ Calls VSCode API (vscode.window.registerFileIconTheme) to apply theme
• At Runtime:
• Listens to workspace events (onDidChangeConfiguration, onDidChangeWorkspaceFolders) → configManager emits updates → manifest rebuilt → VSCode API called again
• Notifications and errors bubble via notificationManager and errorHandler to the user.
Architectural Patterns & Principles
• Inversion of Control / Dependency Injection: compositionRootService centralizes wiring.
• Separation of Concerns:
• Core services (config, i18n, manifest building) are decoupled.
• Models in src/models represent domain objects (extensions, contributions, settings).
• Single Responsibility: each folder (common, services, models, tools) houses a distinct layer.