Skip to content

Plugin System

Ved Gupta edited this page Nov 13, 2026 · 4 revisions

Plugin System

CodeLab supports two complementary ways to extend the IDE: declarative plugins with lazy activation manifests (similar to VS Code extensions) and lightweight imperative plugins attached directly to a workbench instance.


Official Modular Extensions

By default, CodeLab ships with JavaScript, Node.js, and Bun enabled. Additional language packs and the Guided Lab stepper live under dedicated extension subpaths (and attach under the global extensions namespace in UMD builds):

Extension Subpath Import Purpose
JavaScript @innovatorved/code-lab/extensions/javascript Built-in Node.js v22 and Bun v1.1 language registration
TypeScript @innovatorved/code-lab/extensions/typescript TypeScript workspace models, compiler diagnostics, and TS/TSX execution
C++20 WASI @innovatorved/code-lab/extensions/cpp On-demand Clang/LLVM WebAssembly compiler, STL/DSA headers, and test runner
Python 3.12 WASI @innovatorved/code-lab/extensions/python On-demand Pyodide CPython 3.12 runtime, pytest runner, and DSA helpers
Guided Labs @innovatorved/code-lab/extensions/guided-lab Step-by-step challenge drawer, hints, test filtering, and solution diffs (guidedLab)

Declarative Plugins

Declarative plugins contribute commands, keybindings, typed settings, custom drawer or sidebar panels, and themes. Each plugin activates lazily when one of its activation events fires and cleans up all registered disposables automatically when deactivated:

ide.registerPlugin({
  id: 'acme.explain-visualizer',
  name: 'SQL Explain Visualizer',
  version: '1.0.0',
  activationEvents: ['onView:explain-plan', 'onCommand:acme.showPlan'],
  contributes: {
    commands: [
      { id: 'acme.showPlan', title: 'SQL: Show Visual Query Plan', category: 'SQL' }
    ],
    configuration: {
      'acme.explain.buffers': {
        type: 'boolean',
        default: true,
        description: 'Include buffer statistics when explaining queries'
      }
    },
    panels: [
      {
        id: 'explain-plan',
        title: 'Query Plan',
        location: 'drawer',
        render(container) {
          container.textContent = 'Visual query plan ready.';
        }
      }
    ]
  },
  activate(ctx) {
    ctx.subscriptions.push(
      ctx.commands.register('acme.showPlan', () => {
        console.log('Buffers enabled:', ctx.configuration.get('acme.explain.buffers'));
      })
    );
  }
});

Imperative Plugins & Lifecycle Events

For analytics, custom grading hooks, or host-page synchronization, pass a function to the workbench and subscribe to lifecycle events. Every event subscription returns an unsubscribe function:

const telemetryPlugin = (lab) => {
  lab.on('run', ({ mode, entry, result }) => {
    console.log('Executed', entry, mode, result.durationMs);
  });

  lab.on('step-complete', ({ stepId, stepIndex }) => {
    console.log('Completed step', stepIndex + 1, stepId);
  });
};

ide.use(telemetryPlugin);
Event When It Fires
run Whenever a script or test suite finishes running
change Whenever a workspace file is edited in the editor or updated programmatically
file-open / file-create / file-delete Whenever workspace files are opened, created, or deleted
step-complete / lab-complete When a learner passes a single guided step or finishes the entire lab
cpp-toolchain-status During download, caching, and compilation with the C++20 WebAssembly toolchain
csp-violation When Content Security Policy blocks an unauthorized resource inside Web Preview

Clone this wiki locally