@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/dist/shell.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.1.13 — Standalone Browser Code IDE & Virtual Runtime
3
+ * @innovatorved/code-lab v0.3.0 — Standalone Browser Code IDE & Virtual Runtime
4
4
  * ============================================================
5
5
  * Features:
6
6
  * - Sandboxed Web Worker Execution Engine with Multi-Instance Isolation & Watchdog Timer
@@ -1802,7 +1802,7 @@ var CodeLabLogger = (() => {
1802
1802
  }
1803
1803
  return Array.from(children).sort();
1804
1804
  },
1805
- readFileSync(p) {
1805
+ readFileSync(p, encoding) {
1806
1806
  const np = norm(p);
1807
1807
  const f = files.get(np);
1808
1808
  if (!f) {
@@ -1810,6 +1810,9 @@ var CodeLabLogger = (() => {
1810
1810
  err.code = 'ENOENT';
1811
1811
  throw err;
1812
1812
  }
1813
+ if (!encoding && f.rawBytes instanceof Uint8Array) {
1814
+ return f.rawBytes;
1815
+ }
1813
1816
  return f.data;
1814
1817
  },
1815
1818
  writeFileSync(p, data) {
@@ -1820,9 +1823,13 @@ var CodeLabLogger = (() => {
1820
1823
  let cur = '';
1821
1824
  for (const pt of parts) { cur += '/' + pt; dirs.add(cur); }
1822
1825
  }
1823
- const str = typeof data === 'string' ? data : (data.toString ? data.toString('utf8') : String(data));
1826
+ const isBinary = data instanceof Uint8Array;
1827
+ const rawBytes = isBinary ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength) : null;
1828
+ const str = isBinary
1829
+ ? new TextDecoder('utf-8').decode(rawBytes)
1830
+ : (typeof data === 'string' ? data : (data && data.toString ? data.toString('utf8') : String(data)));
1824
1831
  const prevMode = files.has(np) ? files.get(np).mode : 0o100644;
1825
- files.set(np, { data: str, mtimeMs: Date.now(), mode: prevMode });
1832
+ files.set(np, { data: str, rawBytes, mtimeMs: Date.now(), mode: prevMode });
1826
1833
  },
1827
1834
  appendFileSync(p, data) {
1828
1835
  const np = norm(p);
@@ -6049,6 +6056,8 @@ var CodeLabLogger = (() => {
6049
6056
  stdout += ' history, ps, jobs, kill Process and job management\n';
6050
6057
  stdout += ' git [status diff log] Built-in version control\n';
6051
6058
  stdout += ' node, bun, npm, pnpm, npx, bunx CLI runtime and package shims\n';
6059
+ stdout += ' g++, clang++, c++ C++20 WebAssembly compiler (via cppExtension)\n';
6060
+ stdout += ' python, python3, pytest Python 3.12 WebAssembly runtime (via pythonExtension)\n';
6052
6061
  stdout += ' serve [dir] [--port] Built-in preview server (transpiles TS/JSX for the browser)\n';
6053
6062
  stdout += ' ports, curl Port table inspection & HTTP requests\n';
6054
6063
  stdout += ' hey, ab, wrk Concurrent HTTP load generator & latency percentiles\n';
@@ -6167,6 +6176,236 @@ var CodeLabLogger = (() => {
6167
6176
  return { code: res.ok ? 0 : (res.exitCode || 1), stdout: res.stdout, stderr: res.stderr };
6168
6177
  },
6169
6178
 
6179
+ async 'g++'(args, ctx) {
6180
+ if (args.includes('--version') || args.includes('-v')) {
6181
+ return {
6182
+ code: 0,
6183
+ stdout: 'clang version 18.1.8 (Target: wasm32-unknown-wasi)\nTarget: wasm32-unknown-wasi\nThread model: posix\nInstalledDir: /usr/bin\n',
6184
+ stderr: ''
6185
+ };
6186
+ }
6187
+ if (args.includes('--help') || args.includes('-h')) {
6188
+ return {
6189
+ code: 0,
6190
+ stdout:
6191
+ 'Usage: g++ [options] file...\n' +
6192
+ 'Options:\n' +
6193
+ ' -std=<standard> Assume that the input sources are for <standard> (c++17, c++20, c++23)\n' +
6194
+ ' -O0, -O1, -O2, -O3 Optimization level\n' +
6195
+ ' -o <file> Write output to <file> (default: a.out)\n' +
6196
+ ' -I <dir> Add directory to include search path\n',
6197
+ stderr: ''
6198
+ };
6199
+ }
6200
+
6201
+ const sourceFiles = [];
6202
+ const extraFlags = [];
6203
+ let outputPath = PosixPath.join(ctx.cwd, 'a.out');
6204
+ let std = 'c++20';
6205
+ let optLevel = '-O2';
6206
+
6207
+ for (let i = 0; i < args.length; i++) {
6208
+ const arg = args[i];
6209
+ if (arg === '-o' && i + 1 < args.length) {
6210
+ outputPath = ctx.resolvePath(args[++i]);
6211
+ } else if (arg.startsWith('-o') && arg.length > 2) {
6212
+ outputPath = ctx.resolvePath(arg.slice(2));
6213
+ } else if (arg.startsWith('-std=')) {
6214
+ const val = arg.slice(5);
6215
+ if (val === 'c++17' || val === 'gnu++17') std = 'c++17';
6216
+ else if (val === 'c++23' || val === 'c++2b' || val === 'gnu++23') std = 'c++23';
6217
+ else std = 'c++20';
6218
+ } else if (arg === '-O0' || arg === '-O1' || arg === '-O2' || arg === '-O3') {
6219
+ optLevel = arg;
6220
+ } else if (arg.startsWith('-I') || arg.startsWith('-D') || arg.startsWith('-W')) {
6221
+ extraFlags.push(arg);
6222
+ } else if (!arg.startsWith('-')) {
6223
+ sourceFiles.push(ctx.resolvePath(arg));
6224
+ }
6225
+ }
6226
+
6227
+ if (sourceFiles.length === 0) {
6228
+ return { code: 1, stdout: '', stderr: 'g++: fatal error: no input files\ncompilation terminated.\n' };
6229
+ }
6230
+
6231
+ for (const src of sourceFiles) {
6232
+ if (!ctx.vfs.existsSync(src)) {
6233
+ return { code: 1, stdout: '', stderr: `g++: error: ${src}: No such file or directory\n` };
6234
+ }
6235
+ }
6236
+
6237
+ const cppCompiler =
6238
+ (ctx.shell && ctx.shell.options && ctx.shell.options.cppCompiler) ||
6239
+ (typeof globalThis !== 'undefined' && globalThis.__codelabCppCompiler) ||
6240
+ (typeof window !== 'undefined' && window.__codelabCppCompiler);
6241
+
6242
+ if (typeof cppCompiler !== 'function') {
6243
+ return {
6244
+ code: 1,
6245
+ stdout: '',
6246
+ stderr:
6247
+ 'g++: C++ toolchain is not enabled. Enable cppExtension from "@innovatorved/code-lab/extensions/cpp" to compile C++ files.\n'
6248
+ };
6249
+ }
6250
+
6251
+ let outText = '';
6252
+ let errText = '';
6253
+ const compileRes = await cppCompiler({
6254
+ entry: sourceFiles[0],
6255
+ sourceFiles,
6256
+ outputPath,
6257
+ std,
6258
+ optLevel,
6259
+ extraFlags,
6260
+ vfs: ctx.vfs,
6261
+ onStdout: (t) => {
6262
+ outText += t;
6263
+ if (ctx.onStdout) ctx.onStdout(t);
6264
+ },
6265
+ onStderr: (t) => {
6266
+ errText += t;
6267
+ if (ctx.onStderr) ctx.onStderr(t);
6268
+ }
6269
+ });
6270
+
6271
+ if (!compileRes || compileRes.exitCode !== 0) {
6272
+ return {
6273
+ code: (compileRes && compileRes.exitCode) || 1,
6274
+ stdout: outText,
6275
+ stderr: errText || 'g++: error: linker command failed with exit code 1\n'
6276
+ };
6277
+ }
6278
+
6279
+ if (compileRes.wasmBinary) {
6280
+ ctx.vfs.writeFileSync(outputPath, compileRes.wasmBinary);
6281
+ if (typeof ctx.vfs.chmodSync === 'function') {
6282
+ try { ctx.vfs.chmodSync(outputPath, 0o755); } catch (err) { _shellLogger.debug('chmodSync failed on compiled binary', err); }
6283
+ }
6284
+ if (typeof ctx.emitMutation === 'function') ctx.emitMutation('create', outputPath);
6285
+ }
6286
+
6287
+ return { code: 0, stdout: outText, stderr: errText };
6288
+ },
6289
+
6290
+ async 'clang++'(args, ctx) {
6291
+ return COREUTILS['g++'](args, ctx);
6292
+ },
6293
+
6294
+ async 'c++'(args, ctx) {
6295
+ return COREUTILS['g++'](args, ctx);
6296
+ },
6297
+
6298
+ async python3(args, ctx) {
6299
+ if (args.length === 0) {
6300
+ return { code: 0, stdout: 'Python 3.12.8 (CPython WebAssembly via Pyodide)\n', stderr: '' };
6301
+ }
6302
+
6303
+ if (args[0] === '--version' || args[0] === '-V') {
6304
+ return { code: 0, stdout: 'Python 3.12.8 (CPython WebAssembly via Pyodide)\n', stderr: '' };
6305
+ }
6306
+
6307
+ let codeToRun = undefined;
6308
+ let entryFile = undefined;
6309
+
6310
+ if (args[0] === '-c' && args.length > 1) {
6311
+ codeToRun = args[1];
6312
+ } else if (!args[0].startsWith('-')) {
6313
+ entryFile = ctx.resolvePath(args[0]);
6314
+ }
6315
+
6316
+ const pyCompiler =
6317
+ (ctx.shell && ctx.shell.options && ctx.shell.options.pythonCompiler) ||
6318
+ (typeof globalThis !== 'undefined' && globalThis.__codelabPythonCompiler) ||
6319
+ (typeof window !== 'undefined' && window.__codelabPythonCompiler);
6320
+
6321
+ if (typeof pyCompiler !== 'function') {
6322
+ return {
6323
+ code: 1,
6324
+ stdout: '',
6325
+ stderr:
6326
+ 'python3: Python WebAssembly toolchain is not enabled. Enable pythonExtension from "@innovatorved/code-lab/extensions/python".\n'
6327
+ };
6328
+ }
6329
+
6330
+ let outText = '';
6331
+ let errText = '';
6332
+ const res = await pyCompiler({
6333
+ entry: entryFile,
6334
+ source: codeToRun,
6335
+ vfs: ctx.vfs,
6336
+ onStdout: (t) => {
6337
+ outText += t;
6338
+ if (ctx.onStdout) ctx.onStdout(t);
6339
+ },
6340
+ onStderr: (t) => {
6341
+ errText += t;
6342
+ if (ctx.onStderr) ctx.onStderr(t);
6343
+ }
6344
+ });
6345
+
6346
+ return {
6347
+ code: res && res.ok ? 0 : ((res && res.exitCode) || 1),
6348
+ stdout: outText,
6349
+ stderr: errText
6350
+ };
6351
+ },
6352
+
6353
+ async python(args, ctx) {
6354
+ return COREUTILS['python3'](args, ctx);
6355
+ },
6356
+
6357
+ async pytest(args, ctx) {
6358
+ if (args.length > 0 && (args[0] === '--version' || args[0] === '-V')) {
6359
+ return { code: 0, stdout: 'pytest 8.3.4 (Python 3.12 WebAssembly)\n', stderr: '' };
6360
+ }
6361
+ const testFiles = args.filter((a) => !a.startsWith('-'));
6362
+ let target = testFiles[0];
6363
+ if (!target && ctx.vfs) {
6364
+ try {
6365
+ const allFiles = Object.keys(typeof ctx.vfs.toSnapshot === 'function' ? ctx.vfs.toSnapshot('/workspace') : (ctx.vfs.files || {}));
6366
+ target = allFiles.find((f) => /(?:^|\/)(?:test_.*|.*_test|test)\.py$/i.test(f));
6367
+ } catch (err) {
6368
+ void err;
6369
+ }
6370
+ }
6371
+ target = target || 'test.py';
6372
+ return COREUTILS['python3']([target], ctx);
6373
+ },
6374
+
6375
+ async pip(args, ctx) {
6376
+ if (args.length === 0 || args[0] === '--version' || args[0] === '-V') {
6377
+ return { code: 0, stdout: 'pip 24.0 from /usr/lib/python/pip (python 3.12)\n', stderr: '' };
6378
+ }
6379
+ if (args[0] === 'install') {
6380
+ const pkgs = args.slice(1).filter((p) => !p.startsWith('-'));
6381
+ const toolchain =
6382
+ (ctx.shell && ctx.shell.options && ctx.shell.options.pythonToolchain) ||
6383
+ (typeof globalThis !== 'undefined' && globalThis.__codelabPythonToolchain) ||
6384
+ (typeof window !== 'undefined' && window.__codelabPythonToolchain);
6385
+ if (toolchain && typeof toolchain.installPackages === 'function') {
6386
+ const res = await toolchain.installPackages(pkgs);
6387
+ if (res.ok) {
6388
+ return {
6389
+ code: 0,
6390
+ stdout: `Successfully installed ${res.installed.join(', ') || 'packages'}\n`,
6391
+ stderr: ''
6392
+ };
6393
+ }
6394
+ return {
6395
+ code: 1,
6396
+ stdout: '',
6397
+ stderr: `ERROR: Could not find a version that satisfies the requirement ${res.error || pkgs.join(', ')}\n`
6398
+ };
6399
+ }
6400
+ return {
6401
+ code: 0,
6402
+ stdout: `Successfully installed ${pkgs.join(', ') || 'packages'}\n`,
6403
+ stderr: ''
6404
+ };
6405
+ }
6406
+ return { code: 0, stdout: 'pip 24.0 (Pyodide micropip)\n', stderr: '' };
6407
+ },
6408
+
6170
6409
  async bun(args, ctx) {
6171
6410
  if (args.length === 0) {
6172
6411
  return { code: 0, stdout: 'Bun v1.1.20\n', stderr: '' };
@@ -7769,6 +8008,10 @@ var CodeLabLogger = (() => {
7769
8008
  return { code: lastCode, exitCode: lastCode, stdout: combinedStdout, stderr: combinedStderr, ok: lastCode === 0 };
7770
8009
  }
7771
8010
 
8011
+ async executeCommand(commandLine, execOptions = {}) {
8012
+ return this.execute(commandLine, execOptions);
8013
+ }
8014
+
7772
8015
  async _executeWithRedirects(redirects, context, execFn) {
7773
8016
  if (!redirects || redirects.length === 0) {
7774
8017
  return execFn(context);
@@ -8449,6 +8692,48 @@ var CodeLabLogger = (() => {
8449
8692
  Object.assign(context.env, this.env);
8450
8693
  context.cwd = this.cwd;
8451
8694
  }
8695
+ } else if (
8696
+ (cmdName.startsWith('./') || cmdName.startsWith('../') || cmdName.startsWith('/')) &&
8697
+ this.vfs.existsSync(this.resolvePath(cmdName))
8698
+ ) {
8699
+ const absBin = this.resolvePath(cmdName);
8700
+ const st = this.vfs.statSync(absBin);
8701
+ if (st && st.isDirectory()) {
8702
+ res = { code: 126, stdout: '', stderr: `shell: ${cmdName}: Is a directory\n` };
8703
+ } else if (hasVirtualRuntime()) {
8704
+ let rawData = null;
8705
+ try { rawData = this.vfs.readFileSync(absBin); } catch (err) { _shellLogger.debug('Failed to read binary', err); }
8706
+ const isWasmMagic =
8707
+ (rawData instanceof Uint8Array &&
8708
+ rawData.length >= 4 &&
8709
+ rawData[0] === 0x00 &&
8710
+ rawData[1] === 0x61 &&
8711
+ rawData[2] === 0x73 &&
8712
+ rawData[3] === 0x6d) ||
8713
+ (typeof rawData === 'string' && rawData.startsWith('\0asm'));
8714
+ const runRes = await executeInVirtualRuntime({
8715
+ mode: 'run',
8716
+ entry: absBin,
8717
+ wasmBinary: isWasmMagic && rawData instanceof Uint8Array ? rawData : undefined,
8718
+ argv: [cmdName, ...args],
8719
+ stdin: effectiveStdin,
8720
+ env: cmdEnv,
8721
+ vfs: this.vfs,
8722
+ activePortTable: this.portTable,
8723
+ pid: cmdCtx.pid,
8724
+ isBackground: cmdCtx.isBackground,
8725
+ onStdout: cmdCtx.onStdout,
8726
+ onStderr: cmdCtx.onStderr,
8727
+ signal: context.signal
8728
+ });
8729
+ res = {
8730
+ code: runRes.ok ? 0 : (runRes.exitCode || 1),
8731
+ stdout: runRes.stdout || '',
8732
+ stderr: runRes.stderr || ''
8733
+ };
8734
+ } else {
8735
+ res = { code: 126, stdout: '', stderr: `shell: ${cmdName}: cannot execute binary file\n` };
8736
+ }
8452
8737
  } else if (DIRECT_DEV_TOOL_RE.test(cmdName)) {
8453
8738
  // A native dev server (vite/ng/astro/…) typed directly. It cannot run in
8454
8739
  // this runtime — whether or not it was installed — so route it to the
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.1.13 — Standalone Browser Code IDE & Virtual Runtime
3
+ * @innovatorved/code-lab v0.3.0 — Standalone Browser Code IDE & Virtual Runtime
4
4
  * ============================================================
5
5
  * Features:
6
6
  * - Sandboxed Web Worker Execution Engine with Multi-Instance Isolation & Watchdog Timer
package/dist/terminal.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.1.13 — Standalone Browser Code IDE & Virtual Runtime
3
+ * @innovatorved/code-lab v0.3.0 — Standalone Browser Code IDE & Virtual Runtime
4
4
  * ============================================================
5
5
  * Features:
6
6
  * - Sandboxed Web Worker Execution Engine with Multi-Instance Isolation & Watchdog Timer
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @innovatorved/code-lab — Fuzzy-Searchable Command Palette (Cmd+Shift+P / Cmd+K)
3
+ */
4
+ export interface CommandPaletteItem {
5
+ id: string;
6
+ label: string;
7
+ shortcut?: string;
8
+ action: () => void;
9
+ }
10
+ export declare function getStandardWorkbenchCommands(workbench: any): CommandPaletteItem[];
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @innovatorved/code-lab — Inline Monaco Side-by-Side Diff Editor & Fallback Unified Diff
3
+ */
4
+ export interface DiffComputeResult {
5
+ hunks: Array<{
6
+ type: 'context' | 'add' | 'del';
7
+ text: string;
8
+ oldLine: number | null;
9
+ newLine: number | null;
10
+ }>;
11
+ added: number;
12
+ removed: number;
13
+ }
14
+ export declare function computeSimpleDiff(oldText: string, newText: string): DiffComputeResult;
15
+ export declare class CodeLabDiffEditorManager {
16
+ private workbench;
17
+ private diffEditor;
18
+ private originalModel;
19
+ private modifiedModel;
20
+ isActive: boolean;
21
+ activeFile: string;
22
+ currentTarget: 'starter' | 'solution';
23
+ constructor(workbench: any);
24
+ openInlineDiff(file: string, target?: 'starter' | 'solution'): boolean;
25
+ closeInlineDiff(): void;
26
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @innovatorved/code-lab — Resizable Bottom Drawer, Contextual Tabs & Telemetry HUD
3
+ */
4
+ export interface DrawerTabOptions {
5
+ workbench: any;
6
+ drawerTab: string;
7
+ hasGuidedLab: boolean;
8
+ mode: string;
9
+ hasWebContent: boolean;
10
+ problemsCount: number;
11
+ testSuiteVisible: boolean;
12
+ lastDurationMs: number | null;
13
+ lastPeakMemoryBytes: number | null;
14
+ }
15
+ export declare function formatTelemetryHud(durationMs: number | null, memoryBytes: number | null, lang: string): string;
16
+ export declare function renderDrawerTabsHtml(opts: DrawerTabOptions): string;
17
+ export declare function renderProblemsPanelHtml(workbench: any): string;
18
+ export declare function renderStdinPanelHtml(workbench: any): string;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @innovatorved/code-lab — Monaco Editor Host, Model Lifecycle & Formatting
3
+ */
4
+ export interface EditorPosition {
5
+ lineNumber: number;
6
+ column: number;
7
+ }
8
+ /**
9
+ * Normalizes C++ source indentation and braces.
10
+ */
11
+ export declare function formatCppSource(code: string): string;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @innovatorved/code-lab — Explorer File Tree & CRUD Utilities
3
+ */
4
+ export interface FileNode {
5
+ name: string;
6
+ fullPath: string;
7
+ isFolder: boolean;
8
+ children: FileNode[];
9
+ }
10
+ export declare function buildFileHierarchy(files: Record<string, string>, creatingItem?: any): FileNode;
11
+ export declare function getFileIcon(filename: string): string;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @innovatorved/code-lab — Guided Pane: Walkthrough Stepper, Hints & Verification
3
+ */
4
+ export interface GuidedStepData {
5
+ id: string;
6
+ title: string;
7
+ instructions: string | string[];
8
+ hint?: string;
9
+ testNames?: string[];
10
+ }
11
+ export declare function renderStepPillsHtml(steps: GuidedStepData[], activeIndex: number, completedStepIds: Set<string>): string;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @innovatorved/code-lab — Workbench SVG Icon Registry
3
+ * Complete set of lightweight, crisp SVG icons for toolbar, file tree, drawer, and modals.
4
+ */
5
+ export declare const CL_ICONS: Record<string, string>;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @innovatorved/code-lab — Workbench Subsystem Entrypoint
3
+ */
4
+ export * from './icons';
5
+ export * from './styles';
6
+ export * from './toolbar';
7
+ export * from './drawer';
8
+ export * from './diff-editor';
9
+ export * from './command-palette';
10
+ export * from './share';
11
+ export * from './file-tree';
12
+ export * from './editor';
13
+ export * from './guided-pane';
14
+ import * as toolbar from './toolbar';
15
+ import * as drawer from './drawer';
16
+ import * as diffEditor from './diff-editor';
17
+ import * as commandPalette from './command-palette';
18
+ import * as share from './share';
19
+ import * as fileTree from './file-tree';
20
+ import * as guidedPane from './guided-pane';
21
+ export declare const CodeLabWorkbenchComponents: {
22
+ renderStepPillsHtml(steps: guidedPane.GuidedStepData[], activeIndex: number, completedStepIds: Set<string>): string;
23
+ formatCppSource(code: string): string;
24
+ buildFileHierarchy(files: Record<string, string>, creatingItem?: any): fileTree.FileNode;
25
+ getFileIcon(filename: string): string;
26
+ compressWorkspaceSnapshot(payload: share.WorkspaceSharePayload): Promise<string>;
27
+ decompressWorkspaceSnapshot(encoded: string): Promise<share.WorkspaceSharePayload | null>;
28
+ getStandardWorkbenchCommands(workbench: any): commandPalette.CommandPaletteItem[];
29
+ computeSimpleDiff(oldText: string, newText: string): diffEditor.DiffComputeResult;
30
+ CodeLabDiffEditorManager: typeof diffEditor.CodeLabDiffEditorManager;
31
+ formatTelemetryHud(durationMs: number | null, memoryBytes: number | null, lang: string): string;
32
+ renderDrawerTabsHtml(opts: drawer.DrawerTabOptions): string;
33
+ renderProblemsPanelHtml(workbench: any): string;
34
+ renderStdinPanelHtml(workbench: any): string;
35
+ renderLanguageSwitcherHtml(workbench: any): string;
36
+ renderToolbarHtml(opts: toolbar.ToolbarRenderOptions): string;
37
+ WORKBENCH_STYLES: "\n/* \u2500\u2500 Split Run Button \u2500\u2500 */\n.codelab-btn-split {\n display: inline-flex;\n align-items: stretch;\n border-radius: var(--cl-radius, 6px);\n overflow: visible;\n position: relative;\n}\n.codelab-btn-split .codelab-btn-split__main {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n border-right: 1px solid rgba(255, 255, 255, 0.2);\n}\n.codelab-btn-split .codelab-btn-split__trigger {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n padding: 0 6px;\n min-width: 24px;\n}\n.codelab-split-menu {\n position: absolute;\n top: calc(100% + 4px);\n right: 0;\n background: var(--cl-bg-elevated, #252526);\n border: 1px solid var(--cl-border, #3c3c3c);\n border-radius: var(--cl-radius, 6px);\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);\n z-index: 1000;\n min-width: 220px;\n padding: 4px 0;\n display: none;\n}\n.codelab-split-menu.open {\n display: block;\n}\n.codelab-split-menu__item {\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n padding: 6px 12px;\n background: none;\n border: none;\n color: var(--cl-fg, #cccccc);\n font-size: 12px;\n cursor: pointer;\n text-align: left;\n}\n.codelab-split-menu__item:hover {\n background: var(--cl-accent, #007acc);\n color: #ffffff;\n}\n\n/* \u2500\u2500 Command Palette Trigger Pill \u2500\u2500 */\n.codelab-cmd-trigger {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 3px 10px;\n border-radius: var(--cl-radius, 6px);\n background: var(--cl-input-bg, rgba(255, 255, 255, 0.06));\n border: 1px solid var(--cl-border, #3c3c3c);\n color: var(--cl-fg-muted, #858585);\n font-size: 11px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n.codelab-cmd-trigger:hover {\n background: var(--cl-input-bg-focus, rgba(255, 255, 255, 0.12));\n color: var(--cl-fg, #cccccc);\n border-color: var(--cl-accent, #007acc);\n}\n\n/* \u2500\u2500 HUD Telemetry Pill \u2500\u2500 */\n.codelab-hud-pill {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n padding: 2px 10px;\n border-radius: 12px;\n background: var(--cl-hud-bg, rgba(0, 122, 204, 0.15));\n border: 1px solid var(--cl-hud-border, rgba(0, 122, 204, 0.35));\n color: var(--cl-hud-fg, #4fc1ff);\n font-family: var(--cl-font-mono, monospace);\n font-size: 11px;\n font-weight: 500;\n letter-spacing: 0.3px;\n margin-left: auto;\n user-select: none;\n}\n.codelab-hud-pill__metric {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n}\n\n/* \u2500\u2500 Stdin / Custom Input Panel \u2500\u2500 */\n.codelab-stdin-panel {\n display: flex;\n flex-direction: column;\n height: 100%;\n padding: 8px 12px;\n background: var(--cl-bg-editor, #1e1e1e);\n box-sizing: border-box;\n}\n.codelab-stdin-panel__header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n margin-bottom: 6px;\n font-size: 11px;\n color: var(--cl-fg-muted, #858585);\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n}\n.codelab-stdin-panel__textarea {\n flex: 1;\n width: 100%;\n background: var(--cl-input-bg, #252526);\n border: 1px solid var(--cl-border, #3c3c3c);\n border-radius: var(--cl-radius, 4px);\n color: var(--cl-fg, #cccccc);\n font-family: var(--cl-font-mono, monospace);\n font-size: 12px;\n line-height: 1.5;\n padding: 8px;\n resize: none;\n outline: none;\n box-sizing: border-box;\n}\n.codelab-stdin-panel__textarea:focus {\n border-color: var(--cl-accent, #007acc);\n}\n\n/* \u2500\u2500 Problems Drawer Tab \u2500\u2500 */\n.codelab-problems-list {\n display: flex;\n flex-direction: column;\n overflow-y: auto;\n height: 100%;\n padding: 4px 0;\n}\n.codelab-problem-item {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 5px 12px;\n font-size: 12px;\n font-family: var(--cl-font-mono, monospace);\n cursor: pointer;\n border-bottom: 1px solid rgba(255, 255, 255, 0.04);\n}\n.codelab-problem-item:hover {\n background: var(--cl-tree-hover, rgba(255, 255, 255, 0.06));\n}\n.codelab-problem-item--error {\n color: #f14c4c;\n}\n.codelab-problem-item--warning {\n color: #cca700;\n}\n.codelab-problem-item--info {\n color: #3794ff;\n}\n.codelab-problem-item__location {\n color: var(--cl-fg-muted, #858585);\n font-size: 11px;\n margin-left: auto;\n}\n\n/* \u2500\u2500 Monaco Side-by-Side Diff Editor \u2500\u2500 */\n.codelab-diff-container {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n background: var(--cl-bg-editor, #1e1e1e);\n}\n.codelab-diff-toolbar {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 6px 12px;\n background: var(--cl-bg-panel, #252526);\n border-bottom: 1px solid var(--cl-border, #3c3c3c);\n font-size: 12px;\n}\n.codelab-diff-host {\n flex: 1;\n width: 100%;\n height: calc(100% - 36px);\n position: relative;\n}\n";
38
+ CL_ICONS: Record<string, string>;
39
+ };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @innovatorved/code-lab — Zero-Backend URL Snapshot Compressor & Decompressor
3
+ *
4
+ * Serializes workspace state { lang, activeFile, files, stdin }, compresses it
5
+ * with browser-native `CompressionStream('deflate-raw')`, and encodes as Base64url
6
+ * in the URL hash `#codelab=<base64url>`.
7
+ */
8
+ export interface WorkspaceSharePayload {
9
+ lang?: string;
10
+ activeFile?: string | null;
11
+ files: Record<string, string>;
12
+ stdin?: string;
13
+ }
14
+ /**
15
+ * Compresses workspace payload into a compact Base64url string.
16
+ */
17
+ export declare function compressWorkspaceSnapshot(payload: WorkspaceSharePayload): Promise<string>;
18
+ /**
19
+ * Decompresses a Base64url string into workspace snapshot payload.
20
+ */
21
+ export declare function decompressWorkspaceSnapshot(encoded: string): Promise<WorkspaceSharePayload | null>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @innovatorved/code-lab — Workbench CSS Tokens, Themes & Styles
3
+ */
4
+ export declare const WORKBENCH_STYLES = "\n/* \u2500\u2500 Split Run Button \u2500\u2500 */\n.codelab-btn-split {\n display: inline-flex;\n align-items: stretch;\n border-radius: var(--cl-radius, 6px);\n overflow: visible;\n position: relative;\n}\n.codelab-btn-split .codelab-btn-split__main {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n border-right: 1px solid rgba(255, 255, 255, 0.2);\n}\n.codelab-btn-split .codelab-btn-split__trigger {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n padding: 0 6px;\n min-width: 24px;\n}\n.codelab-split-menu {\n position: absolute;\n top: calc(100% + 4px);\n right: 0;\n background: var(--cl-bg-elevated, #252526);\n border: 1px solid var(--cl-border, #3c3c3c);\n border-radius: var(--cl-radius, 6px);\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);\n z-index: 1000;\n min-width: 220px;\n padding: 4px 0;\n display: none;\n}\n.codelab-split-menu.open {\n display: block;\n}\n.codelab-split-menu__item {\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n padding: 6px 12px;\n background: none;\n border: none;\n color: var(--cl-fg, #cccccc);\n font-size: 12px;\n cursor: pointer;\n text-align: left;\n}\n.codelab-split-menu__item:hover {\n background: var(--cl-accent, #007acc);\n color: #ffffff;\n}\n\n/* \u2500\u2500 Command Palette Trigger Pill \u2500\u2500 */\n.codelab-cmd-trigger {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 3px 10px;\n border-radius: var(--cl-radius, 6px);\n background: var(--cl-input-bg, rgba(255, 255, 255, 0.06));\n border: 1px solid var(--cl-border, #3c3c3c);\n color: var(--cl-fg-muted, #858585);\n font-size: 11px;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n.codelab-cmd-trigger:hover {\n background: var(--cl-input-bg-focus, rgba(255, 255, 255, 0.12));\n color: var(--cl-fg, #cccccc);\n border-color: var(--cl-accent, #007acc);\n}\n\n/* \u2500\u2500 HUD Telemetry Pill \u2500\u2500 */\n.codelab-hud-pill {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n padding: 2px 10px;\n border-radius: 12px;\n background: var(--cl-hud-bg, rgba(0, 122, 204, 0.15));\n border: 1px solid var(--cl-hud-border, rgba(0, 122, 204, 0.35));\n color: var(--cl-hud-fg, #4fc1ff);\n font-family: var(--cl-font-mono, monospace);\n font-size: 11px;\n font-weight: 500;\n letter-spacing: 0.3px;\n margin-left: auto;\n user-select: none;\n}\n.codelab-hud-pill__metric {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n}\n\n/* \u2500\u2500 Stdin / Custom Input Panel \u2500\u2500 */\n.codelab-stdin-panel {\n display: flex;\n flex-direction: column;\n height: 100%;\n padding: 8px 12px;\n background: var(--cl-bg-editor, #1e1e1e);\n box-sizing: border-box;\n}\n.codelab-stdin-panel__header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n margin-bottom: 6px;\n font-size: 11px;\n color: var(--cl-fg-muted, #858585);\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n}\n.codelab-stdin-panel__textarea {\n flex: 1;\n width: 100%;\n background: var(--cl-input-bg, #252526);\n border: 1px solid var(--cl-border, #3c3c3c);\n border-radius: var(--cl-radius, 4px);\n color: var(--cl-fg, #cccccc);\n font-family: var(--cl-font-mono, monospace);\n font-size: 12px;\n line-height: 1.5;\n padding: 8px;\n resize: none;\n outline: none;\n box-sizing: border-box;\n}\n.codelab-stdin-panel__textarea:focus {\n border-color: var(--cl-accent, #007acc);\n}\n\n/* \u2500\u2500 Problems Drawer Tab \u2500\u2500 */\n.codelab-problems-list {\n display: flex;\n flex-direction: column;\n overflow-y: auto;\n height: 100%;\n padding: 4px 0;\n}\n.codelab-problem-item {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 5px 12px;\n font-size: 12px;\n font-family: var(--cl-font-mono, monospace);\n cursor: pointer;\n border-bottom: 1px solid rgba(255, 255, 255, 0.04);\n}\n.codelab-problem-item:hover {\n background: var(--cl-tree-hover, rgba(255, 255, 255, 0.06));\n}\n.codelab-problem-item--error {\n color: #f14c4c;\n}\n.codelab-problem-item--warning {\n color: #cca700;\n}\n.codelab-problem-item--info {\n color: #3794ff;\n}\n.codelab-problem-item__location {\n color: var(--cl-fg-muted, #858585);\n font-size: 11px;\n margin-left: auto;\n}\n\n/* \u2500\u2500 Monaco Side-by-Side Diff Editor \u2500\u2500 */\n.codelab-diff-container {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n background: var(--cl-bg-editor, #1e1e1e);\n}\n.codelab-diff-toolbar {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 6px 12px;\n background: var(--cl-bg-panel, #252526);\n border-bottom: 1px solid var(--cl-border, #3c3c3c);\n font-size: 12px;\n}\n.codelab-diff-host {\n flex: 1;\n width: 100%;\n height: calc(100% - 36px);\n position: relative;\n}\n";
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @innovatorved/code-lab — Topbar Navigation & Contextual Execution Controls
3
+ */
4
+ export interface ToolbarRenderOptions {
5
+ workbench: any;
6
+ title: string;
7
+ backLabel: string;
8
+ hasGuidedLab: boolean;
9
+ mode: string;
10
+ activeFile: string | null;
11
+ enabledLanguages: Set<string>;
12
+ currentLang: string;
13
+ hasWebContent: boolean;
14
+ activeServerCount: number;
15
+ }
16
+ export declare function renderLanguageSwitcherHtml(workbench: any): string;
17
+ export declare function renderToolbarHtml(opts: ToolbarRenderOptions): string;
@@ -1 +1,6 @@
1
- export {};
1
+ declare const _hostSDK: any;
2
+ export declare const CodeLabWorkbench: any;
3
+ export declare const Workbench: any;
4
+ export declare const CodeLabElement: any;
5
+ export declare const CodeLab: any;
6
+ export default _hostSDK;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@innovatorved/code-lab",
3
- "version": "0.1.13",
4
- "description": "Standalone browser-native IDE Workbench, POSIX Shell & Coreutils, PTY Terminal, and Web Worker Node.js/Bun Virtual Runtime.",
3
+ "version": "0.3.0",
4
+ "description": "Standalone browser-native IDE Workbench, POSIX Shell & Coreutils, PTY Terminal, Web Worker Node.js/Bun Virtual Runtime, Real WebAssembly C++20 (Clang/WASI) Extension, and Python 3.12 (Pyodide WebAssembly) Extension.",
5
5
  "main": "./dist/code-lab.js",
6
6
  "module": "./dist/code-lab.esm.js",
7
7
  "types": "./dist/code-lab.d.ts",
@@ -37,6 +37,30 @@
37
37
  "require": "./dist/extensions/guided-lab.js",
38
38
  "default": "./dist/extensions/guided-lab.js"
39
39
  },
40
+ "./extensions/javascript": {
41
+ "types": "./dist/extensions/javascript.d.ts",
42
+ "import": "./dist/extensions/javascript.esm.js",
43
+ "require": "./dist/extensions/javascript.js",
44
+ "default": "./dist/extensions/javascript.js"
45
+ },
46
+ "./extensions/typescript": {
47
+ "types": "./dist/extensions/typescript.d.ts",
48
+ "import": "./dist/extensions/typescript.esm.js",
49
+ "require": "./dist/extensions/typescript.js",
50
+ "default": "./dist/extensions/typescript.js"
51
+ },
52
+ "./extensions/cpp": {
53
+ "types": "./dist/extensions/cpp.d.ts",
54
+ "import": "./dist/extensions/cpp.esm.js",
55
+ "require": "./dist/extensions/cpp.js",
56
+ "default": "./dist/extensions/cpp.js"
57
+ },
58
+ "./extensions/python": {
59
+ "types": "./dist/extensions/python.d.ts",
60
+ "import": "./dist/extensions/python.esm.js",
61
+ "require": "./dist/extensions/python.js",
62
+ "default": "./dist/extensions/python.js"
63
+ },
40
64
  "./schemas": {
41
65
  "types": "./dist/schemas.d.ts",
42
66
  "import": "./dist/schemas.esm.js",
@@ -58,6 +82,7 @@
58
82
  "src",
59
83
  "README.md",
60
84
  "ARCHITECTURE.md",
85
+ "CHANGELOG.md",
61
86
  "LICENSE"
62
87
  ],
63
88
  "repository": {
@@ -104,7 +129,12 @@
104
129
  "web-component",
105
130
  "system-design",
106
131
  "browser-sandbox",
107
- "guided-labs"
132
+ "guided-labs",
133
+ "cpp",
134
+ "webassembly",
135
+ "wasi",
136
+ "clang",
137
+ "dsa"
108
138
  ],
109
139
  "author": "Ved Gupta",
110
140
  "license": "MIT"