@innovatorved/code-lab 0.1.13 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/ARCHITECTURE.md +12 -7
  2. package/CHANGELOG.md +134 -0
  3. package/README.md +59 -9
  4. package/dist/code-lab.css +198 -0
  5. package/dist/code-lab.d.ts +37 -7
  6. package/dist/code-lab.esm.js +20444 -1278
  7. package/dist/code-lab.js +20439 -1276
  8. package/dist/extensions/cpp.d.ts +145 -0
  9. package/dist/extensions/cpp.esm.js +5932 -0
  10. package/dist/extensions/cpp.js +5951 -0
  11. package/dist/extensions/guided-lab.esm.js +86 -6
  12. package/dist/extensions/guided-lab.js +87 -6
  13. package/dist/extensions/javascript.d.ts +24 -0
  14. package/dist/extensions/javascript.esm.js +36 -0
  15. package/dist/extensions/javascript.js +59 -0
  16. package/dist/extensions/python.d.ts +92 -0
  17. package/dist/extensions/python.esm.js +5476 -0
  18. package/dist/extensions/python.js +5495 -0
  19. package/dist/extensions/typescript.d.ts +36 -0
  20. package/dist/extensions/typescript.esm.js +55 -0
  21. package/dist/extensions/typescript.js +78 -0
  22. package/dist/index.d.ts +9 -3
  23. package/dist/preview-sw.js +1 -1
  24. package/dist/runtime/index.d.ts +4 -0
  25. package/dist/runtime/module-loader.d.ts +11 -0
  26. package/dist/runtime/test-harness.d.ts +24 -0
  27. package/dist/runtime/vfs.d.ts +31 -0
  28. package/dist/runtime/wasi-host.d.ts +33 -0
  29. package/dist/runtime.d.ts +6 -0
  30. package/dist/runtime.esm.js +920 -15
  31. package/dist/runtime.js +914 -15
  32. package/dist/schemas.d.ts +237 -25
  33. package/dist/schemas.esm.js +85 -6
  34. package/dist/schemas.js +85 -6
  35. package/dist/shell/coreutils/compilers-cli.d.ts +24 -0
  36. package/dist/shell/index.d.ts +4 -0
  37. package/dist/shell/lexer-parser.d.ts +26 -0
  38. package/dist/shell.esm.js +289 -4
  39. package/dist/shell.js +289 -4
  40. package/dist/terminal.esm.js +1 -1
  41. package/dist/terminal.js +1 -1
  42. package/dist/workbench/command-palette.d.ts +10 -0
  43. package/dist/workbench/diff-editor.d.ts +26 -0
  44. package/dist/workbench/drawer.d.ts +18 -0
  45. package/dist/workbench/editor.d.ts +11 -0
  46. package/dist/workbench/file-tree.d.ts +11 -0
  47. package/dist/workbench/guided-pane.d.ts +11 -0
  48. package/dist/workbench/icons.d.ts +5 -0
  49. package/dist/workbench/index.d.ts +39 -0
  50. package/dist/workbench/share.d.ts +21 -0
  51. package/dist/workbench/styles.d.ts +4 -0
  52. package/dist/workbench/toolbar.d.ts +17 -0
  53. package/dist/workbench.d.ts +6 -1
  54. package/package.json +33 -3
  55. package/src/code-lab.css +198 -0
  56. package/src/extensions/cpp.ts +1786 -0
  57. package/src/extensions/guided-lab.ts +10 -0
  58. package/src/extensions/javascript.ts +54 -0
  59. package/src/extensions/python.ts +1293 -0
  60. package/src/extensions/typescript.ts +85 -0
  61. package/src/index.ts +66 -3
  62. package/src/runtime/index.ts +5 -0
  63. package/src/runtime/test-harness.ts +57 -0
  64. package/src/runtime.ts +915 -14
  65. package/src/schemas.ts +94 -7
  66. package/src/shell/coreutils/compilers-cli.ts +103 -0
  67. package/src/shell/index.ts +5 -0
  68. package/src/shell.ts +288 -3
  69. package/src/workbench/command-palette.ts +140 -0
  70. package/src/workbench/diff-editor.ts +216 -0
  71. package/src/workbench/drawer.ts +148 -0
  72. package/src/workbench/editor.ts +49 -0
  73. package/src/workbench/file-tree.ts +51 -0
  74. package/src/workbench/guided-pane.ts +33 -0
  75. package/src/workbench/icons.ts +48 -0
  76. package/src/workbench/index.ts +38 -0
  77. package/src/workbench/share.ts +99 -0
  78. package/src/workbench/styles.ts +200 -0
  79. package/src/workbench/toolbar.ts +171 -0
  80. package/src/workbench.ts +1016 -78
package/ARCHITECTURE.md CHANGED
@@ -1,6 +1,6 @@
1
- # `@innovatorved/code-lab` Architecture (v0.1.13)
1
+ # `@innovatorved/code-lab` Architecture (v0.3.0)
2
2
 
3
- `@innovatorved/code-lab` is an embeddable, browser-native Node.js v22 + Bun v1.1 IDE, POSIX shell, PTY terminal, and virtual execution sandbox with self-contained browser bundles (zero runtime dependencies in `dist/*`; Zod schemas available under `@innovatorved/code-lab/schemas`).
3
+ `@innovatorved/code-lab` is an embeddable, browser-native Node.js v22 + Bun v1.1 + WASI C++20 + Python 3.12 IDE, POSIX shell, PTY terminal, and virtual execution sandbox with self-contained browser bundles (zero runtime dependencies in `dist/*`; Zod schemas available under `@innovatorved/code-lab/schemas`; modular extensions under `@innovatorved/code-lab/extensions/{guided-lab,javascript,typescript,cpp,python}`).
4
4
 
5
5
  It is designed around two strictly decoupled layers that can be used together (`dist/code-lab.js`) or independently (`dist/runtime.js`, `dist/shell.js`, `dist/terminal.js` for headless or modular execution):
6
6
 
@@ -27,9 +27,9 @@ It is designed around two strictly decoupled layers that can be used together (`
27
27
  │ src/terminal.ts) │ │ (src/runtime.ts) │
28
28
  │ • Recursive-descent AST parser │ │ • Web Worker pool + preemption │
29
29
  │ • Pipes (|), redirects (>, >>, 2>&1) │ │ • In-memory POSIX VFS (/tmp, …) │
30
- │ • 64 POSIX coreutils + git + jq │ │ • Node.js v22 (50 built-in mods)│
30
+ │ • 71 POSIX coreutils + git + jq │ │ • Node.js v22 (50 built-in mods)│
31
31
  │ • Interactive PTY ANSI/256-color │ │ • Bun v1.1 (serve, sqlite, test)│
32
- │ • Job table (ps, jobs, fg, bg, kill) │ │ • VirtualPortTable (127.0.0.1) │
32
+ │ • Job table (ps, jobs, fg, bg, kill) │ │ • WASI Preview 1 + C++20 Clang │
33
33
  └───────────────────────────────────────┘ └──────────────────────────────────┘
34
34
  ```
35
35
 
@@ -69,11 +69,11 @@ It is designed around two strictly decoupled layers that can be used together (`
69
69
 
70
70
  `createPosixShell` implements a complete POSIX shell interpreter inside the browser:
71
71
  - **Lexer & Recursive-Descent AST Parser**: Supports single/double quotes, escape sequences, pipelines (`cmd1 | cmd2 | cmd3`), logical operators (`&&`, `||`, `;`), background execution (`&`), I/O redirection (`>`, `>>`, `<`, `<<<`, `2>`, `2>&1`, `&>`), environment variable expansion (`$VAR`, `${VAR:-default}`, `${VAR:=default}`, `${#VAR}`, `$?`, `$$`), command substitution (`$(...)`), arithmetic expansion (`$((...))`), brace expansion (`{a,b,c}`, `{1..5}`), and globbing (`*`, `?`, `**`).
72
- - **64 Built-in Coreutils**:
72
+ - **71 Built-in Coreutils**:
73
73
  - File & Directory: `ls`, `cat`, `head`, `tail`, `wc`, `cp`, `mv`, `rm`, `mkdir`, `rmdir`, `touch`, `ln`, `pwd`, `cd`, `find`, `tree`, `stat`, `file`, `du`, `df`, `chmod`, `chown`, `mktemp`, `basename`, `dirname`, `realpath`.
74
74
  - Text & Data Processing: `grep`, `sed`, `awk`, `sort`, `uniq`, `cut`, `tr`, `tee`, `xargs`, `diff`, `jq`, `xxd`, `hexdump`, `base64`, `md5sum`, `sha256sum`.
75
75
  - Networking, Load Testing, Chaos & Databases: `curl`, `hey` (`ab`, `wrk`), `chaos`, `sqlite3`, `redis-cli`, `nc`, `ping`, `dig`, `nslookup`, `lsof`, `netstat`, `ss`, `ps`, `top`, `kill`, `jobs`, `fg`, `bg`, `tar`, `gzip`, `gunzip`.
76
- - Developer Toolchains: `node`, `bun`, `npm`, `pnpm`, `npx`, `bunx`, `tsc`, `git` (`init`, `status`, `add`, `commit`, `log`, `diff`, `branch`, `checkout`, `clone`).
76
+ - Developer Toolchains: `node`, `bun`, `npm`, `pnpm`, `npx`, `bunx`, `tsc`, `g++`, `clang++`, `c++`, `python`, `python3`, `pytest`, `pip`, `git` (`init`, `status`, `add`, `commit`, `log`, `diff`, `branch`, `checkout`, `clone`).
77
77
  - Web Preview: `serve` (built-in static dev server that transpiles TS/TSX/JSX to browser-native ESM and injects a jsDelivr `+esm` import map for bare specifiers).
78
78
 
79
79
  ---
@@ -109,6 +109,11 @@ Running `bun run build` (`bun run tools/bundle.js`) produces:
109
109
  - `dist/runtime.js` & `dist/runtime.esm.js` (headless virtual runtime)
110
110
  - `dist/shell.js` & `dist/shell.esm.js` (standalone POSIX shell & coreutils)
111
111
  - `dist/terminal.js` & `dist/terminal.esm.js` (standalone PTY terminal engine)
112
+ - `dist/extensions/guided-lab.js`, `dist/extensions/guided-lab.esm.js` & `dist/extensions/guided-lab.d.ts` (opt-in Guided Lab stepper, hints, and multi-language challenge verification)
113
+ - `dist/extensions/javascript.js`, `dist/extensions/javascript.esm.js` & `dist/extensions/javascript.d.ts` (zero-dependency JavaScript language extension)
114
+ - `dist/extensions/typescript.js`, `dist/extensions/typescript.esm.js` & `dist/extensions/typescript.d.ts` (opt-in TypeScript language extension)
115
+ - `dist/extensions/cpp.js`, `dist/extensions/cpp.esm.js` & `dist/extensions/cpp.d.ts` (opt-in Real C++20 in WebAssembly Clang/LLVM + LLD + WASI Preview 1 toolchain extension)
116
+ - `dist/extensions/python.js`, `dist/extensions/python.esm.js` & `dist/extensions/python.d.ts` (opt-in Real Python 3.12 in WebAssembly CPython WASI / Pyodide extension)
112
117
  - `dist/code-lab.css` (standalone dark/light CSS variables & workbench styles)
113
118
  - `dist/preview-sw.js` (Web Preview virtual-loopback Service Worker for pop-out tabs; also copied to `examples/cloud-ide/public/preview-sw.js` for root scope)
114
119
  - `dist/code-lab.d.ts` (TypeScript definitions for `CodeLab`, `CodeLabWorkbench`, `CodeLabElement`, `CodeLabRuntime`, `CodeLabShell`, `CodeLabTerminal`, and the strict leaf modules `zip`, `storage`, `search`, `diagnostics`, and `scm`)
@@ -128,6 +133,6 @@ Running `bun run build` (`bun run tools/bundle.js`) produces:
128
133
  | **Visual Source Control (SCM)** | Staging, unstaging, diffing, and commit history | `src/scm.ts` (`createGitState`, `computeGitStatus`, `stageFile`, `unstageFile`, `commitChanges`, `computeShortCommitHash`) — Pure TypeScript SCM state machine synced with the POSIX shell `git` command |
129
134
  | **Live Preview & Error Overlay** | Hot/debounced reload, console bridge, runtime error overlay | `src/csp.ts` (`buildPreviewShims`) + `src/workbench.ts` — 300ms debounced VFS-synced auto-reload, `codelab:preview-console` forwarding to terminal logs, and `codelab:preview-error` in-frame overlay |
130
135
 
131
- All 40 test suites (`bun run test:all` and `node tests/run-all.js`) and the Playwright Chromium E2E suite (`bun run test:browser`) verify these modules and end-to-end workbench flows against the built `dist/*` artifacts.
136
+ All 43 test suites (`bun run test:all` and `node tests/run-all.js`) and the Playwright Chromium E2E suite (`bun run test:browser`) verify these modules and end-to-end workbench flows against the built `dist/*` artifacts.
132
137
 
133
138
 
package/CHANGELOG.md ADDED
@@ -0,0 +1,134 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@innovatorved/code-lab` are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.3.0] - 2026-10-24
8
+
9
+ ### Added
10
+ - **Core Codebase Modularization (`src/workbench/`, `src/runtime/`, `src/shell/`)**:
11
+ - Refactored monolithic files into clean, single-responsibility submodules while keeping all package entrypoints (`src/index.ts`, `dist/code-lab.{js,esm.js,d.ts}`, `dist/extensions/*`) 100% backwards-compatible.
12
+ - Safe, idempotent `.use()` extension chaining that refreshes toolbar and language switcher controls without destroying an already mounted Monaco instance or leaking DOM listeners.
13
+ - **Contextual Execution UI & Smooth Workbench UX**:
14
+ - **Guided Lab Mode**: Features prominent `[▶ Run Demo (⇧⌘↵)]` and primary `[✓ Verify Step (⌘↵)]` actions in the topbar with the `Test Suite` drawer tab open by default.
15
+ - **Normal / Sandbox Mode**: Features a VS Code-style split button `[▶ Run Code (⌘↵) | ▾]` with dropdown options (`Run Entry`, `Run Active File`, `Run Tests`, `Configure Stdin`), with the drawer defaulting to `Terminal & REPL` and the `Test Suite` tab neatly hidden until tests are executed.
16
+ - **Contextual Web Preview**: Topbar globe button and drawer tab are automatically hidden on pure DSA / C++ / Python workspaces and dynamically reveal only when HTML files exist or an HTTP/Bun server listens on a port.
17
+ - **Six High-Impact IDE Power Features**:
18
+ - **First-Class Problems Drawer Tab**: Dedicated `⚠ Problems (N)` tab aggregating JS/TS, C++, and Python diagnostics with live badges and 1-click cursor navigation to error line and column.
19
+ - **Execution Time & Peak Memory HUD Badge**: High-resolution performance badge (`⏱ 12.4 ms · 🧠 1.8 MB`) in the drawer header and status bar across Node, Bun, WASI C++, and Pyodide.
20
+ - **Collapsible Stdin / Custom Input Panel**: Monospace textarea in the drawer for passing DSA / competitive-programming input directly into `std::cin`, `sys.stdin`, and `process.stdin`.
21
+ - **Native Monaco Side-by-Side Diff Editor**: Inline Monaco diff editor (`monaco.editor.createDiffEditor`) with segmented toggles for `Starter ↔ Current` and `Current ↔ Solution` with 1-click revert and solution apply.
22
+ - **Visible Command Palette Pill & Format Document**: Clickable topbar `🔍 Command Palette (⇧⌘P)` pill trigger + `Format Document` (`⇧⌥F`) across all languages.
23
+ - **Zero-Backend URL Workspace Snapshot**: URL hash snapshot compression (`#codelab=<base64url>`) powered by `CompressionStream('deflate-raw')` for instant zero-server workspace sharing.
24
+ - **Built-in VS Code-Style C++20 Intelligence (`@innovatorved/code-lab/extensions/cpp`)**:
25
+ - Rich Monaco completions for STL containers, algorithms, types, and standard library headers with detailed hover documentation.
26
+ - Debounced static AST linter (`analyzeCppSource`) and live Clang compiler stderr error-squiggles (`applyClangStderrDiagnostics`).
27
+ - **Python 3.12 WebAssembly Extension (`@innovatorved/code-lab/extensions/python`)**:
28
+ - Pure CPython 3.12 WebAssembly execution via Pyodide with lazy-loaded CDN binaries and IndexedDB caching.
29
+ - Seeded `/usr/lib/python/` standard DSA helpers (`codelab_dsa.py` with `ListNode`, `TreeNode`, `MinHeap`, `MaxHeap`) and structured test framework (`codelab_test.py` with `describe`, `it`, `assert_equal`, `__CODELAB_TEST__` telemetry).
30
+ - Shell CLI commands: `python`, `python3`, `pytest`, `pip` (expanding POSIX coreutils to 71).
31
+ - 4-way language switcher (`JS | TS | C++ | PY`).
32
+ - Traceback and static linting (`applyPythonTracebackDiagnostics`, `analyzePythonSource`) and PEP-8 formatting (`formatPythonSource`).
33
+
34
+ ## [0.2.0] - 2026-10-24
35
+
36
+ ### Added
37
+ - **Real C++20 in WebAssembly Extension (`@innovatorved/code-lab/extensions/cpp`, `src/extensions/cpp.ts`)**:
38
+ - Real ~35 MB Clang/LLVM + LLD (`wasm-ld`) + WASI C++20 Sysroot (`libc` + `libc++`) toolchain downloaded on demand only when `cppExtension` is used and cached persistently in `IndexedDB` (`codelab_cpp_toolchain_v1`).
39
+ - Built-in Competitive Programming & DSA headers seeded into `/usr/include`: `<bits/stdc++.h>`, `<codelab/dsa.hpp>` (`ListNode`, `TreeNode`, `buildLinkedList`, `buildBinaryTree`, `printMatrix`, `BenchmarkTimer`), and `<codelab/test.hpp>` (`DESCRIBE`, `TEST`, `IT`, `ASSERT_EQ`, `ASSERT_NE`, `ASSERT_TRUE`, `ASSERT_FALSE`) emitting structured `__CODELAB_TEST__:{json}` markers to `code-lab`'s Test Suite drawer and Guided Lab `Verify Step`.
40
+ - Pure TypeScript POSIX UStar `.tar` extractor and generator (`extractTarToVfs`, `createTarArchive`).
41
+ - **WASI Preview 1 Syscall Layer (`src/runtime.ts`)**:
42
+ - Added `createVirtualWasi` (`wasi_snapshot_preview1`) and `executeWasiModule` backed by `VirtualFS` (`fd_read`, `fd_write`, `fd_seek`, `fd_close`, `path_open`, `path_create_directory`, `path_unlink_file`, `args_get`, `environ_get`, `clock_time_get`, `random_get`, `proc_exit` via `WasiExitSignal`).
43
+ - `executeInVirtualRuntime` now supports `.wasm` and `.cpp` entrypoints directly and parses `__CODELAB_TEST__:{json}` lines into `testResults`.
44
+ - **POSIX Shell C++ Compiler & WASI Binary Execution (`src/shell.ts`)**:
45
+ - Added `g++`, `clang++`, and `c++` commands (`67` total POSIX coreutils) plus direct `./<binary>` (`.wasm` magic byte `0x00 0x61 0x73 0x6d`) execution with `< input.txt` stdin and `> output.txt` / `>>` stdout redirection.
46
+ - **Modular Language Extensions (`@innovatorved/code-lab/extensions/{javascript,typescript,cpp}`)**:
47
+ - **JavaScript (`javascriptExtension`)**: Enabled **by default out-of-the-box** using the browser's native JS engine and `code-lab`'s zero-dependency `node` & `bun` virtual runtime.
48
+ - **TypeScript (`typescriptExtension`)**: Opt-in zero-dependency browser extension using `code-lab`'s built-in `transpileTS` + virtual `node`/`bun` runtime.
49
+ - **C++ (`cppExtension`)**: Opt-in WebAssembly Clang/LLVM + WASI C++20 extension.
50
+ - **3-Way Language Switcher (`JS | TS | C++`) & Multi-Language Guided Labs (`src/workbench.ts`, `src/schemas.ts`)**:
51
+ - Added `cppStarterFiles`, `cppSolutionFiles`, and `cppFiles` to `GuidedLabExtensionOptionsSchema` and `WorkbenchOptionsSchema`.
52
+ - Workbench language switcher dynamically renders pills for the enabled languages (`wb.enabledLanguages`).
53
+
54
+ ### Breaking Changes & Migration Guide (`v0.1.x` $\rightarrow$ `v0.2.0`)
55
+ 1. **Default Workbench Language Surface (`['js']` by default)**:
56
+ - **Before (`v0.1.x`)**: Mounting a standalone workbench without language extensions exposed only JavaScript unless `guidedLabExtension` was configured with `ts*` files.
57
+ - **Now (`v0.2.0`)**: JavaScript (`javascriptExtension`) + zero-dependency virtual `node` and `bun` remains enabled by default (`0 MB` extra download). To enable TypeScript or C++ in the workbench toolbar switcher (`JS | TS | C++`), register `typescriptExtension` and/or `cppExtension` via `.use()` or `extensions: [...]`:
58
+ ```ts
59
+ import CodeLab, {
60
+ typescriptExtension,
61
+ cppExtension,
62
+ guidedLabExtension
63
+ } from '@innovatorved/code-lab';
64
+
65
+ const lab = CodeLab.mount('#editor', {
66
+ id: 'dsa-binary-search',
67
+ title: 'Binary Search in Depth',
68
+ language: 'cpp'
69
+ })
70
+ .use(typescriptExtension)
71
+ .use((wb) => cppExtension(wb, { std: 'c++20' }))
72
+ .use((wb) =>
73
+ guidedLabExtension(wb, {
74
+ starterFiles: { 'src/solution.js': '...' },
75
+ tsStarterFiles: { 'src/solution.ts': '...' },
76
+ cppStarterFiles: { 'src/solution.cpp': '...' },
77
+ steps: [...]
78
+ })
79
+ );
80
+ ```
81
+ - **Backward Compatibility**: Existing `guidedLabExtension(wb, { tsStarterFiles })` or `cppStarterFiles` configs automatically add `'ts'` / `'cpp'` to `wb.enabledLanguages`.
82
+ 2. **`LanguageIdSchema` Enum Widened**:
83
+ - `LanguageIdSchema` (`@innovatorved/code-lab/schemas`) is now `z.enum(['js', 'ts', 'cpp'])` (previously `z.enum(['js', 'ts'])`). TypeScript consumers switching exhaustively on `LanguageId` should handle `'cpp'`.
84
+
85
+ ## [0.1.13] - 2026-10-23
86
+
87
+ ### Added
88
+ - **System Design Chaos Engine & Port Telemetry (`src/runtime.ts`)**: Extended `VirtualPortTable` with per-port fault injection (`setChaos`, `getChaos`, `clearChaos`: latency/jitter injection, HTTP 503 error rate, and partitioned/down nodes) and rolling 60-second SLO telemetry (`recordMetric`, `getMetrics`, `getAllMetrics`: live RPS, `p50`/`p95`/`p99` latency, error rate, and upstream call graph edges).
89
+ - **4 System Design POSIX Coreutils (`src/shell.ts`)**: Added `hey` / `ab` / `wrk` (concurrent HTTP load generator with ASCII latency histograms and `p50`/`p90`/`p95`/`p99` percentiles), `chaos` (CLI fault injector for port latency, error rate, and partitions), `sqlite3` (interactive CLI with `.tables`, `.schema`, and `EXPLAIN QUERY PLAN`), and `redis-cli` (in-memory + VFS-persisted Redis server/CLI supporting strings, TTLs, atomic counters, lists, hashes, sets, and sorted sets).
90
+ - **VFS-Persisted SQLite with Secondary Indexes & Query Planner (`src/runtime.ts`)**: Added file-backed persistence (`/workspace/*.db`), `CREATE INDEX` / `DROP INDEX`, `PRAGMA index_list`, and `EXPLAIN QUERY PLAN` (`SCAN TABLE` vs `SEARCH TABLE ... USING INDEX`) to `bun:sqlite`.
91
+ - **Workbench SLO Telemetry Bar, Live Topology Graph & 1-Click Chaos Pills (`src/workbench.ts`, `src/code-lab.css`)**: Added live RPS/`p50`/`p95`/`p99`/Error% telemetry bar, interactive ASCII/SVG topology trace (`Client -> LB :3000 -> Worker :3001`), and 1-click Chaos pills (`+200ms Latency`, `25% HTTP 503`, `Kill Node`, `Run hey Load Test`) to the Ports & Networking panel.
92
+ - **Distributed System Cluster Presets (`examples/cloud-ide/src/pages/index.astro`)**: Added `Distributed Cluster & Chaos Lab` (`sd-cluster`) and `High-Scale URL Shortener` (`sd-shortener`) templates to the Cloud IDE.
93
+
94
+ ## [0.1.10] - 2026-10-22
95
+
96
+ ### Fixed
97
+ - **Live Browser Preview CSP & React ESM Deduplication (`src/csp.ts`, `src/shell.ts`)**: Added `data:` to `script-src` in `buildPreviewPolicy` so local `.ts`/`.tsx` modules mapped via import maps execute under the preview CSP, and deduplicated the React ESM URL in `buildHtmlPreviewResponse` so `react-dom/client` and local TSX modules share a single React instance.
98
+ - **Right Split-Pane Preview Grid & Drawer Layout Polish (`src/code-lab.css`, `src/workbench.ts`)**: Added `.codelab-workspace.has-preview-split` 5-column grid layout, preserved preview toolbar visibility in the bottom drawer (`min-height: 0` + scroll reset), widened the split-pane URL input, and refined the `.codelab-ports-panel` column ratios.
99
+
100
+ ## [0.1.9] - 2026-10-22
101
+
102
+ ### Added
103
+ - **StackBlitz-Grade Web Preview Engine & Split-Pane Dock (`src/csp.ts`, `src/shell.ts`, `src/workbench.ts`, `src/code-lab.css`)**: Right-hand split-pane preview dock (`#cl-preview-split`, `#cl-splitter-preview`), maximize toggle, inline collapsible preview console, dynamic HTML/React/TSX bundler and local asset inliner, and sandboxed iframe loopback bridge (`fetch()`, relative `<a href>` navigation, SPA `history.pushState`/`replaceState` URL sync).
104
+ - **Ports Manager, Mini HTTP Client & Network Inspector UI (`src/code-lab.css`, `src/workbench.ts`)**: Complete 2-column grid layout and styling for `.codelab-ports-panel`, `.codelab-http-client`, and `.codelab-network-panel`, plus fixed event handlers for HTTP header editing and network request filtering/selection.
105
+ - **Durable Browser Auto-Save & Page-Refresh State Persistence (`src/workbench.ts`, `examples/cloud-ide/src/pages/index.astro`)**: Added `hasSnapshot` tracking and IndexedDB mirroring so user edits, newly created files, and deleted default files persist across page reloads, with immediate state flushing on `visibilitychange`.
106
+
107
+ ## [0.1.8] - 2026-10-22
108
+
109
+ ### Added
110
+ - **Project ZIP Export & Import (`src/zip.ts`)**: Pure TypeScript IEEE 802.3 CRC-32 + PKWARE ZIP v2.0 archive generator/extractor (`createZip`, `extractZip`, `wb.exportProjectZip()`, `wb.importProjectZip()`) with Zip-Slip path sanitization.
111
+ - **Cascading Workspace Storage (`src/storage.ts`)**: Durable multi-project workspace persistence cascading `IndexedDB` $\rightarrow$ `localStorage` $\rightarrow$ in-memory fallback (`WorkspaceStorage`, `createWorkspaceStorage`) with automatic quota-exceeded recovery.
112
+ - **Workspace-Wide Search & Replace (`src/search.ts`)**: Regex, case-sensitive, whole-word, and glob-filtered search/replace (`searchInFiles`, `replaceInFiles`, `wb.searchWorkspace()`, `wb.replaceInWorkspace()`, `wb.showSearchModal()`, `⇧⌘F`).
113
+ - **Diagnostics & Problems Panel (`src/diagnostics.ts`)**: Structured workspace diagnostics store (`DiagnosticsStore`, `createDiagnosticsStore`, `wb.getDiagnostics()`, `wb.showProblemsModal()`).
114
+ - **Source Control (SCM) Engine (`src/scm.ts`)**: Porcelain Git status, staging, unstaging, and commit creation (`createGitState`, `computeGitStatus`, `stageFile`, `unstageFile`, `commitChanges`, `wb.getGitStatus()`, `wb.showScmModal()`).
115
+ - **Live Preview Console Bridge, Error Overlay & Debounced Auto-Reload**: In-preview runtime error overlay (`#codelab-preview-error-overlay`), console/error `postMessage` bridge (`codelab:preview-console`, `codelab:preview-error`), 300ms debounced preview reload on editor edits, and multi-port server selector.
116
+ - **Multi-Session Terminal & Multi-CDN Package Fallback**: Multi-session terminal management (`createTerminalSession`, `switchTerminalSession`, `closeTerminalSession`, `listTerminalSessions`), cascading npm CDN resolution (`jsDelivr` $\rightarrow$ `unpkg` $\rightarrow$ `esm.sh`), and deterministic `/workspace/package-lock.json` v3 generation.
117
+ - **Shared Preview CSP Builder (`src/csp.ts`)**: Added `buildPreviewCsp`, `injectCspMeta`, `resolvePreviewCspMode`, and the `previewCsp` workbench option / `preview-csp` HTML attribute supporting `'strict'`, `'balanced'` (new default), `'permissive'`, or a custom CSP policy string across both the embedded `srcdoc` iframe and `preview-sw.js`.
118
+ - **Preview CSP Violation Reporting**: Injected a `securitypolicyviolation` listener into the preview bridge that forwards blocked resource details (`blockedURI`, `violatedDirective`, `effectiveDirective`, `sourceFile`, `lineNumber`) to the host workbench (`csp-violation` event and structured logger warning).
119
+ - **Structured Diagnostics & Error Taxonomy (`src/logger.ts`)**: Added `CodeLabError` (`code`, `context`, `cause`), `isCodeLabError`, `createLogger`, and the `logLevel` workbench option (`'silent' | 'error' | 'warn' | 'info' | 'debug'`).
120
+ - **Save-State Events & Quota Indicator**: Emits `save-state` (`{ state: 'saving' | 'saved' | 'failed', status, labId, error }`) and `error` (`CodeLabError('E_SAVE', ...)`) when `localStorage` persistence fails, updating `#cl-status-save` to `⚠ Save failed (session-only)` instead of falsely displaying `Saved`.
121
+ - **Strict SafeHtml Template Tag (`src/html.ts`)**: Added `SafeHtml`, `html`, `raw`, `isSafeHtml`, and `escapeHtml` with `Symbol.for('codelab.SafeHtml')` branding to prevent accidental unescaped DOM interpolation.
122
+ - **Strict TypeScript Ratchet & Empty-Catch Lint Gate**: Added `tsconfig.strict.json` (`bun run typecheck:strict`) covering all 8 strict leaf modules (`src/csp.ts`, `src/logger.ts`, `src/html.ts`, `src/zip.ts`, `src/storage.ts`, `src/search.ts`, `src/diagnostics.ts`, `src/scm.ts`), plus `tools/lint.js` (`bun run lint`) enforcing zero empty `catch` blocks and strict module coverage in CI.
123
+ - **Repository Governance**: Added `SECURITY.md`, `CONTRIBUTING.md`, `CHANGELOG.md`, `.github/dependabot.yml`, and `.github/workflows/release.yml` (tag-triggered npm provenance publishing).
124
+
125
+ ### Fixed
126
+ - **Markdown Balanced-Parenthesis Link Parsing**: `renderInlineFormatting` in `src/workbench.ts` now parses balanced parentheses inside Markdown `[text](url)` destinations (e.g., Wikipedia URLs like `https://en.wikipedia.org/wiki/B-tree_(data_structure)`) and blocks `javascript:alert(1)` links without leaving trailing `)` characters in the output.
127
+ - **Portable Bundle-First Test Suites**: All 39 test suites now load built artifacts from `dist/` via `tests/helpers/load.js` (`assertFresh()`) and run identically under Bun and Node 20/22/24.
128
+ - **Documentation Capability Counts**: Synchronized `README.md` and `ARCHITECTURE.md` counts (`58` POSIX coreutils, `50` Node.js built-in modules, `39` test suites, `6-Tab Bottom Drawer`) with automated regression checks in `tests/test-version-sync.js`.
129
+
130
+ ## [0.1.7] - 2026-04-19
131
+
132
+ ### Added
133
+ - Consolidated TypeScript source tree under `src/*.ts` with deterministic single-source version injection from `package.json` (`tools/bundle.js`).
134
+ - Added headless runtime, POSIX shell (58 coreutils, streaming `git clone`), PTY terminal engine, and 6-tab IDE workbench with embedded and Service Worker pop-out Web Preview.
package/README.md CHANGED
@@ -2,23 +2,33 @@
2
2
 
3
3
  > **Note:** This project is in active development. APIs and sandbox internals are stable for production use.
4
4
 
5
- Browser-native code IDE workbench, modular guided challenge engine (`@innovatorved/code-lab/extensions/guided-lab`), POSIX shell with 64 UNIX coreutils, public GitHub repository cloner (`git clone`), and Web Worker execution runtime for **Node.js** and **Bun** (JavaScript & TypeScript) with Zod type safety and zero backend server dependencies.
5
+ Browser-native code IDE workbench, modular guided challenge engine (`@innovatorved/code-lab/extensions/guided-lab`), modular language extensions (`javascript`, `typescript`, real WebAssembly `cpp`, and WebAssembly `python`), POSIX shell with 71 UNIX coreutils, public GitHub repository cloner (`git clone`), and Web Worker execution runtime for **Node.js**, **Bun** (JavaScript & TypeScript), **C++20 (Clang/LLVM + WASI)**, and **Python 3.12 (CPython WASI)** with Zod type safety and zero backend server dependencies.
6
6
 
7
7
  - **Live Cloud IDE & GitHub Repo Explorer**: **[https://code-lab-3dr.pages.dev](https://code-lab-3dr.pages.dev)** — Enter any public GitHub repository (`owner/repo` or URL) to clone and run it directly in your browser.
8
- - **Built for**: [System Design In Depth](https://system-design-in-depth.vedgupta.in)
8
+ - **Built for**: [System Design In Depth](https://system-design-in-depth.vedgupta.in) & Data Structures & Algorithms (DSA) In Depth
9
9
 
10
10
  ---
11
11
 
12
12
  ## Features
13
13
 
14
- - **Modular Architecture (`v0.1.13`)**: Pure, general-purpose browser IDE (`code-lab`) by default with File Explorer, Monaco Editor, and PTY Terminal. Curriculum features (Guided Steps, Mode Switcher, and JS/TS switcher) are encapsulated in an opt-in modular extension (`@innovatorved/code-lab/extensions/guided-lab`).
15
- - **End-to-End TypeScript & Zod Type Safety**: Written in TypeScript with strict runtime schemas and inferred types (`z.infer<typeof ...>`) for workbench options, guided labs, runtime execution, and git cloning.
14
+ - **Modular Architecture (`v0.3.0`)**: Pure, general-purpose browser IDE (`code-lab`) by default with File Explorer, Monaco Editor, PTY Terminal, and zero-dependency **JavaScript + Node.js/Bun** execution out of the box. Additional languages (`@innovatorved/code-lab/extensions/typescript`, `@innovatorved/code-lab/extensions/cpp`, and `@innovatorved/code-lab/extensions/python`) and curriculum features (`@innovatorved/code-lab/extensions/guided-lab`) are opt-in modular extensions.
15
+ - **Real C++20 in WebAssembly (`@innovatorved/code-lab/extensions/cpp`)**: Compile and run real C++17/C++20/C++23 code natively in the browser via a WebAssembly Clang/LLVM + LLD (`wasm-ld`) + WASI `libc++` sysroot toolchain (~35 MB downloaded on demand only when the C++ extension is used and cached in `IndexedDB`). Features rich VS Code-style Monaco IntelliSense with auto-completions, header hovers, debounced static AST linting (`analyzeCppSource`), and live Clang compiler stderr error-squiggles (`applyClangStderrDiagnostics`). Includes `<bits/stdc++.h>`, `<codelab/dsa.hpp>` (`ListNode`, `TreeNode`, `buildLinkedList`, `buildBinaryTree`), and `<codelab/test.hpp>` (`DESCRIBE`, `TEST`, `ASSERT_EQ`) wired directly into the Test Suite drawer and Guided Lab step verification.
16
+ - **Python 3.12 WebAssembly Extension (`@innovatorved/code-lab/extensions/python`)**: Run pure CPython 3.12 WebAssembly via Pyodide with lazy-loaded CDN binaries and IndexedDB caching. Features bidirectional VFS sync, pre-seeded `/usr/lib/python/` standard DSA helpers (`codelab_dsa.py` with `ListNode`, `TreeNode`, `MinHeap`, `MaxHeap`) and structured test framework (`codelab_test.py` with `describe`, `it`, `assert_equal`), Monaco completion/hover intelligence, traceback-to-squiggle mapping (`applyPythonTracebackDiagnostics`), static linting (`analyzePythonSource`), and formatting (`formatPythonSource`).
17
+ - **Contextual Execution UI & Smooth Workbench**: Guided Challenge mode features a prominent primary `[✓ Verify Step (⌘↵)]` button with the `Test Suite` drawer tab visible by default. Normal/Sandbox mode provides a clean VS Code-style split button `[▶ Run Code (⌘↵) | ▾]` with dropdown options (`Run Entry`, `Run Active File`, `Run Tests`, `Configure Stdin`), with the drawer defaulting to `Terminal & REPL`. The topbar `Web Preview` globe button and bottom `Web Preview` drawer tab are contextual and stay neatly hidden unless the project contains web files or an active HTTP server.
18
+ - **High-Impact IDE Power Features**:
19
+ - **Problems Drawer Tab**: Dedicated `⚠ Problems (N)` tab aggregating JS/TS, C++, and Python diagnostics with live counter badge and 1-click cursor jump to line and column.
20
+ - **Execution Time & Peak Memory HUD Badge**: High-resolution performance telemetry pill (`⏱ 12.4 ms · 🧠 1.8 MB`) displayed in the drawer header and status bar across Node, Bun, WASI C++, and Pyodide.
21
+ - **Collapsible Stdin / Custom Input Panel**: Monospace textarea in the drawer for passing competitive-programming / DSA input directly into `std::cin`, `sys.stdin`, and `process.stdin`.
22
+ - **Native Monaco Side-by-Side Diff Editor**: Compare `Starter ↔ Current` and `Current ↔ Solution` with 1-click "Revert" and "Apply Solution" actions directly in Monaco.
23
+ - **Visible Command Palette Pill & Format Document**: Clickable topbar `🔍 Command Palette (⇧⌘P)` pill trigger + `Format Document` (`⇧⌥F`) across all languages.
24
+ - **Zero-Backend URL Workspace Snapshot**: URL hash snapshot compression (`#codelab=<base64url>`) powered by `CompressionStream('deflate-raw')` for instant zero-server workspace sharing.
25
+ - **End-to-End TypeScript & Zod Type Safety**: Written in TypeScript with strict runtime schemas and inferred types (`z.infer<typeof ...>`) for workbench options, guided labs, C++ toolchain options, runtime execution, and git cloning.
16
26
  - **Public GitHub Repository Cloning (`git clone`)**: Clone any public GitHub repository (`git clone https://github.com/owner/repo` or `git clone owner/repo --branch main` in the terminal, or `await lab.cloneRepo('owner/repo')` via the SDK) directly into `/workspace` with zero authentication required (automatic GitHub Trees API + jsDelivr unlimited fallback). Clone progress (`remote: Enumerating objects…`, `Receiving objects: n%…`) streams into the terminal in real time as it downloads.
17
27
  - **Interactive IDE Workbench**: Multi-file Monaco editor, collapsible hierarchical file tree with drag-and-drop, a workspace **folder switcher** (breadcrumb dropdown that scopes the explorer to any subfolder), decoupled editor tabs, Command Palette (`Cmd+Shift+P`), Quick Open (`Cmd+P`), breadcrumbs, and line-by-line solution diff viewer.
18
28
  - **Interactive PTY Terminal**: Inline prompt (`codelab:/workspace$ `), cursor navigation, history (`Up`/`Down`), `Ctrl+R` reverse-i-search, `Tab` auto-completion, `Ctrl+C` interrupt, `Ctrl+L` clear, and 256-color / TrueColor ANSI support.
19
- - **POSIX Shell & 64 Coreutils**: Full pure-JS AST interpreter supporting pipelines (`|`), redirects (`>`, `>>`, `2>&1`, `<<<`, `<<EOF`), control flow (`if`/`for`/`while`/`case`), functions, arithmetic `$((...))`, brace expansion `{1..5}`, and 64 UNIX commands (`git`, `ls`, `cat`, `grep`, `find`, `sed`, `awk`, `jq`, `tar`, `curl`, `hey`, `ab`, `wrk`, `chaos`, `sqlite3`, `redis-cli`, `nc`, `lsof`, `tsc`, etc.).
29
+ - **POSIX Shell & 71 Coreutils**: Full pure-JS AST interpreter supporting pipelines (`|`), redirects (`>`, `>>`, `<`, `2>&1`, `<<<`, `<<EOF`), control flow (`if`/`for`/`while`/`case`), functions, arithmetic `$((...))`, brace expansion `{1..5}`, and 71 UNIX commands (`g++`, `clang++`, `c++`, `python`, `python3`, `pytest`, `pip`, `git`, `ls`, `cat`, `grep`, `find`, `sed`, `awk`, `jq`, `tar`, `curl`, `hey`, `ab`, `wrk`, `chaos`, `sqlite3`, `redis-cli`, `nc`, `lsof`, `tsc`, etc.) plus direct `./a.out` WASI binary execution.
20
30
  - **Dual Runtime Engines (Node.js v22 & Bun v1.1)**:
21
- - **Node.js**: 50 built-in modules (`fs`, `fs/promises`, `http`, `https`, `net`, `stream`, `events`, `crypto`, `zlib`, `vm`, `worker_threads`, `readline`, `module`, `node:test`, `assert`, etc.).
31
+ - **Node.js**: 50 built-in modules (`fs`, `fs/promises`, `http`, `https`, `net`, `stream`, `events`, `crypto`, `zlib`, `vm`, `worker_threads`, `readline`, `module`, `node:test`, `assert`, etc.) with full Node.js built-ins support.
22
32
  - **Bun**: Native `.ts` transpilation, `Bun.serve()`, `Bun.file()`, `Bun.write()`, `Bun.spawn()`, `Bun.password`, `Bun.hash()`, `bun:test`, and VFS-backed `bun:sqlite`.
23
33
  - **Persistent HTTP/TCP Servers & Dual Web Preview**: Start background servers (`node server.js &` or `bun run server.ts &`), query them with `curl http://localhost:3000` or global `fetch()`, and view live responses in the Ports table, an embedded **Web Preview** tab (URL bar, back/forward, device frames), or a popped-out browser tab backed by a virtual-loopback Service Worker (`/__preview/:port/*`). Public URLs (e.g. `https://example.com`) entered in the preview URL bar open in a real browser tab instead of the virtual frame.
24
34
  - **Built-in Preview Server (`serve`) & Toolbar *Run & Preview***: Render a real app in the browser with no bundler — `serve [dir] [--port]`, the toolbar globe button, or `npm run dev` all start a static server that transpiles `.ts` / `.tsx` / `.jsx` to browser-native ESM, resolves extensionless relative imports, and injects a jsDelivr `+esm` **import map** for bare specifiers (`react`, `react-dom/client`, `@angular/core`, …). Vite/`ng`/Astro/Next scripts that need native binaries transparently fall back to it.
@@ -113,6 +123,44 @@ const res = await executeInWorker({
113
123
  console.log(res.ok, res.testResults);
114
124
  ```
115
125
 
126
+ ### 4. Modular Language Extensions (TypeScript & Real C++20 in WebAssembly)
127
+
128
+ JavaScript (`node` and `bun` zero-dependency browser runtime) is enabled out of the box. You can opt into TypeScript (`@innovatorved/code-lab/extensions/typescript`) and/or Real C++20 in WebAssembly (`@innovatorved/code-lab/extensions/cpp`):
129
+
130
+ ```js
131
+ import CodeLab from '@innovatorved/code-lab';
132
+ import { typescriptExtension } from '@innovatorved/code-lab/extensions/typescript';
133
+ import { cppExtension } from '@innovatorved/code-lab/extensions/cpp';
134
+ import { guidedLabExtension } from '@innovatorved/code-lab/extensions/guided-lab';
135
+
136
+ const lab = CodeLab.mount('#editor', {
137
+ id: 'dsa-binary-search',
138
+ title: 'Binary Search (JS / TS / C++20)',
139
+ language: 'cpp'
140
+ })
141
+ .use(typescriptExtension)
142
+ .use((wb) => cppExtension(wb, { std: 'c++20', cacheInIndexedDB: true }))
143
+ .use((wb) =>
144
+ guidedLabExtension(wb, {
145
+ starterFiles: { 'src/solution.js': 'module.exports = { search: () => -1 };\n' },
146
+ tsStarterFiles: { 'src/solution.ts': 'export const search = (nums: number[], target: number): number => -1;\n' },
147
+ cppStarterFiles: {
148
+ 'src/solution.hpp': '#pragma once\n#include <bits/stdc++.h>\nint search(const std::vector<int>& nums, int target) { return -1; }\n',
149
+ 'src/test.cpp': '#include <codelab/test.hpp>\n#include "solution.hpp"\nint main() {\n DESCRIBE("Binary Search", {\n TEST("finds target", {\n ASSERT_EQ(search({-1, 0, 3, 5, 9, 12}, 9), 4);\n });\n });\n return CODELAB_TEST_EXIT_CODE();\n}\n'
150
+ },
151
+ steps: [
152
+ {
153
+ id: 'step-1',
154
+ title: 'Implement O(log N) binary search',
155
+ targetFile: 'src/solution.hpp',
156
+ instructions: 'Return the index of `target` in `nums`, or `-1` if not found.',
157
+ testNames: ['finds target']
158
+ }
159
+ ]
160
+ })
161
+ );
162
+ ```
163
+
116
164
  ---
117
165
 
118
166
  ## Documentation
@@ -122,7 +170,7 @@ Complete documentation is published on the [GitHub Wiki](https://github.com/inno
122
170
  - **[Quick Start](https://github.com/innovatorved/code-lab/wiki/Quick-Start)**: Setup, CDN, and quick examples.
123
171
  - **[Integration Guide](https://github.com/innovatorved/code-lab/wiki/Integration-Guide)**: Embedding in React, Next.js, Vite, and HTML.
124
172
  - **[Workbench Configuration](https://github.com/innovatorved/code-lab/wiki/Workbench-Configuration)**: Complete reference of options, methods, events, and shortcuts.
125
- - **[POSIX Shell & Coreutils](https://github.com/innovatorved/code-lab/wiki/POSIX-Shell-and-Coreutils)**: Pipelines, redirects, background jobs, and 64 UNIX commands.
173
+ - **[POSIX Shell & Coreutils](https://github.com/innovatorved/code-lab/wiki/POSIX-Shell-and-Coreutils)**: Pipelines, redirects, background jobs, and 71 UNIX commands.
126
174
  - **[Runtime APIs (Node & Bun)](https://github.com/innovatorved/code-lab/wiki/Runtime-APIs)**: 50 Node.js built-ins, Bun APIs, `bun:test`, `bun:sqlite`, and npm install.
127
175
  - **[HTTP Servers & Networking](https://github.com/innovatorved/code-lab/wiki/HTTP-Servers-and-Networking)**: Virtual port table, background servers, `curl`, and Port Preview.
128
176
  - **[Headless Runtime](https://github.com/innovatorved/code-lab/wiki/Headless-Runtime)**: Run code and tests programmatically with zero UI.
@@ -146,15 +194,17 @@ bun run tests/test-all-builds.js # 15/15 builds & 226 unit tests
146
194
  bun run tests/test-runtime-advanced.js # Advanced runtime, VFS, HTTP/TCP
147
195
  bun run tests/test-option1-shell-bun-http.js # Shell AST, Bun runtime, curl, ports, npm/pnpm
148
196
  bun run tests/test-frameworks.js # React/Preact/Vue/Angular support + browser preview server
149
- bun run tests/test-coreutils-adversarial.js # Adversarial stress tests on 64 coreutils
197
+ bun run tests/test-coreutils-adversarial.js # Adversarial stress tests on 71 coreutils
150
198
  bun run tests/test-stress-shell.js # Deep pipelines, redirections, large stdout
151
199
  bun run tests/test-workbench-ui.js # Workbench tabs, explorer, shortcuts
200
+ bun run tests/test-cpp-extension.js # Real C++20 WASI runtime, g++, and language extensions
201
+ bun run tests/test-python-extension.js # Python 3.12 WebAssembly runtime, pytest, and language service
152
202
  ```
153
203
 
154
204
  Individual suites also run under Node 20, 22 and 24 — CI exercises all three:
155
205
 
156
206
  ```bash
157
- bun run build && node tests/run-all.js # same 40 suites, Node runtime
207
+ bun run build && node tests/run-all.js # same 43 suites, Node runtime
158
208
  ```
159
209
 
160
210
  Suites load the built bundles from `dist/` (never raw TypeScript from `src/`), so
package/dist/code-lab.css CHANGED
@@ -5322,3 +5322,201 @@ code-lab,
5322
5322
  border-color: rgba(245, 158, 11, 0.5) !important;
5323
5323
  color: var(--cl-amber, #f59e0b) !important;
5324
5324
  }
5325
+
5326
+ /* ── CodeLab v0.3.0 UI Polish & Power Features ── */
5327
+
5328
+ /* ── Split Run Button ── */
5329
+ .codelab-btn-split {
5330
+ display: inline-flex;
5331
+ align-items: stretch;
5332
+ border-radius: var(--cl-radius, 6px);
5333
+ overflow: visible;
5334
+ position: relative;
5335
+ }
5336
+ .codelab-btn-split .codelab-btn-split__main {
5337
+ border-top-right-radius: 0;
5338
+ border-bottom-right-radius: 0;
5339
+ border-right: 1px solid rgba(255, 255, 255, 0.2);
5340
+ }
5341
+ .codelab-btn-split .codelab-btn-split__trigger {
5342
+ border-top-left-radius: 0;
5343
+ border-bottom-left-radius: 0;
5344
+ padding: 0 6px;
5345
+ min-width: 24px;
5346
+ }
5347
+ .codelab-split-menu {
5348
+ position: absolute;
5349
+ top: calc(100% + 4px);
5350
+ right: 0;
5351
+ background: var(--cl-bg-elevated, #252526);
5352
+ border: 1px solid var(--cl-border, #3c3c3c);
5353
+ border-radius: var(--cl-radius, 6px);
5354
+ box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
5355
+ z-index: 1000;
5356
+ min-width: 220px;
5357
+ padding: 4px 0;
5358
+ display: none;
5359
+ }
5360
+ .codelab-split-menu.open {
5361
+ display: block;
5362
+ }
5363
+ .codelab-split-menu__item {
5364
+ display: flex;
5365
+ align-items: center;
5366
+ justify-content: space-between;
5367
+ width: 100%;
5368
+ padding: 6px 12px;
5369
+ background: none;
5370
+ border: none;
5371
+ color: var(--cl-fg, #cccccc);
5372
+ font-size: 12px;
5373
+ cursor: pointer;
5374
+ text-align: left;
5375
+ }
5376
+ .codelab-split-menu__item:hover {
5377
+ background: var(--cl-accent, #007acc);
5378
+ color: #ffffff;
5379
+ }
5380
+
5381
+ /* ── Command Palette Trigger Pill ── */
5382
+ .codelab-cmd-trigger {
5383
+ display: inline-flex;
5384
+ align-items: center;
5385
+ gap: 6px;
5386
+ padding: 3px 10px;
5387
+ border-radius: var(--cl-radius, 6px);
5388
+ background: var(--cl-input-bg, rgba(255, 255, 255, 0.06));
5389
+ border: 1px solid var(--cl-border, #3c3c3c);
5390
+ color: var(--cl-fg-muted, #858585);
5391
+ font-size: 11px;
5392
+ cursor: pointer;
5393
+ transition: all 0.15s ease;
5394
+ }
5395
+ .codelab-cmd-trigger:hover {
5396
+ background: var(--cl-input-bg-focus, rgba(255, 255, 255, 0.12));
5397
+ color: var(--cl-fg, #cccccc);
5398
+ border-color: var(--cl-accent, #007acc);
5399
+ }
5400
+
5401
+ /* ── HUD Telemetry Pill ── */
5402
+ .codelab-hud-pill {
5403
+ display: inline-flex;
5404
+ align-items: center;
5405
+ gap: 8px;
5406
+ padding: 2px 10px;
5407
+ border-radius: 12px;
5408
+ background: var(--cl-hud-bg, rgba(0, 122, 204, 0.15));
5409
+ border: 1px solid var(--cl-hud-border, rgba(0, 122, 204, 0.35));
5410
+ color: var(--cl-hud-fg, #4fc1ff);
5411
+ font-family: var(--cl-font-mono, monospace);
5412
+ font-size: 11px;
5413
+ font-weight: 500;
5414
+ letter-spacing: 0.3px;
5415
+ margin-left: auto;
5416
+ user-select: none;
5417
+ }
5418
+ .codelab-hud-pill__metric {
5419
+ display: inline-flex;
5420
+ align-items: center;
5421
+ gap: 4px;
5422
+ }
5423
+
5424
+ /* ── Stdin / Custom Input Panel ── */
5425
+ .codelab-stdin-panel {
5426
+ display: flex;
5427
+ flex-direction: column;
5428
+ height: 100%;
5429
+ padding: 8px 12px;
5430
+ background: var(--cl-bg-editor, #1e1e1e);
5431
+ box-sizing: border-box;
5432
+ }
5433
+ .codelab-stdin-panel__header {
5434
+ display: flex;
5435
+ align-items: center;
5436
+ justify-content: space-between;
5437
+ margin-bottom: 6px;
5438
+ font-size: 11px;
5439
+ color: var(--cl-fg-muted, #858585);
5440
+ font-weight: 600;
5441
+ text-transform: uppercase;
5442
+ letter-spacing: 0.5px;
5443
+ }
5444
+ .codelab-stdin-panel__textarea {
5445
+ flex: 1;
5446
+ width: 100%;
5447
+ background: var(--cl-input-bg, #252526);
5448
+ border: 1px solid var(--cl-border, #3c3c3c);
5449
+ border-radius: var(--cl-radius, 4px);
5450
+ color: var(--cl-fg, #cccccc);
5451
+ font-family: var(--cl-font-mono, monospace);
5452
+ font-size: 12px;
5453
+ line-height: 1.5;
5454
+ padding: 8px;
5455
+ resize: none;
5456
+ outline: none;
5457
+ box-sizing: border-box;
5458
+ }
5459
+ .codelab-stdin-panel__textarea:focus {
5460
+ border-color: var(--cl-accent, #007acc);
5461
+ }
5462
+
5463
+ /* ── Problems Drawer Tab ── */
5464
+ .codelab-problems-list {
5465
+ display: flex;
5466
+ flex-direction: column;
5467
+ overflow-y: auto;
5468
+ height: 100%;
5469
+ padding: 4px 0;
5470
+ }
5471
+ .codelab-problem-item {
5472
+ display: flex;
5473
+ align-items: center;
5474
+ gap: 8px;
5475
+ padding: 5px 12px;
5476
+ font-size: 12px;
5477
+ font-family: var(--cl-font-mono, monospace);
5478
+ cursor: pointer;
5479
+ border-bottom: 1px solid rgba(255, 255, 255, 0.04);
5480
+ }
5481
+ .codelab-problem-item:hover {
5482
+ background: var(--cl-tree-hover, rgba(255, 255, 255, 0.06));
5483
+ }
5484
+ .codelab-problem-item--error {
5485
+ color: #f14c4c;
5486
+ }
5487
+ .codelab-problem-item--warning {
5488
+ color: #cca700;
5489
+ }
5490
+ .codelab-problem-item--info {
5491
+ color: #3794ff;
5492
+ }
5493
+ .codelab-problem-item__location {
5494
+ color: var(--cl-fg-muted, #858585);
5495
+ font-size: 11px;
5496
+ margin-left: auto;
5497
+ }
5498
+
5499
+ /* ── Monaco Side-by-Side Diff Editor ── */
5500
+ .codelab-diff-container {
5501
+ display: flex;
5502
+ flex-direction: column;
5503
+ width: 100%;
5504
+ height: 100%;
5505
+ background: var(--cl-bg-editor, #1e1e1e);
5506
+ }
5507
+ .codelab-diff-toolbar {
5508
+ display: flex;
5509
+ align-items: center;
5510
+ gap: 8px;
5511
+ padding: 6px 12px;
5512
+ background: var(--cl-bg-panel, #252526);
5513
+ border-bottom: 1px solid var(--cl-border, #3c3c3c);
5514
+ font-size: 12px;
5515
+ }
5516
+ .codelab-diff-host {
5517
+ flex: 1;
5518
+ width: 100%;
5519
+ height: calc(100% - 36px);
5520
+ position: relative;
5521
+ }
5522
+
@@ -1,5 +1,5 @@
1
1
  /**
2
- * TypeScript Definitions for @innovatorved/code-lab v0.1.13
2
+ * TypeScript Definitions for @innovatorved/code-lab v0.3.0
3
3
  */
4
4
 
5
5
  export interface CodeLabStep {
@@ -334,9 +334,11 @@ export interface CodeLabOptions {
334
334
  previewOrigin?: string;
335
335
  /** Initial workbench mode ('guided' | 'sandbox') */
336
336
  mode?: 'guided' | 'sandbox';
337
- /** Initial workspace language ('js' | 'ts') */
338
- language?: 'js' | 'ts';
339
- lang?: 'js' | 'ts';
337
+ /** Initial workspace language ('js' | 'ts' | 'cpp' | 'py') */
338
+ language?: 'js' | 'ts' | 'cpp' | 'py';
339
+ lang?: 'js' | 'ts' | 'cpp' | 'py';
340
+ /** Enabled languages in the language switcher */
341
+ languages?: Array<'js' | 'ts' | 'cpp' | 'py'>;
340
342
  /** Explicit theme override ('dark' | 'light' | 'auto') */
341
343
  theme?: 'dark' | 'light' | 'auto';
342
344
  /** Set to false to disable localStorage persistence and use in-memory state only */
@@ -361,12 +363,32 @@ export interface CodeLabOptions {
361
363
  tsSolutionFiles?: Record<string, string>;
362
364
  /** Explicit TypeScript starter files map for guided mode */
363
365
  tsStarterFiles?: Record<string, string>;
366
+ /** Explicit C++ files map for sandbox mode */
367
+ cppFiles?: Record<string, string>;
368
+ cppSolutionFiles?: Record<string, string>;
369
+ /** Explicit C++ starter files map for guided mode */
370
+ cppStarterFiles?: Record<string, string>;
371
+ /** Explicit Python files map for sandbox mode */
372
+ pyFiles?: Record<string, string>;
373
+ pySolutionFiles?: Record<string, string>;
374
+ /** Explicit Python starter files map for guided mode */
375
+ pyStarterFiles?: Record<string, string>;
376
+ /** Python toolchain configuration */
377
+ python?: {
378
+ preloadPackages?: string[];
379
+ cdnBaseUrl?: string;
380
+ };
381
+ /** Modular extensions or plugins to install on mount */
382
+ extensions?: Array<any>;
383
+ plugins?: Array<any>;
364
384
  /** Ordered guided steps */
365
385
  steps?: CodeLabStep[];
366
386
  /** Guided configuration object */
367
387
  guided?: {
368
388
  starterFiles?: Record<string, string>;
369
389
  tsStarterFiles?: Record<string, string>;
390
+ cppStarterFiles?: Record<string, string>;
391
+ pyStarterFiles?: Record<string, string>;
370
392
  steps?: CodeLabStep[];
371
393
  };
372
394
  /** Initial active step index (0-based) */
@@ -405,7 +427,8 @@ export declare class CodeLabWorkbench {
405
427
  openTabs: string[];
406
428
  activeFile: string | null;
407
429
  mode: 'guided' | 'sandbox';
408
- lang: 'js' | 'ts';
430
+ lang: 'js' | 'ts' | 'cpp' | 'py';
431
+ enabledLanguages: Set<'js' | 'ts' | 'cpp' | 'py'>;
409
432
  activeStepIndex: number;
410
433
  completedSteps: Set<string>;
411
434
  steps: CodeLabStep[];
@@ -437,9 +460,15 @@ export declare class CodeLabWorkbench {
437
460
  deleteFile(filename: string): boolean;
438
461
  deleteFolder(folderPrefix: string): boolean;
439
462
  setMode(newMode: 'guided' | 'sandbox'): void;
440
- setLanguage(newLang: 'js' | 'ts'): void;
463
+ setLanguage(newLang: 'js' | 'ts' | 'cpp' | 'py'): void;
441
464
  switchDrawerTab(tabName: 'tests' | 'terminal' | 'ports' | 'network' | 'inspector'): void;
442
- configure(opts?: { mode?: 'guided' | 'sandbox'; lang?: 'js' | 'ts'; stepIndex?: number }): void;
465
+ configure(opts?: { mode?: 'guided' | 'sandbox'; lang?: 'js' | 'ts' | 'cpp' | 'py'; stepIndex?: number }): void;
466
+ runCode(): Promise<void>;
467
+ runActiveFile(): Promise<void>;
468
+ shareSnapshot(): Promise<void>;
469
+ formatActiveDocument(): Promise<void>;
470
+ toggleWebPreview(): void;
471
+ runSelectedCode(): Promise<void>;
443
472
  openCommandPalette(mode?: 'commands' | 'files'): void;
444
473
  closeCommandPalette(): void;
445
474
  openContextMenu(x: number, y: number, items: Array<{ label?: string; action?: () => void; danger?: boolean; separator?: boolean }>): void;
@@ -618,5 +647,6 @@ export interface CodeLabStatic {
618
647
  };
619
648
  }
620
649
 
650
+ export declare const CodeLabWorkbenchComponents: any;
621
651
  export declare const CodeLab: CodeLabStatic;
622
652
  export default CodeLab;