Skip to content
innovatorvedPublic

About

Browser-Native Interactive IDE Lab & Virtual Node.js (JS/TS) Sandbox Engine, Powered by Monaco Editor, Web Workers, Virtual FS, and Loopback HTTP

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

@innovatorved/code-lab

CI npm version License: MIT Live Cloud IDE

Modular browser-native IDE workbench (v0.8.0), Web Worker runtime for Node.js, Bun, TypeScript, C++20 WebAssembly, and Python 3.12 WebAssembly, POSIX shell with 73 UNIX coreutils, and lightweight SQL playground built with strict TypeScript and Zod schemas — zero backend servers or cross-origin isolation headers required.

Try the Live Cloud IDE →

Highlights

  • Layered Modular Core: Four-layer workspace architecture with dependency injection, workspace settings and custom keybindings, a visual Settings dialog, Light (default), Dark, and High-Contrast themes, and lazy-loaded plugins.
  • VS Code Compact Layout (new in 0.8): No top navbar. The File, Edit, View and Help menus open from the ☰ button at the top of the Activity Bar, and Run, Verify, Guided/Sandbox and the language switch sit beside the editor tabs. The Cursor Light theme uses cool neutral chrome around a white editor, and host pages that define --ds-* design tokens keep their own colors.
  • SQL Editor & Playground (~16.5 KB gzipped): Standalone PostgreSQL 18 and SQLite 3 editor supporting inline lesson blocks, split-pane query studios, SQL formatting, schema-aware alias autocomplete, inline wavy diagnostics, and accessible keyboard navigation.
  • Node.js, Bun & WebAssembly Toolchains: Built-in JavaScript and JSX runtime with 50 built-in modules (50 Node.js built-ins) and native Bun APIs, plus opt-in TypeScript, Clang/LLVM C++20 WebAssembly, and Pyodide Python 3.12 extensions.
  • POSIX Shell & 73 Coreutils: Multi-session terminal with pipelines, stream redirection, background servers, public GitHub repository cloning, package installation, HTTP load testing, and 73 UNIX commands.
  • Guided Labs & Headless Grading: Step-by-step coding and SQL challenges with progressive hints, side-by-side solution diffs, and zero-UI headless worker execution.
  • Real Linux Terminal (opt-in, new in 0.8): A real Linux kernel in WebAssembly (unkernel) boots Alpine in the browser. Terminals become real ptys (vi, top, Ctrl+C), language: 'sh' guided steps are graded by check scripts, and Reset machine restores each step's snapshot. ~5 KB gzipped; the kernel loads lazily.

Install

bun add @innovatorved/code-lab
# or
npm install @innovatorved/code-lab

Or load via CDN with zero build tools:

<!-- Full IDE Workbench -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@innovatorved/code-lab/dist/code-lab.css" />
<script src="https://cdn.jsdelivr.net/npm/@innovatorved/code-lab/dist/code-lab.js"></script>

<!-- Standalone SQL Pack (~16.5 KB gzipped JS + CSS) -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@innovatorved/code-lab/dist/code-lab-sql.css" />
<script src="https://cdn.jsdelivr.net/npm/@innovatorved/code-lab/dist/code-lab-sql.umd.js"></script>

Quick Start

Browser IDE Workbench

import CodeLab from '@innovatorved/code-lab';
import '@innovatorved/code-lab/code-lab.css';

const lab = CodeLab.mount('#editor', {
  id: 'http-demo',
  title: 'Bun HTTP Server',
  lang: 'ts', // 'js' | 'ts' | 'sql' | 'py' | 'cpp' | 'sh'
  showLanguageSelector: true,
  entry: 'server.ts',
  // Pass user-customizable settings on init (or use `overrides` / `lockSettings: true` to lock them)
  settings: {
    'workbench.colorTheme': 'dark',
    'editor.fontSize': 14,
    'terminal.fontSize': 13,
    'sql.defaultDialect': 'postgres'
  },
  files: {
    'server.ts': 'Bun.serve({ port: 3000, fetch: () => Response.json({ ok: true }) });\n'
  }
});

Foreground servers started in the terminal (serve, npm run dev, node server.js, bun run server.ts) hold the terminal open until Ctrl+C (SIGINT) and automatically free their virtual port on exit. Append & (e.g., node server.js &) or open a second terminal session (+) to run commands concurrently.

Real Linux Terminal & Shell Labs

import CodeLab from '@innovatorved/code-lab';
import { linuxExtension } from '@innovatorved/code-lab/extensions/linux';

CodeLab.mount('#lab', {
  lang: 'sh',
  mode: 'guided',
  shStarterFiles: { 'run.sh': '#!/bin/sh\necho "hello from $(uname -sr)"\n' },
  steps: [{
    id: 'chmod',
    title: 'Make run.sh executable',
    instructions: 'Run `chmod +x run.sh` in the terminal, then Verify.',
    check: 'test -x /workspace/run.sh || { echo "run.sh is not executable yet"; exit 1; }'
  }],
  extensions: [linuxExtension({ distroUrl: '/linux/alpine.erofs' })]
});

Serve alpine.erofs yourself with HTTP Range support. Static hosts that ignore Range, including the free Cloudflare Pages plan, work with the small service worker in examples/cloud-ide/public/linux-lab/sw.js. npx -p @innovatorved/code-lab codelab-fetch-unkernel --out public/linux (or node tools/fetch-unkernel.js in a checkout) downloads the pinned image and SDK with checksum verification. The real kernel needs WebAssembly JSPI (Chrome/Edge 137+, Firefox 153+, Safari 27+); other browsers keep the simulated shell. See docs/PLUGINS.md §5 for options and CSP, and ARCHITECTURE.md §7 for how it works. The Linux kernel is GPL-2.0 and is never bundled; see docs/licenses.md.

Lightweight SQL Inline Editor & Playground

import { createSqlEditor } from '@innovatorved/code-lab/sql';
import '@innovatorved/code-lab/sql.css';

const sql = createSqlEditor(document.getElementById('sql')!, {
  mode: 'inline',
  dialect: 'postgres',
  value: 'SELECT id, email FROM customers ORDER BY id LIMIT 10;',
  async onRun({ effectiveSql }) {
    console.log('Execute SQL:', effectiveSql);
  }
});

Package Entrypoints

Import Path Purpose
@innovatorved/code-lab Full multi-file IDE workbench, POSIX terminal, Settings UI, plugins, and Web Preview
@innovatorved/code-lab/code-lab.css Main workbench stylesheet
@innovatorved/code-lab/sql Zero-dependency PostgreSQL 18 and SQLite 3 inline and playground editor (~16.5 KB gzipped)
@innovatorved/code-lab/sql.css Standalone SQL editor stylesheet
@innovatorved/code-lab/runtime Headless Web Worker runtime for programmatic code and test execution
@innovatorved/code-lab/shell Pure-JavaScript POSIX shell interpreter and 73 UNIX utilities
@innovatorved/code-lab/terminal 256-color PTY terminal emulator engine
@innovatorved/code-lab/schemas Zod runtime validation schemas and TypeScript types
@innovatorved/code-lab/extensions/* Opt-in extensions for Guided Labs, TypeScript, C++20 WebAssembly, and Python 3.12 WebAssembly
@innovatorved/code-lab/extensions/linux Opt-in real Linux terminal and sh shell labs (unkernel, loaded lazily)
@innovatorved/code-lab/preview-sw.js Virtual loopback Service Worker for standalone browser preview tabs

Full guides and API references live on the GitHub Wiki.

Embed Examples

Ready-to-copy starters live in examples/:

Repository Layout

├── packages/          # Layered workspace packages (core, fs, settings, commands, ui, sql)
├── src/               # Workbench shell, POSIX shell, virtual runtime, SCM, search, diagnostics & language extensions
├── examples/cloud-ide # Full Astro Cloud IDE demo app
├── tests/             # 49 unit/integration suites + E2E runner (50 suites) and Playwright browser specs
└── tools/             # Build bundler, linter, architecture boundary checker, and gzip size guard

Development

bun install
bun run build                  # Build all ESM, CJS, UMD bundles and TypeScript declarations
bun run check:boundaries       # Verify 4-layer package boundaries and zero circular imports
bun run check:size             # Enforce gzip bundle size budgets
bun run test:all               # Build bundles and run all 50 unit/integration/E2E suites
bun run test:browser           # Run Playwright browser tests (Chromium)
node tests/run-all.js          # Run the same 50 suites under Node 20, 22, and 24

See CONTRIBUTING.md for contribution guidelines.

License

MIT © Ved Gupta

About

Browser-Native Interactive IDE Lab & Virtual Node.js (JS/TS) Sandbox Engine, Powered by Monaco Editor, Web Workers, Virtual FS, and Loopback HTTP

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages