@innovatorved/code-lab 0.2.0 → 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.
- package/ARCHITECTURE.md +11 -6
- package/CHANGELOG.md +27 -0
- package/README.md +18 -8
- package/dist/code-lab.css +198 -0
- package/dist/code-lab.d.ts +27 -9
- package/dist/code-lab.esm.js +8248 -83
- package/dist/code-lab.js +8246 -81
- package/dist/extensions/cpp.d.ts +32 -6
- package/dist/extensions/cpp.esm.js +745 -6
- package/dist/extensions/cpp.js +745 -6
- package/dist/extensions/guided-lab.esm.js +39 -1
- package/dist/extensions/guided-lab.js +39 -1
- package/dist/extensions/python.d.ts +92 -0
- package/dist/extensions/python.esm.js +5476 -0
- package/dist/extensions/python.js +5495 -0
- package/dist/index.d.ts +7 -4
- package/dist/preview-sw.js +1 -1
- package/dist/runtime/index.d.ts +4 -0
- package/dist/runtime/module-loader.d.ts +11 -0
- package/dist/runtime/test-harness.d.ts +24 -0
- package/dist/runtime/vfs.d.ts +31 -0
- package/dist/runtime/wasi-host.d.ts +33 -0
- package/dist/runtime.esm.js +36 -4
- package/dist/runtime.js +36 -4
- package/dist/schemas.d.ts +134 -21
- package/dist/schemas.esm.js +43 -1
- package/dist/schemas.js +43 -1
- package/dist/shell/coreutils/compilers-cli.d.ts +24 -0
- package/dist/shell/index.d.ts +4 -0
- package/dist/shell/lexer-parser.d.ts +26 -0
- package/dist/shell.esm.js +113 -1
- package/dist/shell.js +113 -1
- package/dist/terminal.esm.js +1 -1
- package/dist/terminal.js +1 -1
- package/dist/workbench/command-palette.d.ts +10 -0
- package/dist/workbench/diff-editor.d.ts +26 -0
- package/dist/workbench/drawer.d.ts +18 -0
- package/dist/workbench/editor.d.ts +11 -0
- package/dist/workbench/file-tree.d.ts +11 -0
- package/dist/workbench/guided-pane.d.ts +11 -0
- package/dist/workbench/icons.d.ts +5 -0
- package/dist/workbench/index.d.ts +39 -0
- package/dist/workbench/share.d.ts +21 -0
- package/dist/workbench/styles.d.ts +4 -0
- package/dist/workbench/toolbar.d.ts +17 -0
- package/dist/workbench.d.ts +6 -1
- package/package.json +8 -2
- package/src/code-lab.css +198 -0
- package/src/extensions/cpp.ts +710 -5
- package/src/extensions/python.ts +1293 -0
- package/src/index.ts +35 -3
- package/src/runtime/index.ts +5 -0
- package/src/runtime/test-harness.ts +57 -0
- package/src/runtime.ts +35 -3
- package/src/schemas.ts +46 -1
- package/src/shell/coreutils/compilers-cli.ts +103 -0
- package/src/shell/index.ts +5 -0
- package/src/shell.ts +112 -0
- package/src/workbench/command-palette.ts +140 -0
- package/src/workbench/diff-editor.ts +216 -0
- package/src/workbench/drawer.ts +148 -0
- package/src/workbench/editor.ts +49 -0
- package/src/workbench/file-tree.ts +51 -0
- package/src/workbench/guided-pane.ts +33 -0
- package/src/workbench/icons.ts +48 -0
- package/src/workbench/index.ts +38 -0
- package/src/workbench/share.ts +99 -0
- package/src/workbench/styles.ts +200 -0
- package/src/workbench/toolbar.ts +171 -0
- package/src/workbench.ts +755 -70
package/ARCHITECTURE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# `@innovatorved/code-lab` Architecture (v0.
|
|
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 + WASI C++20 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}`).
|
|
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,7 +27,7 @@ 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
|
-
│ •
|
|
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
32
|
│ • Job table (ps, jobs, fg, bg, kill) │ │ • WASI Preview 1 + C++20 Clang │
|
|
33
33
|
└───────────────────────────────────────┘ └──────────────────────────────────┘
|
|
@@ -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
|
-
- **
|
|
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`, `g++`, `clang++`, `c++`, `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
|
|
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
CHANGED
|
@@ -4,6 +4,33 @@ All notable changes to `@innovatorved/code-lab` are documented in this file.
|
|
|
4
4
|
|
|
5
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
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
|
+
|
|
7
34
|
## [0.2.0] - 2026-10-24
|
|
8
35
|
|
|
9
36
|
### Added
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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`), modular language extensions (`javascript`, `typescript`,
|
|
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
8
|
- **Built for**: [System Design In Depth](https://system-design-in-depth.vedgupta.in) & Data Structures & Algorithms (DSA) In Depth
|
|
@@ -11,15 +11,24 @@ Browser-native code IDE workbench, modular guided challenge engine (`@innovatorv
|
|
|
11
11
|
|
|
12
12
|
## Features
|
|
13
13
|
|
|
14
|
-
- **Modular Architecture (`v0.
|
|
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`). 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.
|
|
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.
|
|
16
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.
|
|
17
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.
|
|
18
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.
|
|
19
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.
|
|
20
|
-
- **POSIX Shell &
|
|
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.
|
|
21
30
|
- **Dual Runtime Engines (Node.js v22 & Bun v1.1)**:
|
|
22
|
-
- **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.
|
|
23
32
|
- **Bun**: Native `.ts` transpilation, `Bun.serve()`, `Bun.file()`, `Bun.write()`, `Bun.spawn()`, `Bun.password`, `Bun.hash()`, `bun:test`, and VFS-backed `bun:sqlite`.
|
|
24
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.
|
|
25
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.
|
|
@@ -161,7 +170,7 @@ Complete documentation is published on the [GitHub Wiki](https://github.com/inno
|
|
|
161
170
|
- **[Quick Start](https://github.com/innovatorved/code-lab/wiki/Quick-Start)**: Setup, CDN, and quick examples.
|
|
162
171
|
- **[Integration Guide](https://github.com/innovatorved/code-lab/wiki/Integration-Guide)**: Embedding in React, Next.js, Vite, and HTML.
|
|
163
172
|
- **[Workbench Configuration](https://github.com/innovatorved/code-lab/wiki/Workbench-Configuration)**: Complete reference of options, methods, events, and shortcuts.
|
|
164
|
-
- **[POSIX Shell & Coreutils](https://github.com/innovatorved/code-lab/wiki/POSIX-Shell-and-Coreutils)**: Pipelines, redirects, background jobs, and
|
|
173
|
+
- **[POSIX Shell & Coreutils](https://github.com/innovatorved/code-lab/wiki/POSIX-Shell-and-Coreutils)**: Pipelines, redirects, background jobs, and 71 UNIX commands.
|
|
165
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.
|
|
166
175
|
- **[HTTP Servers & Networking](https://github.com/innovatorved/code-lab/wiki/HTTP-Servers-and-Networking)**: Virtual port table, background servers, `curl`, and Port Preview.
|
|
167
176
|
- **[Headless Runtime](https://github.com/innovatorved/code-lab/wiki/Headless-Runtime)**: Run code and tests programmatically with zero UI.
|
|
@@ -185,16 +194,17 @@ bun run tests/test-all-builds.js # 15/15 builds & 226 unit tests
|
|
|
185
194
|
bun run tests/test-runtime-advanced.js # Advanced runtime, VFS, HTTP/TCP
|
|
186
195
|
bun run tests/test-option1-shell-bun-http.js # Shell AST, Bun runtime, curl, ports, npm/pnpm
|
|
187
196
|
bun run tests/test-frameworks.js # React/Preact/Vue/Angular support + browser preview server
|
|
188
|
-
bun run tests/test-coreutils-adversarial.js # Adversarial stress tests on
|
|
197
|
+
bun run tests/test-coreutils-adversarial.js # Adversarial stress tests on 71 coreutils
|
|
189
198
|
bun run tests/test-stress-shell.js # Deep pipelines, redirections, large stdout
|
|
190
199
|
bun run tests/test-workbench-ui.js # Workbench tabs, explorer, shortcuts
|
|
191
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
|
|
192
202
|
```
|
|
193
203
|
|
|
194
204
|
Individual suites also run under Node 20, 22 and 24 — CI exercises all three:
|
|
195
205
|
|
|
196
206
|
```bash
|
|
197
|
-
bun run build && node tests/run-all.js # same
|
|
207
|
+
bun run build && node tests/run-all.js # same 43 suites, Node runtime
|
|
198
208
|
```
|
|
199
209
|
|
|
200
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
|
+
|
package/dist/code-lab.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TypeScript Definitions for @innovatorved/code-lab v0.
|
|
2
|
+
* TypeScript Definitions for @innovatorved/code-lab v0.3.0
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
export interface CodeLabStep {
|
|
@@ -334,11 +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' | 'cpp') */
|
|
338
|
-
language?: 'js' | 'ts' | 'cpp';
|
|
339
|
-
lang?: 'js' | 'ts' | 'cpp';
|
|
337
|
+
/** Initial workspace language ('js' | 'ts' | 'cpp' | 'py') */
|
|
338
|
+
language?: 'js' | 'ts' | 'cpp' | 'py';
|
|
339
|
+
lang?: 'js' | 'ts' | 'cpp' | 'py';
|
|
340
340
|
/** Enabled languages in the language switcher */
|
|
341
|
-
languages?: Array<'js' | 'ts' | 'cpp'>;
|
|
341
|
+
languages?: Array<'js' | 'ts' | 'cpp' | 'py'>;
|
|
342
342
|
/** Explicit theme override ('dark' | 'light' | 'auto') */
|
|
343
343
|
theme?: 'dark' | 'light' | 'auto';
|
|
344
344
|
/** Set to false to disable localStorage persistence and use in-memory state only */
|
|
@@ -368,6 +368,16 @@ export interface CodeLabOptions {
|
|
|
368
368
|
cppSolutionFiles?: Record<string, string>;
|
|
369
369
|
/** Explicit C++ starter files map for guided mode */
|
|
370
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
|
+
};
|
|
371
381
|
/** Modular extensions or plugins to install on mount */
|
|
372
382
|
extensions?: Array<any>;
|
|
373
383
|
plugins?: Array<any>;
|
|
@@ -378,6 +388,7 @@ export interface CodeLabOptions {
|
|
|
378
388
|
starterFiles?: Record<string, string>;
|
|
379
389
|
tsStarterFiles?: Record<string, string>;
|
|
380
390
|
cppStarterFiles?: Record<string, string>;
|
|
391
|
+
pyStarterFiles?: Record<string, string>;
|
|
381
392
|
steps?: CodeLabStep[];
|
|
382
393
|
};
|
|
383
394
|
/** Initial active step index (0-based) */
|
|
@@ -416,8 +427,8 @@ export declare class CodeLabWorkbench {
|
|
|
416
427
|
openTabs: string[];
|
|
417
428
|
activeFile: string | null;
|
|
418
429
|
mode: 'guided' | 'sandbox';
|
|
419
|
-
lang: 'js' | 'ts' | 'cpp';
|
|
420
|
-
enabledLanguages: Set<'js' | 'ts' | 'cpp'>;
|
|
430
|
+
lang: 'js' | 'ts' | 'cpp' | 'py';
|
|
431
|
+
enabledLanguages: Set<'js' | 'ts' | 'cpp' | 'py'>;
|
|
421
432
|
activeStepIndex: number;
|
|
422
433
|
completedSteps: Set<string>;
|
|
423
434
|
steps: CodeLabStep[];
|
|
@@ -449,9 +460,15 @@ export declare class CodeLabWorkbench {
|
|
|
449
460
|
deleteFile(filename: string): boolean;
|
|
450
461
|
deleteFolder(folderPrefix: string): boolean;
|
|
451
462
|
setMode(newMode: 'guided' | 'sandbox'): void;
|
|
452
|
-
setLanguage(newLang: 'js' | 'ts' | 'cpp'): void;
|
|
463
|
+
setLanguage(newLang: 'js' | 'ts' | 'cpp' | 'py'): void;
|
|
453
464
|
switchDrawerTab(tabName: 'tests' | 'terminal' | 'ports' | 'network' | 'inspector'): void;
|
|
454
|
-
configure(opts?: { mode?: 'guided' | 'sandbox'; lang?: 'js' | 'ts' | 'cpp'; 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>;
|
|
455
472
|
openCommandPalette(mode?: 'commands' | 'files'): void;
|
|
456
473
|
closeCommandPalette(): void;
|
|
457
474
|
openContextMenu(x: number, y: number, items: Array<{ label?: string; action?: () => void; danger?: boolean; separator?: boolean }>): void;
|
|
@@ -630,5 +647,6 @@ export interface CodeLabStatic {
|
|
|
630
647
|
};
|
|
631
648
|
}
|
|
632
649
|
|
|
650
|
+
export declare const CodeLabWorkbenchComponents: any;
|
|
633
651
|
export declare const CodeLab: CodeLabStatic;
|
|
634
652
|
export default CodeLab;
|