@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
@@ -0,0 +1,36 @@
1
+ /**
2
+ * TypeScript Language Extension for CodeLab
3
+ *
4
+ * Zero-dependency browser TypeScript extension powered by CodeLab's built-in
5
+ * `transpileTS` compiler and virtual Node.js / Bun runtime.
6
+ */
7
+ export interface TypeScriptExtensionOptions {
8
+ /**
9
+ * Optional TypeScript workspace files (`tsFiles`).
10
+ */
11
+ files?: Record<string, string>;
12
+ /**
13
+ * Optional Guided Lab TypeScript starter files (`tsStarterFiles`).
14
+ */
15
+ starterFiles?: Record<string, string>;
16
+ /**
17
+ * Optional Guided Lab TypeScript reference solution files (`tsSolutionFiles`).
18
+ */
19
+ solutionFiles?: Record<string, string>;
20
+ /**
21
+ * Optional entry file when TypeScript is active (e.g. 'src/demo.ts').
22
+ */
23
+ entry?: string;
24
+ /**
25
+ * Immediately switch the active workbench language to 'ts'.
26
+ */
27
+ activate?: boolean;
28
+ }
29
+ export declare function typescriptExtension(workbench: any, options?: TypeScriptExtensionOptions): any;
30
+ export declare function createTypeScriptExtension(options?: TypeScriptExtensionOptions): {
31
+ (workbench: any): any;
32
+ extensionName: string;
33
+ languageId: "ts";
34
+ };
35
+ export declare const tsExtension: typeof typescriptExtension;
36
+ export default typescriptExtension;
@@ -0,0 +1,55 @@
1
+ // src/extensions/typescript.ts
2
+ function typescriptExtension(workbench, options = {}) {
3
+ if (!workbench) return workbench;
4
+ if (!workbench.enabledLanguages || !(workbench.enabledLanguages instanceof Set)) {
5
+ workbench.enabledLanguages = /* @__PURE__ */ new Set(["js", "ts"]);
6
+ } else {
7
+ workbench.enabledLanguages.add("ts");
8
+ }
9
+ if (options.files && typeof options.files === "object") {
10
+ workbench.tsFiles = { ...workbench.tsFiles || {}, ...options.files };
11
+ if (workbench.guidedConfig) {
12
+ workbench.guidedConfig.tsFiles = { ...workbench.guidedConfig.tsFiles || {}, ...options.files };
13
+ }
14
+ }
15
+ if (options.starterFiles && typeof options.starterFiles === "object") {
16
+ if (!workbench.guidedConfig) workbench.guidedConfig = {};
17
+ workbench.guidedConfig.tsStarterFiles = {
18
+ ...workbench.guidedConfig.tsStarterFiles || {},
19
+ ...options.starterFiles
20
+ };
21
+ }
22
+ if (options.solutionFiles && typeof options.solutionFiles === "object") {
23
+ if (!workbench.guidedConfig) workbench.guidedConfig = {};
24
+ workbench.guidedConfig.tsSolutionFiles = {
25
+ ...workbench.guidedConfig.tsSolutionFiles || {},
26
+ ...options.solutionFiles
27
+ };
28
+ }
29
+ if (options.entry) {
30
+ workbench.tsEntry = options.entry;
31
+ }
32
+ workbench.hasMultipleLanguages = workbench.enabledLanguages.size > 1;
33
+ if (options.activate && typeof workbench.setLanguage === "function") {
34
+ workbench.setLanguage("ts");
35
+ } else if (typeof workbench._renderShell === "function" && workbench.container) {
36
+ workbench._renderShell();
37
+ if (typeof workbench._bindEvents === "function") workbench._bindEvents();
38
+ if (typeof workbench._renderFileLists === "function") workbench._renderFileLists();
39
+ }
40
+ return workbench;
41
+ }
42
+ function createTypeScriptExtension(options = {}) {
43
+ const plugin = (workbench) => typescriptExtension(workbench, options);
44
+ plugin.extensionName = "typescript";
45
+ plugin.languageId = "ts";
46
+ return plugin;
47
+ }
48
+ var tsExtension = typescriptExtension;
49
+ var typescript_default = typescriptExtension;
50
+ export {
51
+ createTypeScriptExtension,
52
+ typescript_default as default,
53
+ tsExtension,
54
+ typescriptExtension
55
+ };
@@ -0,0 +1,78 @@
1
+ var CodeLabTypeScript = (() => {
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/extensions/typescript.ts
21
+ var typescript_exports = {};
22
+ __export(typescript_exports, {
23
+ createTypeScriptExtension: () => createTypeScriptExtension,
24
+ default: () => typescript_default,
25
+ tsExtension: () => tsExtension,
26
+ typescriptExtension: () => typescriptExtension
27
+ });
28
+ function typescriptExtension(workbench, options = {}) {
29
+ if (!workbench) return workbench;
30
+ if (!workbench.enabledLanguages || !(workbench.enabledLanguages instanceof Set)) {
31
+ workbench.enabledLanguages = /* @__PURE__ */ new Set(["js", "ts"]);
32
+ } else {
33
+ workbench.enabledLanguages.add("ts");
34
+ }
35
+ if (options.files && typeof options.files === "object") {
36
+ workbench.tsFiles = { ...workbench.tsFiles || {}, ...options.files };
37
+ if (workbench.guidedConfig) {
38
+ workbench.guidedConfig.tsFiles = { ...workbench.guidedConfig.tsFiles || {}, ...options.files };
39
+ }
40
+ }
41
+ if (options.starterFiles && typeof options.starterFiles === "object") {
42
+ if (!workbench.guidedConfig) workbench.guidedConfig = {};
43
+ workbench.guidedConfig.tsStarterFiles = {
44
+ ...workbench.guidedConfig.tsStarterFiles || {},
45
+ ...options.starterFiles
46
+ };
47
+ }
48
+ if (options.solutionFiles && typeof options.solutionFiles === "object") {
49
+ if (!workbench.guidedConfig) workbench.guidedConfig = {};
50
+ workbench.guidedConfig.tsSolutionFiles = {
51
+ ...workbench.guidedConfig.tsSolutionFiles || {},
52
+ ...options.solutionFiles
53
+ };
54
+ }
55
+ if (options.entry) {
56
+ workbench.tsEntry = options.entry;
57
+ }
58
+ workbench.hasMultipleLanguages = workbench.enabledLanguages.size > 1;
59
+ if (options.activate && typeof workbench.setLanguage === "function") {
60
+ workbench.setLanguage("ts");
61
+ } else if (typeof workbench._renderShell === "function" && workbench.container) {
62
+ workbench._renderShell();
63
+ if (typeof workbench._bindEvents === "function") workbench._bindEvents();
64
+ if (typeof workbench._renderFileLists === "function") workbench._renderFileLists();
65
+ }
66
+ return workbench;
67
+ }
68
+ function createTypeScriptExtension(options = {}) {
69
+ const plugin = (workbench) => typescriptExtension(workbench, options);
70
+ plugin.extensionName = "typescript";
71
+ plugin.languageId = "ts";
72
+ return plugin;
73
+ }
74
+ var tsExtension = typescriptExtension;
75
+ var typescript_default = typescriptExtension;
76
+ return __toCommonJS(typescript_exports);
77
+ })();
78
+ if(typeof module!=="undefined"&&module.exports)module.exports=CodeLabTypeScript;if(typeof globalThis!=="undefined")globalThis.CodeLabTypeScript=CodeLabTypeScript;
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
- * @innovatorved/code-lab v0.1.10
3
- * Browser-native IDE, POSIX Shell, Web Worker Node.js/Bun Runtime, and Git Engine.
2
+ * @innovatorved/code-lab v0.3.0
3
+ * Browser-native IDE, POSIX Shell, Web Worker Node.js/Bun Runtime, WASI C++20 Toolchain, Python 3.12 WebAssembly, and Git Engine.
4
4
  */
5
5
  export * from './schemas';
6
6
  export * from './logger';
7
- export { SafeHtml, isSafeHtml, raw, html } from './html';
7
+ export { type SafeHtml, isSafeHtml, raw, html } from './html';
8
8
  export * from './csp';
9
9
  export * from './zip';
10
10
  export { type StorageBackendType, type ProjectSummary, type WorkspaceStorageOptions, WorkspaceStorage, createWorkspaceStorage } from './storage';
@@ -14,6 +14,12 @@ export { type GitCommitRecord, type GitState, type GitStatusResult, computeShort
14
14
  export * from './runtime';
15
15
  export { createPosixShell, cloneGitHubRepository, parseGitHubRepoUrl, CodeLabShell } from './shell';
16
16
  export * from './terminal';
17
+ export { CodeLabWorkbench, Workbench, CodeLabElement, CodeLab } from './workbench';
18
+ export * from './workbench/index';
17
19
  export { guidedLabExtension } from './extensions/guided-lab';
20
+ export { type JavaScriptExtensionOptions, javascriptExtension, createJavaScriptExtension } from './extensions/javascript';
21
+ export { type TypeScriptExtensionOptions, typescriptExtension, createTypeScriptExtension } from './extensions/typescript';
22
+ export { type CppCompileOptions, type CppCompileResult, type CppCompilerAdapter, type CppSymbolDoc, DEFAULT_CPP_CDN_BASE_URL, BUILTIN_CPP_HEADERS, STANDARD_CPP20_HEADERS, CPP_COMPLETIONS_AND_HOVERS, extractTarToVfs, createTarArchive, seedCppHeadersIntoVfs, parseCppCompilerFlags, CppToolchainManager, registerCppCompilerOnRuntime, registerMonacoCppLanguageService, analyzeCppSource, applyClangStderrDiagnostics, cppExtension, createCppExtension } from './extensions/cpp';
23
+ export { type ExtendedPythonExtensionOptions, type PythonCompileResult, type PythonSymbolDoc, DEFAULT_PYTHON_CDN_BASE_URL, BUILTIN_PYTHON_MODULES, PYTHON_COMPLETIONS_AND_HOVERS, PythonToolchainManager, seedPythonModulesIntoVfs, registerPythonCompilerOnRuntime, registerMonacoPythonLanguageService, analyzePythonSource, applyPythonTracebackDiagnostics, formatPythonSource, pythonExtension, createPythonExtension } from './extensions/python';
18
24
  declare const _default: any;
19
25
  export default _default;
@@ -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,4 @@
1
+ /**
2
+ * @innovatorved/code-lab — Runtime Subsystem Entrypoint
3
+ */
4
+ export * from './test-harness';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @innovatorved/code-lab — Module Loader, ESM Transformer & TypeScript Stripper
3
+ */
4
+ /**
5
+ * Fast TypeScript type-stripper for browser-native execution without external transpile overhead.
6
+ */
7
+ export declare function stripTypeScriptTypes(source: string): string;
8
+ /**
9
+ * Transforms ESM import/export statements into CommonJS require/exports.
10
+ */
11
+ export declare function transformEsmToCommonJs(source: string): string;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @innovatorved/code-lab — Structured Test Harness & __CODELAB_TEST__: Telemetry Parser
3
+ * Normalizes test events from node:test, <codelab/test.hpp>, and codelab_test.py.
4
+ */
5
+ export interface TestResultItem {
6
+ index: number;
7
+ name: string;
8
+ status: 'pass' | 'fail';
9
+ passed: boolean;
10
+ durationMs: number;
11
+ error: {
12
+ name?: string;
13
+ message?: string;
14
+ stack?: string;
15
+ actual?: string;
16
+ expected?: string;
17
+ } | null;
18
+ }
19
+ export declare class CodeLabTestParser {
20
+ private count;
21
+ private onResult;
22
+ constructor(onResult?: (item: TestResultItem) => void);
23
+ parseLine(line: string): TestResultItem | null;
24
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @innovatorved/code-lab — In-Memory POSIX Virtual File System (VFS) Types & Utilities
3
+ */
4
+ export interface VfsStat {
5
+ dev: number;
6
+ ino: number;
7
+ mode: number;
8
+ nlink: number;
9
+ uid: number;
10
+ gid: number;
11
+ rdev: number;
12
+ size: number;
13
+ blksize: number;
14
+ blocks: number;
15
+ atimeMs: number;
16
+ mtimeMs: number;
17
+ ctimeMs: number;
18
+ birthtimeMs: number;
19
+ isDirectory(): boolean;
20
+ isFile(): boolean;
21
+ isSymbolicLink(): boolean;
22
+ }
23
+ export interface VfsSnapshotItem {
24
+ path: string;
25
+ size: number;
26
+ isDirectory: boolean;
27
+ mtimeMs: number;
28
+ preview?: string;
29
+ hexPreview?: string;
30
+ }
31
+ export declare function normalizeVfsPath(p: string, cwd?: string): string;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @innovatorved/code-lab — WASI Preview 1 Host, Linear Memory Inspection & Execution Harness
3
+ */
4
+ export declare class WasiExitSignal extends Error {
5
+ code: number;
6
+ _isWasiExit: boolean;
7
+ constructor(code?: number);
8
+ }
9
+ export interface WasiExecutionOptions {
10
+ args?: string[];
11
+ argv?: string[];
12
+ env?: Record<string, string>;
13
+ preopens?: Record<string, string>;
14
+ vfs?: any;
15
+ files?: Record<string, string>;
16
+ stdin?: string;
17
+ imports?: Record<string, any>;
18
+ onStdout?: (text: string) => void;
19
+ onStderr?: (text: string) => void;
20
+ }
21
+ export interface WasiExecutionResult {
22
+ ok: boolean;
23
+ exitCode: number;
24
+ durationMs: number;
25
+ stdout: string;
26
+ stderr: string;
27
+ vfs: any;
28
+ peakMemoryBytes: number;
29
+ }
30
+ /**
31
+ * Calculates peak memory from a WebAssembly instance's exported linear memory.
32
+ */
33
+ export declare function getWasiPeakMemoryBytes(instance: any): number;
package/dist/runtime.d.ts CHANGED
@@ -21,6 +21,12 @@ export declare const transpileTS: (code: string, filename?: string) => string;
21
21
  export declare const transpileForBrowser: (source: string, filename?: string) => string;
22
22
  export declare const preloadNpmPackages: (files?: Record<string, any>, onProgressOrCache?: ((pkg: string) => void) | Map<string, string>, onProgress?: (pkg: string) => void) => Promise<Record<string, string>>;
23
23
  export declare const createVirtualPortTable: () => any;
24
+ export declare const createVirtualWasi: (options?: any) => any;
25
+ export declare const executeWasiModule: (wasmBytesOrModule: Uint8Array | ArrayBuffer | WebAssembly.Module, options?: any) => Promise<{
26
+ exitCode: number;
27
+ stdout: string;
28
+ stderr: string;
29
+ }>;
24
30
  export declare const executeInVirtualRuntime: (options?: any) => Promise<any>;
25
31
  declare const createWorkerRuntimeSourceExport: () => string;
26
32
  export { createWorkerRuntimeSourceExport as createWorkerRuntimeSource };