Project Overview
View Exports SVG is a VS Code extension with a React-based webview UI. The project is split into two main parts:- Extension (TypeScript) - The VS Code extension host
- Client (React + TypeScript) - The webview UI
Directory Structure
Extension Architecture
Entry Point: extension.ts
The main entry point for the extension is src/extension.ts. This file:
- Exports the
activate()function, called when the extension is activated - Initializes cache managers and theme configuration
- Registers all commands and providers
- Sets up the in-memory file system provider
src/extension.ts:20
Commands (src/commands/)
Commands are the entry points for user actions. Key commands include:
showMenu- Opens the SVG viewer from context menuscanning- Scans workspace for SVG componentsreloadTheme- Reloads the current VS Code themeexpandedIcons- Toggles icon expansion statedevTools- Opens/closes the DevTools panelcache- Manages extension cache
extension.ts with the prefix JT-View-Exports-SVG.
Controllers (src/controllers/)
Controllers contain the core business logic, organized by responsibility:
Cache Controllers (controllers/cache/)
CacheManagerController- Central cache managementIconCacheController- Manages icon data cacheComponentsCacheController- Caches component informationFileModifiedCacheController- Tracks file modifications
Config Controllers (controllers/config/)
ConfigManagerController- Central configuration managementAssetsPathsController- Manages asset pathsDefaultIconPropertiesController- Default icon propertiesIgnoreDirectoriesController- Directories to ignore during scanningGroupPatternsController- Pattern-based groupingRecentIconsController- Recent icons tracking
Handler Controllers (controllers/handlers/)
AssetsHandler- Handles asset-related operationsCacheHandler- Cache operation handlingConfigurationHandler- Configuration changesSVGComponentHandler- SVG component processingUIHandler- UI state management
Listener Controllers (controllers/listener/)
ListerWebviewController- Listens to webview eventsMessageRouterController- Routes messages between extension and webview
View Controllers (controllers/views/)
ViewExportsSVGController- Main webview panel controller
Utilities (src/utilities/)
Utility functions organized by domain:
files/- File operations (scanning, processing, filtering)svg/- SVG parsing, analysis, and manipulationproperties/- Property extraction and managementcss/- CSS parsing and processingvscode/- VS Code API utilitiesicons/- Icon-specific utilities
Providers (src/providers/)
InMemoryFileSystemProvider- Provides an in-memory file system for virtual documents
Types (src/types/)
TypeScript type definitions organized by domain:
views/- Webview-related typessvg/- SVG component typesproperties/- Property-related typescache.d.ts- Cache typesViewExportsSVG.d.ts- Main extension types
Client Architecture
The webview UI is a React application built with Vite, located in theclient/ directory.
Key Technologies
- React 19 - UI framework
- TypeScript - Type safety
- Redux Toolkit - State management
- Material-UI - Component library
- Monaco Editor - Code editor in playground
- Vite - Build tool
- i18next - Internationalization
Client Structure
Communication Flow
- User Action → Command registered in
extension.ts - Command → Calls appropriate controller
- Controller → Uses utilities to process data
- Controller → Posts message to webview
- Webview → Receives message via
MessageRouterController - React UI → Updates state and renders
Build Outputs
The extension compiles to different formats:out/cjs/- CommonJS format (default for VS Code)out/esm/- ES Module formatout/types/- TypeScript type declarations
package.json:36 as ./out/cjs/extension.js.
Design Patterns
Controller Pattern
Controllers separate business logic from commands and views.Provider Pattern
Providers implement VS Code APIs for custom functionality.Message Passing
Extension and webview communicate via message passing for security and isolation.Cache-First Strategy
Data is cached to minimize file system operations and improve performance.Next Steps
- Learn about building the extension
- Understand the testing approach
- Set up your development environment