How incognitadev/vscode-deco-cx works
Purpose and Runtime
This repository is a TypeScript Visual Studio Code extension for Deco.cx development. It accelerates creation of Deco “Section”, “Loader”, and “Action” source files, provides Deco-oriented snippets, and offers annotation autocomplete/preview tooling. It runs in the VS Code extension host (Node.js) and uses VS Code APIs; its UI preview surface is a VS Code webview.
Key entry points:
• src/extension.ts
• src/fresh/extension.ts
Extension Composition
The root extension activation likely delegates feature registration to the Fresh/Deco module. src/fresh/extension.ts is the feature-level coordinator: it should register commands, completion providers, snippets, and webview behavior with VS Code.
• src/extension.ts
• src/fresh/extension.ts
• package.json
File Generation Pipeline
Generation is centered on selecting a Deco artifact type and target location, deriving a route/path, then emitting a base source file. This supports both command-driven creation and folder-context creation in the Explorer.
• src/fresh/generate.ts
• src/fresh/getRoutes.ts
• src/fresh/extension.ts
Boundary: filesystem and workspace mutations should remain in generation/route modules, while command registration stays in the extension coordinator.
Route and Workspace Context Resolution
Route discovery/resolution is separated from generation. getRoutes.ts likely maps the selected folder or workspace structure into valid Deco paths/names, allowing generated Sections, Loaders, and Actions to follow project conventions rather than use only a raw filename.
• src/fresh/getRoutes.ts
• src/fresh/generate.ts
Editor Assistance: Snippets and Annotations
Snippet definitions are isolated from activation and generation. They provide reusable editor insertions such as loading fallback, error fallback, and loader patterns. Annotation completion and widget-related suggestions are expected to be registered through the Fresh extension module and may use the webview for rich previews.
• src/fresh/snippets.ts
• src/fresh/extension.ts
• src/fresh/webview.ts
Webview Preview Boundary
The webview module bridges extension-host logic to a sandboxed browser UI for annotation/widget previews. Static browser assets are kept separately and should be loaded through VS Code webview-safe URIs and message passing, rather than accessed directly by editor-assistance logic.
• src/fresh/webview.ts
• media/fresh/main.js
• media/fresh/main.css
Frontend Assets and Packaging
The webview frontend is plain static JavaScript/CSS under media/fresh; vscode.css likely aligns the UI with VS Code styling. Extension packaging, activation declarations, commands, and dependencies are defined by the VS Code extension manifest.
• media/fresh/main.js
• media/fresh/vscode.css
• package.json
Main entry points: webview.ts Webview Bridge · fresh/extension.ts Fresh/Deco Coordinator · src/extension.ts Root Activation · getRoutes.ts Route Resolution
Components 14
Extension Host
TypeScript running in the VS Code extension host.
- Root Activation · Activates the extension and delegates Deco features.
src/extension.ts - Fresh/Deco Coordinator · Registers feature commands and VS Code providers.
src/fresh/extension.ts - VS Code APIs · Commands, Explorer context, editor providers, and webviews.
Generation Pipeline
Creates Deco artifact files from workspace context.
- Artifact Creation Commands · Starts Section, Loader, and Action creation from commands or folders.
src/fresh/extension.ts - Route Resolution · Derives valid Deco paths from selected folders and workspace structure.
src/fresh/getRoutes.ts - Source Generation · Emits base Section, Loader, and Action source files.
src/fresh/generate.ts - Workspace Filesystem · Target folders and generated source files.
Editor Assistance
Snippets, annotation completion, and previews.
- Deco Snippets · Reusable loading, error, and loader insertions.
src/fresh/snippets.ts - Annotation Assistance · Provides annotation autocomplete and preview interactions.
src/fresh/extension.ts
Webview UI
Sandboxed browser assets for rich previews.
- Webview Bridge · Creates the preview surface and exchanges messages with its UI.
src/fresh/webview.ts - Preview Script · Renders annotation or widget previews.
media/fresh/main.js - Preview Styles · Styles the webview preview UI.
media/fresh/main.css - VS Code Theme Styles · Aligns the preview with VS Code styling.
media/fresh/vscode.css
Other components
- Extension Manifest · Declares activation, commands, and dependencies.
package.json
Connections 15
- Extension Manifest → Root Activation: activates
- Root Activation → Fresh/Deco Coordinator: delegates to
- Fresh/Deco Coordinator → VS Code APIs: registers with
- Fresh/Deco Coordinator → Artifact Creation Commands: registers
- Artifact Creation Commands → Route Resolution: resolves target
- Route Resolution → Source Generation: supplies route and path
- Source Generation → Workspace Filesystem: writes source files
- Fresh/Deco Coordinator → Deco Snippets: registers
- Fresh/Deco Coordinator → Annotation Assistance: registers
- Annotation Assistance → Webview Bridge: requests preview
- Webview Bridge → VS Code APIs: creates webview via
- Webview Bridge → Preview Script: loads safe URI
- Webview Bridge → Preview Styles: loads safe URI
- Webview Bridge → VS Code Theme Styles: loads safe URI
- Preview Script → Webview Bridge: message passing