@innovatorved/code-lab 0.1.4 → 0.1.6

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 CHANGED
@@ -73,7 +73,8 @@ It is designed around two strictly decoupled layers that can be used together (`
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, Process & Archive: `curl`, `nc`, `ping`, `dig`, `nslookup`, `lsof`, `netstat`, `ss`, `ps`, `top`, `kill`, `jobs`, `fg`, `bg`, `tar`, `gzip`, `gunzip`.
76
- - Developer Toolchains: `node`, `bun`, `npm`, `npx`, `tsc`, `git` (`init`, `status`, `add`, `commit`, `log`, `diff`, `branch`, `checkout`).
76
+ - Developer Toolchains: `node`, `bun`, `npm`, `pnpm`, `npx`, `bunx`, `tsc`, `git` (`init`, `status`, `add`, `commit`, `log`, `diff`, `branch`, `checkout`).
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).
77
78
 
78
79
  ---
79
80
 
package/README.md CHANGED
@@ -21,8 +21,9 @@ Browser-native code IDE workbench, modular guided challenge engine (`@innovatorv
21
21
  - **Node.js**: 28 built-in modules (`fs`, `fs/promises`, `http`, `https`, `net`, `stream`, `events`, `crypto`, `zlib`, `vm`, `worker_threads`, `readline`, `node:sqlite`, `node:test`, `assert`).
22
22
  - **Bun**: Native `.ts` transpilation, `Bun.serve()`, `Bun.file()`, `Bun.write()`, `Bun.spawn()`, `Bun.password`, `Bun.hash()`, `bun:test`, and VFS-backed `bun:sqlite`.
23
23
  - **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
+ - **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.
24
25
  - **GitHub-Flavored Markdown Engine**: Zero-dependency GFM renderer (tables with column alignment, `[!NOTE]` / `[!TIP]` / `[!IMPORTANT]` / `[!WARNING]` / `[!CAUTION]` callout alerts, task-list checkboxes, and syntax-highlighted code blocks with one-click copy) powering the Guide tab, hints, and `.md` file previews.
25
- - **NPM & Bun Package Management**: `npm i <pkg>` / `bun add <pkg>` / `bun install` fetch the real package (and its transitive dependencies) from the jsDelivr CDN into virtual `/workspace/node_modules/<pkg>` and update `package.json`; packages stay `require()`-able from `node`/`bun run`, with a bundled offline fallback for common demo packages.
26
+ - **NPM, pnpm & Bun Package Management**: `npm i <pkg>` / `pnpm add <pkg>` / `bun add <pkg>` / `bun install` fetch the real package (and its transitive dependencies, honouring `exports` maps, subpaths and peer deps) from the jsDelivr CDN into virtual `/workspace/node_modules/<pkg>` and update `package.json` (`-D` / `--save-dev` writes to `devDependencies`); packages stay `require()`-able from `node`/`bun run`, with a bundled offline fallback for common demo packages. Framework JSX/TSX (`React.createElement`, custom `@jsx` pragmas) and ESM (including minified bundles) are handled by the runtime transpiler.
26
27
  - **Guided Step-by-Step Challenges**: TutorialKit / Codedamn-style curriculum extension with targeted instructions, hints, automated test verification per step, and reference solutions.
27
28
  - **Headless Runtime**: Programmatic execution engine (`@innovatorved/code-lab/runtime`) for grading, testing, or automated evaluation with zero UI.
28
29
 
@@ -143,7 +144,8 @@ bun run build
143
144
  bun run test:all
144
145
  bun run tests/test-all-builds.js # 15/15 builds & 226 unit tests
145
146
  bun run tests/test-runtime-advanced.js # Advanced runtime, VFS, HTTP/TCP
146
- bun run tests/test-option1-shell-bun-http.js # Shell AST, Bun runtime, curl, ports
147
+ bun run tests/test-option1-shell-bun-http.js # Shell AST, Bun runtime, curl, ports, npm/pnpm
148
+ bun run tests/test-frameworks.js # React/Preact/Vue/Angular support + browser preview server
147
149
  bun run tests/test-coreutils-adversarial.js # Adversarial stress tests on 40+ coreutils
148
150
  bun run tests/test-stress-shell.js # Deep pipelines, redirections, large stdout
149
151
  bun run tests/test-workbench-ui.js # Workbench tabs, explorer, shortcuts
package/dist/code-lab.css CHANGED
@@ -4353,3 +4353,52 @@ code-lab,
4353
4353
  font-size: 11px;
4354
4354
  color: var(--cl-fg-faint);
4355
4355
  }
4356
+
4357
+ .codelab-preview-empty {
4358
+ display: flex;
4359
+ flex-direction: column;
4360
+ align-items: center;
4361
+ gap: 8px;
4362
+ padding: 28px 20px;
4363
+ text-align: center;
4364
+ border-top: 1px solid var(--cl-border);
4365
+ background: var(--cl-bg-subtle, transparent);
4366
+ }
4367
+
4368
+ .codelab-preview-empty__icon {
4369
+ display: inline-flex;
4370
+ align-items: center;
4371
+ justify-content: center;
4372
+ width: 38px;
4373
+ height: 38px;
4374
+ border-radius: 50%;
4375
+ color: var(--cl-accent, #4f9cf9);
4376
+ background: color-mix(in srgb, var(--cl-accent, #4f9cf9) 14%, transparent);
4377
+ }
4378
+
4379
+ .codelab-preview-empty__title {
4380
+ font-size: 13px;
4381
+ font-weight: 600;
4382
+ color: var(--cl-fg);
4383
+ }
4384
+
4385
+ .codelab-preview-empty__text {
4386
+ max-width: 440px;
4387
+ font-size: 12px;
4388
+ line-height: 1.5;
4389
+ color: var(--cl-fg-muted);
4390
+ }
4391
+
4392
+ .codelab-preview-empty__text code,
4393
+ .codelab-preview-empty__hint code {
4394
+ font-family: var(--cl-font-mono);
4395
+ font-size: 11px;
4396
+ padding: 1px 5px;
4397
+ border-radius: 4px;
4398
+ background: color-mix(in srgb, var(--cl-fg, #fff) 8%, transparent);
4399
+ }
4400
+
4401
+ .codelab-preview-empty__hint {
4402
+ font-size: 11px;
4403
+ color: var(--cl-fg-faint);
4404
+ }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * TypeScript Definitions for @innovatorved/code-lab v1.4.0
2
+ * TypeScript Definitions for @innovatorved/code-lab v2.0.0
3
3
  */
4
4
 
5
5
  export interface CodeLabStep {
@@ -276,6 +276,7 @@ export interface CodeLabRuntimeAPI {
276
276
  preloadNpmPackages(files?: Record<string, string>, onProgress?: (pkg: string) => void): Promise<Record<string, string>>;
277
277
  preloadNpmPackages(files: Record<string, string> | undefined, existingCache: Map<string, string>, onProgress?: (pkg: string) => void): Promise<Record<string, string>>;
278
278
  transpileTS(source: string, filename?: string): string;
279
+ transpileForBrowser(source: string, filename?: string): string;
279
280
  createVirtualFs(initialFiles?: Record<string, string>): any;
280
281
  createVirtualHttp(resourceTracker?: any, sharedTrace?: any[], activePortTable?: any): any;
281
282
  createVirtualNet(resourceTracker?: any, sharedTrace?: any[], activePortTable?: any): any;
@@ -288,6 +289,7 @@ export declare const executeInWorker: CodeLabRuntimeAPI['executeInWorker'];
288
289
  export declare const cancelWorkerExecution: CodeLabRuntimeAPI['cancelWorkerExecution'];
289
290
  export declare const preloadNpmPackages: CodeLabRuntimeAPI['preloadNpmPackages'];
290
291
  export declare const transpileTS: CodeLabRuntimeAPI['transpileTS'];
292
+ export declare const transpileForBrowser: CodeLabRuntimeAPI['transpileForBrowser'];
291
293
  export declare const createVirtualFs: CodeLabRuntimeAPI['createVirtualFs'];
292
294
  export declare const createVirtualHttp: CodeLabRuntimeAPI['createVirtualHttp'];
293
295
  export declare const createVirtualNet: CodeLabRuntimeAPI['createVirtualNet'];