@innovatorved/code-lab 0.2.0 → 0.3.1

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 (66) hide show
  1. package/ARCHITECTURE.md +11 -6
  2. package/CHANGELOG.md +40 -0
  3. package/README.md +18 -8
  4. package/dist/code-lab.css +198 -0
  5. package/dist/code-lab.d.ts +27 -9
  6. package/dist/code-lab.esm.js +8516 -84
  7. package/dist/code-lab.js +8514 -82
  8. package/dist/extensions/cpp.d.ts +40 -6
  9. package/dist/extensions/cpp.esm.js +1027 -7
  10. package/dist/extensions/cpp.js +1027 -7
  11. package/dist/extensions/guided-lab.esm.js +40 -2
  12. package/dist/extensions/guided-lab.js +40 -2
  13. package/dist/extensions/python.d.ts +92 -0
  14. package/dist/extensions/python.esm.js +5476 -0
  15. package/dist/extensions/python.js +5495 -0
  16. package/dist/index.d.ts +7 -4
  17. package/dist/preview-sw.js +1 -1
  18. package/dist/runtime/index.d.ts +4 -0
  19. package/dist/runtime/test-harness.d.ts +24 -0
  20. package/dist/runtime.esm.js +36 -4
  21. package/dist/runtime.js +36 -4
  22. package/dist/schemas.d.ts +137 -24
  23. package/dist/schemas.esm.js +44 -2
  24. package/dist/schemas.js +44 -2
  25. package/dist/shell/coreutils/compilers-cli.d.ts +24 -0
  26. package/dist/shell/index.d.ts +4 -0
  27. package/dist/shell.esm.js +113 -1
  28. package/dist/shell.js +113 -1
  29. package/dist/terminal.esm.js +1 -1
  30. package/dist/terminal.js +1 -1
  31. package/dist/workbench/command-palette.d.ts +10 -0
  32. package/dist/workbench/diff-editor.d.ts +26 -0
  33. package/dist/workbench/drawer.d.ts +18 -0
  34. package/dist/workbench/editor.d.ts +11 -0
  35. package/dist/workbench/file-tree.d.ts +11 -0
  36. package/dist/workbench/guided-pane.d.ts +11 -0
  37. package/dist/workbench/icons.d.ts +5 -0
  38. package/dist/workbench/index.d.ts +39 -0
  39. package/dist/workbench/share.d.ts +21 -0
  40. package/dist/workbench/styles.d.ts +4 -0
  41. package/dist/workbench/toolbar.d.ts +17 -0
  42. package/dist/workbench.d.ts +6 -1
  43. package/package.json +8 -2
  44. package/src/code-lab.css +198 -0
  45. package/src/extensions/cpp.ts +966 -5
  46. package/src/extensions/python.ts +1293 -0
  47. package/src/index.ts +35 -3
  48. package/src/runtime/index.ts +5 -0
  49. package/src/runtime/test-harness.ts +57 -0
  50. package/src/runtime.ts +35 -3
  51. package/src/schemas.ts +47 -2
  52. package/src/shell/coreutils/compilers-cli.ts +103 -0
  53. package/src/shell/index.ts +5 -0
  54. package/src/shell.ts +112 -0
  55. package/src/workbench/command-palette.ts +140 -0
  56. package/src/workbench/diff-editor.ts +216 -0
  57. package/src/workbench/drawer.ts +144 -0
  58. package/src/workbench/editor.ts +49 -0
  59. package/src/workbench/file-tree.ts +51 -0
  60. package/src/workbench/guided-pane.ts +33 -0
  61. package/src/workbench/icons.ts +48 -0
  62. package/src/workbench/index.ts +38 -0
  63. package/src/workbench/share.ts +99 -0
  64. package/src/workbench/styles.ts +200 -0
  65. package/src/workbench/toolbar.ts +171 -0
  66. package/src/workbench.ts +744 -69
package/dist/schemas.js CHANGED
@@ -32,7 +32,10 @@ __export(schemas_exports, {
32
32
  GuidedLabExtensionOptionsSchema: () => GuidedLabExtensionOptionsSchema,
33
33
  GuidedStepSchema: () => GuidedStepSchema,
34
34
  LanguageBundleSchema: () => LanguageBundleSchema,
35
+ LanguageEnum: () => LanguageEnum,
35
36
  LanguageIdSchema: () => LanguageIdSchema,
37
+ PythonExtensionOptionsSchema: () => PythonExtensionOptionsSchema,
38
+ PythonToolchainProgressSchema: () => PythonToolchainProgressSchema,
36
39
  RuntimeExecuteOptionsSchema: () => RuntimeExecuteOptionsSchema,
37
40
  SearchOptionsSchema: () => SearchOptionsSchema,
38
41
  StoredProjectSchema: () => StoredProjectSchema,
@@ -4095,7 +4098,8 @@ var GuidedStepSchema = external_exports.object({
4095
4098
  hint: external_exports.string().optional(),
4096
4099
  testNames: external_exports.array(external_exports.string()).optional()
4097
4100
  });
4098
- var LanguageIdSchema = external_exports.enum(["js", "ts", "cpp"]);
4101
+ var LanguageIdSchema = external_exports.enum(["js", "ts", "cpp", "py"]);
4102
+ var LanguageEnum = LanguageIdSchema;
4099
4103
  var LanguageBundleSchema = external_exports.object({
4100
4104
  language: LanguageIdSchema.default("js"),
4101
4105
  files: external_exports.record(external_exports.string()).default({}),
@@ -4118,12 +4122,18 @@ var GuidedLabExtensionOptionsSchema = external_exports.object({
4118
4122
  cppStarterFiles: external_exports.record(external_exports.string()).optional(),
4119
4123
  cppSolutionFiles: external_exports.record(external_exports.string()).optional(),
4120
4124
  cppFiles: external_exports.record(external_exports.string()).optional(),
4125
+ pyStarterFiles: external_exports.record(external_exports.string()).optional(),
4126
+ pySolutionFiles: external_exports.record(external_exports.string()).optional(),
4127
+ pyFiles: external_exports.record(external_exports.string()).optional(),
4128
+ pyEntry: external_exports.string().optional(),
4129
+ pyTestEntry: external_exports.string().optional(),
4130
+ pyTestCode: external_exports.string().optional(),
4121
4131
  summary: external_exports.string().optional(),
4122
4132
  onStepComplete: external_exports.function().args(GuidedStepSchema, external_exports.number()).returns(external_exports.void()).optional(),
4123
4133
  onLabComplete: external_exports.function().args(external_exports.string()).returns(external_exports.void()).optional()
4124
4134
  });
4125
4135
  var CppToolchainProgressSchema = external_exports.object({
4126
- stage: external_exports.enum(["downloading", "caching", "extracting", "compiling", "linking", "ready"]),
4136
+ stage: external_exports.enum(["downloading", "caching", "extracting", "compiling", "linking", "ready", "error"]),
4127
4137
  loadedBytes: external_exports.number().optional(),
4128
4138
  totalBytes: external_exports.number().optional(),
4129
4139
  percent: external_exports.number().optional(),
@@ -4149,6 +4159,30 @@ var CppExtensionOptionsSchema = external_exports.object({
4149
4159
  solutionFiles: external_exports.record(external_exports.string()).optional(),
4150
4160
  onProgress: external_exports.function().args(external_exports.any()).returns(external_exports.void()).optional()
4151
4161
  });
4162
+ var PythonToolchainProgressSchema = external_exports.object({
4163
+ stage: external_exports.enum(["downloading", "caching", "extracting", "initializing", "ready"]),
4164
+ loadedBytes: external_exports.number().optional(),
4165
+ totalBytes: external_exports.number().optional(),
4166
+ percent: external_exports.number().optional(),
4167
+ message: external_exports.string().optional()
4168
+ });
4169
+ var PythonExtensionOptionsSchema = external_exports.object({
4170
+ cdnBaseUrl: external_exports.string().optional(),
4171
+ indexUrl: external_exports.string().optional(),
4172
+ pyodideIndexUrl: external_exports.string().optional(),
4173
+ cacheInIndexedDB: external_exports.boolean().default(true),
4174
+ preload: external_exports.boolean().default(false),
4175
+ activate: external_exports.boolean().optional(),
4176
+ entry: external_exports.string().default("main.py"),
4177
+ testEntry: external_exports.string().default("test.py"),
4178
+ packages: external_exports.array(external_exports.string()).optional(),
4179
+ preloadPackages: external_exports.array(external_exports.string()).optional(),
4180
+ compilerMemoryLimitMb: external_exports.number().optional(),
4181
+ files: external_exports.record(external_exports.string()).optional(),
4182
+ starterFiles: external_exports.record(external_exports.string()).optional(),
4183
+ solutionFiles: external_exports.record(external_exports.string()).optional(),
4184
+ onProgress: external_exports.function().args(external_exports.any()).returns(external_exports.void()).optional()
4185
+ });
4152
4186
  var CloneProgressPhaseSchema = external_exports.enum([
4153
4187
  "connecting",
4154
4188
  "metadata",
@@ -4244,6 +4278,14 @@ var WorkbenchOptionsSchema = external_exports.object({
4244
4278
  cppFiles: external_exports.record(external_exports.string()).optional(),
4245
4279
  cppStarterFiles: external_exports.record(external_exports.string()).optional(),
4246
4280
  cppSolutionFiles: external_exports.record(external_exports.string()).optional(),
4281
+ pyFiles: external_exports.record(external_exports.string()).optional(),
4282
+ pyStarterFiles: external_exports.record(external_exports.string()).optional(),
4283
+ pySolutionFiles: external_exports.record(external_exports.string()).optional(),
4284
+ pyEntry: external_exports.string().optional().default("main.py"),
4285
+ pyTestEntry: external_exports.string().optional().default("test.py"),
4286
+ pyTestCode: external_exports.string().optional(),
4287
+ showWebPreview: external_exports.boolean().optional(),
4288
+ stdin: external_exports.string().optional(),
4247
4289
  guided: external_exports.any().optional(),
4248
4290
  mode: external_exports.enum(["guided", "sandbox"]).optional(),
4249
4291
  language: LanguageIdSchema.optional(),
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @innovatorved/code-lab — Shell Compiler Coreutils
3
+ * Provides `node`, `tsx`, `tsc`, `g++`, `clang++`, `python`, `python3`, `pytest`, `pip`.
4
+ */
5
+ export interface ShellExecutionContext {
6
+ vfs: any;
7
+ cwd: string;
8
+ env: Record<string, string>;
9
+ resolvePath: (p: string) => string;
10
+ onStdout?: (text: string) => void;
11
+ onStderr?: (text: string) => void;
12
+ shell?: any;
13
+ }
14
+ export interface ShellExecResult {
15
+ code: number;
16
+ stdout: string;
17
+ stderr: string;
18
+ }
19
+ export declare const COMPILER_COREUTILS: {
20
+ python3(args: string[], ctx: ShellExecutionContext): Promise<ShellExecResult>;
21
+ python(args: string[], ctx: ShellExecutionContext): Promise<ShellExecResult>;
22
+ pytest(args: string[], ctx: ShellExecutionContext): Promise<ShellExecResult>;
23
+ pip(args: string[], ctx: ShellExecutionContext): Promise<ShellExecResult>;
24
+ };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @innovatorved/code-lab — Shell Subsystem Entrypoint
3
+ */
4
+ export * from './coreutils/compilers-cli';
package/dist/shell.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.2.0 — Standalone Browser Code IDE & Virtual Runtime
3
+ * @innovatorved/code-lab v0.3.1 — Standalone Browser Code IDE & Virtual Runtime
4
4
  * ============================================================
5
5
  * Features:
6
6
  * - Sandboxed Web Worker Execution Engine with Multi-Instance Isolation & Watchdog Timer
@@ -6056,6 +6056,7 @@ var CodeLabLogger = (() => {
6056
6056
  stdout += ' git [status diff log] Built-in version control\n';
6057
6057
  stdout += ' node, bun, npm, pnpm, npx, bunx CLI runtime and package shims\n';
6058
6058
  stdout += ' g++, clang++, c++ C++20 WebAssembly compiler (via cppExtension)\n';
6059
+ stdout += ' python, python3, pytest Python 3.12 WebAssembly runtime (via pythonExtension)\n';
6059
6060
  stdout += ' serve [dir] [--port] Built-in preview server (transpiles TS/JSX for the browser)\n';
6060
6061
  stdout += ' ports, curl Port table inspection & HTTP requests\n';
6061
6062
  stdout += ' hey, ab, wrk Concurrent HTTP load generator & latency percentiles\n';
@@ -6293,6 +6294,117 @@ var CodeLabLogger = (() => {
6293
6294
  return COREUTILS['g++'](args, ctx);
6294
6295
  },
6295
6296
 
6297
+ async python3(args, ctx) {
6298
+ if (args.length === 0) {
6299
+ return { code: 0, stdout: 'Python 3.12.8 (CPython WebAssembly via Pyodide)\n', stderr: '' };
6300
+ }
6301
+
6302
+ if (args[0] === '--version' || args[0] === '-V') {
6303
+ return { code: 0, stdout: 'Python 3.12.8 (CPython WebAssembly via Pyodide)\n', stderr: '' };
6304
+ }
6305
+
6306
+ let codeToRun = undefined;
6307
+ let entryFile = undefined;
6308
+
6309
+ if (args[0] === '-c' && args.length > 1) {
6310
+ codeToRun = args[1];
6311
+ } else if (!args[0].startsWith('-')) {
6312
+ entryFile = ctx.resolvePath(args[0]);
6313
+ }
6314
+
6315
+ const pyCompiler =
6316
+ (ctx.shell && ctx.shell.options && ctx.shell.options.pythonCompiler) ||
6317
+ (typeof globalThis !== 'undefined' && globalThis.__codelabPythonCompiler) ||
6318
+ (typeof window !== 'undefined' && window.__codelabPythonCompiler);
6319
+
6320
+ if (typeof pyCompiler !== 'function') {
6321
+ return {
6322
+ code: 1,
6323
+ stdout: '',
6324
+ stderr:
6325
+ 'python3: Python WebAssembly toolchain is not enabled. Enable pythonExtension from "@innovatorved/code-lab/extensions/python".\n'
6326
+ };
6327
+ }
6328
+
6329
+ let outText = '';
6330
+ let errText = '';
6331
+ const res = await pyCompiler({
6332
+ entry: entryFile,
6333
+ source: codeToRun,
6334
+ vfs: ctx.vfs,
6335
+ onStdout: (t) => {
6336
+ outText += t;
6337
+ if (ctx.onStdout) ctx.onStdout(t);
6338
+ },
6339
+ onStderr: (t) => {
6340
+ errText += t;
6341
+ if (ctx.onStderr) ctx.onStderr(t);
6342
+ }
6343
+ });
6344
+
6345
+ return {
6346
+ code: res && res.ok ? 0 : ((res && res.exitCode) || 1),
6347
+ stdout: outText,
6348
+ stderr: errText
6349
+ };
6350
+ },
6351
+
6352
+ async python(args, ctx) {
6353
+ return COREUTILS['python3'](args, ctx);
6354
+ },
6355
+
6356
+ async pytest(args, ctx) {
6357
+ if (args.length > 0 && (args[0] === '--version' || args[0] === '-V')) {
6358
+ return { code: 0, stdout: 'pytest 8.3.4 (Python 3.12 WebAssembly)\n', stderr: '' };
6359
+ }
6360
+ const testFiles = args.filter((a) => !a.startsWith('-'));
6361
+ let target = testFiles[0];
6362
+ if (!target && ctx.vfs) {
6363
+ try {
6364
+ const allFiles = Object.keys(typeof ctx.vfs.toSnapshot === 'function' ? ctx.vfs.toSnapshot('/workspace') : (ctx.vfs.files || {}));
6365
+ target = allFiles.find((f) => /(?:^|\/)(?:test_.*|.*_test|test)\.py$/i.test(f));
6366
+ } catch (err) {
6367
+ void err;
6368
+ }
6369
+ }
6370
+ target = target || 'test.py';
6371
+ return COREUTILS['python3']([target], ctx);
6372
+ },
6373
+
6374
+ async pip(args, ctx) {
6375
+ if (args.length === 0 || args[0] === '--version' || args[0] === '-V') {
6376
+ return { code: 0, stdout: 'pip 24.0 from /usr/lib/python/pip (python 3.12)\n', stderr: '' };
6377
+ }
6378
+ if (args[0] === 'install') {
6379
+ const pkgs = args.slice(1).filter((p) => !p.startsWith('-'));
6380
+ const toolchain =
6381
+ (ctx.shell && ctx.shell.options && ctx.shell.options.pythonToolchain) ||
6382
+ (typeof globalThis !== 'undefined' && globalThis.__codelabPythonToolchain) ||
6383
+ (typeof window !== 'undefined' && window.__codelabPythonToolchain);
6384
+ if (toolchain && typeof toolchain.installPackages === 'function') {
6385
+ const res = await toolchain.installPackages(pkgs);
6386
+ if (res.ok) {
6387
+ return {
6388
+ code: 0,
6389
+ stdout: `Successfully installed ${res.installed.join(', ') || 'packages'}\n`,
6390
+ stderr: ''
6391
+ };
6392
+ }
6393
+ return {
6394
+ code: 1,
6395
+ stdout: '',
6396
+ stderr: `ERROR: Could not find a version that satisfies the requirement ${res.error || pkgs.join(', ')}\n`
6397
+ };
6398
+ }
6399
+ return {
6400
+ code: 0,
6401
+ stdout: `Successfully installed ${pkgs.join(', ') || 'packages'}\n`,
6402
+ stderr: ''
6403
+ };
6404
+ }
6405
+ return { code: 0, stdout: 'pip 24.0 (Pyodide micropip)\n', stderr: '' };
6406
+ },
6407
+
6296
6408
  async bun(args, ctx) {
6297
6409
  if (args.length === 0) {
6298
6410
  return { code: 0, stdout: 'Bun v1.1.20\n', stderr: '' };
package/dist/shell.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.2.0 — Standalone Browser Code IDE & Virtual Runtime
3
+ * @innovatorved/code-lab v0.3.1 — Standalone Browser Code IDE & Virtual Runtime
4
4
  * ============================================================
5
5
  * Features:
6
6
  * - Sandboxed Web Worker Execution Engine with Multi-Instance Isolation & Watchdog Timer
@@ -6057,6 +6057,7 @@ var CodeLabLogger = (() => {
6057
6057
  stdout += ' git [status diff log] Built-in version control\n';
6058
6058
  stdout += ' node, bun, npm, pnpm, npx, bunx CLI runtime and package shims\n';
6059
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';
6060
6061
  stdout += ' serve [dir] [--port] Built-in preview server (transpiles TS/JSX for the browser)\n';
6061
6062
  stdout += ' ports, curl Port table inspection & HTTP requests\n';
6062
6063
  stdout += ' hey, ab, wrk Concurrent HTTP load generator & latency percentiles\n';
@@ -6294,6 +6295,117 @@ var CodeLabLogger = (() => {
6294
6295
  return COREUTILS['g++'](args, ctx);
6295
6296
  },
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
+
6297
6409
  async bun(args, ctx) {
6298
6410
  if (args.length === 0) {
6299
6411
  return { code: 0, stdout: 'Bun v1.1.20\n', stderr: '' };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.2.0 — Standalone Browser Code IDE & Virtual Runtime
3
+ * @innovatorved/code-lab v0.3.1 — 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.2.0 — Standalone Browser Code IDE & Virtual Runtime
3
+ * @innovatorved/code-lab v0.3.1 — 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.2.0",
4
- "description": "Standalone browser-native IDE Workbench, POSIX Shell & Coreutils, PTY Terminal, Web Worker Node.js/Bun Virtual Runtime, and Real WebAssembly C++20 (Clang/WASI) Extension.",
3
+ "version": "0.3.1",
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",
@@ -55,6 +55,12 @@
55
55
  "require": "./dist/extensions/cpp.js",
56
56
  "default": "./dist/extensions/cpp.js"
57
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
+ },
58
64
  "./schemas": {
59
65
  "types": "./dist/schemas.d.ts",
60
66
  "import": "./dist/schemas.esm.js",