@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,85 @@
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
+
8
+ export interface TypeScriptExtensionOptions {
9
+ /**
10
+ * Optional TypeScript workspace files (`tsFiles`).
11
+ */
12
+ files?: Record<string, string>;
13
+ /**
14
+ * Optional Guided Lab TypeScript starter files (`tsStarterFiles`).
15
+ */
16
+ starterFiles?: Record<string, string>;
17
+ /**
18
+ * Optional Guided Lab TypeScript reference solution files (`tsSolutionFiles`).
19
+ */
20
+ solutionFiles?: Record<string, string>;
21
+ /**
22
+ * Optional entry file when TypeScript is active (e.g. 'src/demo.ts').
23
+ */
24
+ entry?: string;
25
+ /**
26
+ * Immediately switch the active workbench language to 'ts'.
27
+ */
28
+ activate?: boolean;
29
+ }
30
+
31
+ export function typescriptExtension(workbench: any, options: TypeScriptExtensionOptions = {}) {
32
+ if (!workbench) return workbench;
33
+
34
+ if (!workbench.enabledLanguages || !(workbench.enabledLanguages instanceof Set)) {
35
+ workbench.enabledLanguages = new Set(['js', 'ts']);
36
+ } else {
37
+ workbench.enabledLanguages.add('ts');
38
+ }
39
+
40
+ if (options.files && typeof options.files === 'object') {
41
+ workbench.tsFiles = { ...(workbench.tsFiles || {}), ...options.files };
42
+ if (workbench.guidedConfig) {
43
+ workbench.guidedConfig.tsFiles = { ...(workbench.guidedConfig.tsFiles || {}), ...options.files };
44
+ }
45
+ }
46
+ if (options.starterFiles && typeof options.starterFiles === 'object') {
47
+ if (!workbench.guidedConfig) workbench.guidedConfig = {};
48
+ workbench.guidedConfig.tsStarterFiles = {
49
+ ...(workbench.guidedConfig.tsStarterFiles || {}),
50
+ ...options.starterFiles
51
+ };
52
+ }
53
+ if (options.solutionFiles && typeof options.solutionFiles === 'object') {
54
+ if (!workbench.guidedConfig) workbench.guidedConfig = {};
55
+ workbench.guidedConfig.tsSolutionFiles = {
56
+ ...(workbench.guidedConfig.tsSolutionFiles || {}),
57
+ ...options.solutionFiles
58
+ };
59
+ }
60
+ if (options.entry) {
61
+ workbench.tsEntry = options.entry;
62
+ }
63
+
64
+ workbench.hasMultipleLanguages = workbench.enabledLanguages.size > 1;
65
+
66
+ if (options.activate && typeof workbench.setLanguage === 'function') {
67
+ workbench.setLanguage('ts');
68
+ } else if (typeof workbench._renderShell === 'function' && workbench.container) {
69
+ workbench._renderShell();
70
+ if (typeof workbench._bindEvents === 'function') workbench._bindEvents();
71
+ if (typeof workbench._renderFileLists === 'function') workbench._renderFileLists();
72
+ }
73
+
74
+ return workbench;
75
+ }
76
+
77
+ export function createTypeScriptExtension(options: TypeScriptExtensionOptions = {}) {
78
+ const plugin = (workbench: any) => typescriptExtension(workbench, options);
79
+ plugin.extensionName = 'typescript';
80
+ plugin.languageId = 'ts' as const;
81
+ return plugin;
82
+ }
83
+
84
+ export const tsExtension = typescriptExtension;
85
+ export default typescriptExtension;
package/src/index.ts CHANGED
@@ -1,11 +1,11 @@
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
 
6
6
  export * from './schemas';
7
7
  export * from './logger';
8
- export { SafeHtml, isSafeHtml, raw, html } from './html';
8
+ export { type SafeHtml, isSafeHtml, raw, html } from './html';
9
9
  export * from './csp';
10
10
  export * from './zip';
11
11
  export {
@@ -50,9 +50,68 @@ export {
50
50
  CodeLabShell
51
51
  } from './shell';
52
52
  export * from './terminal';
53
+ export {
54
+ CodeLabWorkbench,
55
+ Workbench,
56
+ CodeLabElement,
57
+ CodeLab
58
+ } from './workbench';
59
+ export * from './workbench/index';
53
60
  export { guidedLabExtension } from './extensions/guided-lab';
61
+ export {
62
+ type JavaScriptExtensionOptions,
63
+ javascriptExtension,
64
+ createJavaScriptExtension
65
+ } from './extensions/javascript';
66
+ export {
67
+ type TypeScriptExtensionOptions,
68
+ typescriptExtension,
69
+ createTypeScriptExtension
70
+ } from './extensions/typescript';
71
+ export {
72
+ type CppCompileOptions,
73
+ type CppCompileResult,
74
+ type CppCompilerAdapter,
75
+ type CppSymbolDoc,
76
+ DEFAULT_CPP_CDN_BASE_URL,
77
+ BUILTIN_CPP_HEADERS,
78
+ STANDARD_CPP20_HEADERS,
79
+ CPP_COMPLETIONS_AND_HOVERS,
80
+ extractTarToVfs,
81
+ createTarArchive,
82
+ seedCppHeadersIntoVfs,
83
+ parseCppCompilerFlags,
84
+ CppToolchainManager,
85
+ registerCppCompilerOnRuntime,
86
+ registerMonacoCppLanguageService,
87
+ analyzeCppSource,
88
+ applyClangStderrDiagnostics,
89
+ cppExtension,
90
+ createCppExtension
91
+ } from './extensions/cpp';
92
+ export {
93
+ type ExtendedPythonExtensionOptions,
94
+ type PythonCompileResult,
95
+ type PythonSymbolDoc,
96
+ DEFAULT_PYTHON_CDN_BASE_URL,
97
+ BUILTIN_PYTHON_MODULES,
98
+ PYTHON_COMPLETIONS_AND_HOVERS,
99
+ PythonToolchainManager,
100
+ seedPythonModulesIntoVfs,
101
+ registerPythonCompilerOnRuntime,
102
+ registerMonacoPythonLanguageService,
103
+ analyzePythonSource,
104
+ applyPythonTracebackDiagnostics,
105
+ formatPythonSource,
106
+ pythonExtension,
107
+ createPythonExtension
108
+ } from './extensions/python';
54
109
 
55
110
  import { guidedLabExtension } from './extensions/guided-lab';
111
+ import { javascriptExtension } from './extensions/javascript';
112
+ import { typescriptExtension } from './extensions/typescript';
113
+ import { cppExtension } from './extensions/cpp';
114
+ import { pythonExtension } from './extensions/python';
56
115
 
57
116
  declare const globalThis: any;
58
117
  const root = typeof window !== 'undefined' ? window : (typeof globalThis !== 'undefined' ? globalThis : {});
@@ -61,6 +120,10 @@ const root = typeof window !== 'undefined' ? window : (typeof globalThis !== 'un
61
120
  if (root.CodeLab) {
62
121
  root.CodeLab.extensions = root.CodeLab.extensions || {};
63
122
  root.CodeLab.extensions.guidedLab = guidedLabExtension;
123
+ root.CodeLab.extensions.javascript = javascriptExtension;
124
+ root.CodeLab.extensions.typescript = typescriptExtension;
125
+ root.CodeLab.extensions.cpp = cppExtension;
126
+ root.CodeLab.extensions.python = pythonExtension;
64
127
  }
65
128
 
66
129
  export default (root.CodeLab || {});
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @innovatorved/code-lab — Runtime Subsystem Entrypoint
3
+ */
4
+
5
+ export * from './test-harness';
@@ -0,0 +1,57 @@
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
+
6
+ export interface TestResultItem {
7
+ index: number;
8
+ name: string;
9
+ status: 'pass' | 'fail';
10
+ passed: boolean;
11
+ durationMs: number;
12
+ error: {
13
+ name?: string;
14
+ message?: string;
15
+ stack?: string;
16
+ actual?: string;
17
+ expected?: string;
18
+ } | null;
19
+ }
20
+
21
+ export class CodeLabTestParser {
22
+ private count = 0;
23
+ private onResult: ((item: TestResultItem) => void) | null;
24
+
25
+ constructor(onResult?: (item: TestResultItem) => void) {
26
+ this.onResult = onResult || null;
27
+ }
28
+
29
+ public parseLine(line: string): TestResultItem | null {
30
+ const trimmed = String(line || '').trim();
31
+ const prefix = '__CODELAB_TEST__:';
32
+ const idx = trimmed.indexOf(prefix);
33
+ if (idx === -1) return null;
34
+
35
+ const payload = trimmed.slice(idx + prefix.length).trim();
36
+ try {
37
+ const data = JSON.parse(payload);
38
+ this.count++;
39
+ const item: TestResultItem = {
40
+ index: typeof data.index === 'number' ? data.index : this.count,
41
+ name: String(data.name || `Test #${this.count}`),
42
+ status: data.passed ? 'pass' : 'fail',
43
+ passed: Boolean(data.passed),
44
+ durationMs: typeof data.durationMs === 'number' ? data.durationMs : 0,
45
+ error: data.error || null
46
+ };
47
+
48
+ if (this.onResult) {
49
+ this.onResult(item);
50
+ }
51
+ return item;
52
+ } catch (err) {
53
+ void err;
54
+ return null;
55
+ }
56
+ }
57
+ }