@innovatorved/code-lab 0.3.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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.3.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
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.3.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/runtime.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.3.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/schemas.d.ts CHANGED
@@ -232,20 +232,20 @@ export declare const GuidedLabExtensionOptionsSchema: z.ZodObject<{
232
232
  }>;
233
233
  export type GuidedLabExtensionOptions = z.infer<typeof GuidedLabExtensionOptionsSchema>;
234
234
  export declare const CppToolchainProgressSchema: z.ZodObject<{
235
- stage: z.ZodEnum<["downloading", "caching", "extracting", "compiling", "linking", "ready"]>;
235
+ stage: z.ZodEnum<["downloading", "caching", "extracting", "compiling", "linking", "ready", "error"]>;
236
236
  loadedBytes: z.ZodOptional<z.ZodNumber>;
237
237
  totalBytes: z.ZodOptional<z.ZodNumber>;
238
238
  percent: z.ZodOptional<z.ZodNumber>;
239
239
  message: z.ZodOptional<z.ZodString>;
240
240
  }, "strip", z.ZodTypeAny, {
241
241
  message?: string;
242
- stage?: "downloading" | "caching" | "extracting" | "compiling" | "linking" | "ready";
242
+ stage?: "error" | "downloading" | "caching" | "extracting" | "compiling" | "linking" | "ready";
243
243
  loadedBytes?: number;
244
244
  totalBytes?: number;
245
245
  percent?: number;
246
246
  }, {
247
247
  message?: string;
248
- stage?: "downloading" | "caching" | "extracting" | "compiling" | "linking" | "ready";
248
+ stage?: "error" | "downloading" | "caching" | "extracting" | "compiling" | "linking" | "ready";
249
249
  loadedBytes?: number;
250
250
  totalBytes?: number;
251
251
  percent?: number;
@@ -4093,7 +4093,7 @@ var GuidedLabExtensionOptionsSchema = external_exports.object({
4093
4093
  onLabComplete: external_exports.function().args(external_exports.string()).returns(external_exports.void()).optional()
4094
4094
  });
4095
4095
  var CppToolchainProgressSchema = external_exports.object({
4096
- stage: external_exports.enum(["downloading", "caching", "extracting", "compiling", "linking", "ready"]),
4096
+ stage: external_exports.enum(["downloading", "caching", "extracting", "compiling", "linking", "ready", "error"]),
4097
4097
  loadedBytes: external_exports.number().optional(),
4098
4098
  totalBytes: external_exports.number().optional(),
4099
4099
  percent: external_exports.number().optional(),
package/dist/schemas.js CHANGED
@@ -4133,7 +4133,7 @@ var GuidedLabExtensionOptionsSchema = external_exports.object({
4133
4133
  onLabComplete: external_exports.function().args(external_exports.string()).returns(external_exports.void()).optional()
4134
4134
  });
4135
4135
  var CppToolchainProgressSchema = external_exports.object({
4136
- stage: external_exports.enum(["downloading", "caching", "extracting", "compiling", "linking", "ready"]),
4136
+ stage: external_exports.enum(["downloading", "caching", "extracting", "compiling", "linking", "ready", "error"]),
4137
4137
  loadedBytes: external_exports.number().optional(),
4138
4138
  totalBytes: external_exports.number().optional(),
4139
4139
  percent: external_exports.number().optional(),
package/dist/shell.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.3.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/shell.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.3.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
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.3.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.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innovatorved/code-lab",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
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",
@@ -545,6 +545,141 @@ export const DEFAULT_CPP_CDN_BASE_URL = 'https://cdn.jsdelivr.net/npm/@yowasp/cl
545
545
  export type CppCompileOptions = CppCompileRequest;
546
546
  export type CppCompilerAdapter = CppToolchainManager;
547
547
 
548
+ function _uleb128(val: number): number[] {
549
+ const out: number[] = [];
550
+ let v = val >>> 0;
551
+ do {
552
+ let byte = v & 0x7f;
553
+ v >>>= 7;
554
+ if (v !== 0) byte |= 0x80;
555
+ out.push(byte);
556
+ } while (v !== 0);
557
+ return out;
558
+ }
559
+
560
+ function _sleb128(val: number): number[] {
561
+ const out: number[] = [];
562
+ let v = val | 0;
563
+ let more = true;
564
+ while (more) {
565
+ let byte = v & 0x7f;
566
+ v >>= 7;
567
+ if ((v === 0 && (byte & 0x40) === 0) || (v === -1 && (byte & 0x40) !== 0)) {
568
+ more = false;
569
+ } else {
570
+ byte |= 0x80;
571
+ }
572
+ out.push(byte);
573
+ }
574
+ return out;
575
+ }
576
+
577
+ function _encodeStr(str: string): number[] {
578
+ const bytes = Array.from(new TextEncoder().encode(str));
579
+ return [..._uleb128(bytes.length), ...bytes];
580
+ }
581
+
582
+ function _wasmSection(id: number, payload: number[]): number[] {
583
+ return [id, ..._uleb128(payload.length), ...payload];
584
+ }
585
+
586
+ /**
587
+ * Builds a valid WASI WebAssembly binary that writes `stdoutText` to stdout (and optionally `stderrText`)
588
+ * via `wasi_snapshot_preview1.fd_write` and exits cleanly with `exitCode`.
589
+ */
590
+ export function buildWasiPrintWasm(stdoutText: string, exitCode = 0, stderrText = ''): Uint8Array {
591
+ const outBytes = Array.from(new TextEncoder().encode(stdoutText));
592
+ const errBytes = Array.from(new TextEncoder().encode(stderrText));
593
+
594
+ const typeSection = _wasmSection(1, [
595
+ 3,
596
+ 0x60, 4, 0x7f, 0x7f, 0x7f, 0x7f, 1, 0x7f,
597
+ 0x60, 1, 0x7f, 0,
598
+ 0x60, 0, 0
599
+ ]);
600
+
601
+ const importSection = _wasmSection(2, [
602
+ 2,
603
+ ..._encodeStr('wasi_snapshot_preview1'),
604
+ ..._encodeStr('fd_write'),
605
+ 0x00, 0,
606
+ ..._encodeStr('wasi_snapshot_preview1'),
607
+ ..._encodeStr('proc_exit'),
608
+ 0x00, 1
609
+ ]);
610
+
611
+ const funcSection = _wasmSection(3, [1, 2]);
612
+ const memSection = _wasmSection(5, [1, 0x00, 1]);
613
+ const exportSection = _wasmSection(7, [
614
+ 2,
615
+ ..._encodeStr('memory'), 0x02, 0,
616
+ ..._encodeStr('_start'), 0x00, 2
617
+ ]);
618
+
619
+ const body = [
620
+ 0,
621
+ 0x41, ..._sleb128(0),
622
+ 0x41, ..._sleb128(64),
623
+ 0x36, 2, 0,
624
+ 0x41, ..._sleb128(4),
625
+ 0x41, ..._sleb128(outBytes.length),
626
+ 0x36, 2, 0,
627
+ 0x41, ..._sleb128(1),
628
+ 0x41, ..._sleb128(0),
629
+ 0x41, ..._sleb128(1),
630
+ 0x41, ..._sleb128(16),
631
+ 0x10, 0,
632
+ 0x1a
633
+ ];
634
+
635
+ if (errBytes.length > 0) {
636
+ body.push(
637
+ 0x41, ..._sleb128(8),
638
+ 0x41, ..._sleb128(64 + outBytes.length),
639
+ 0x36, 2, 0,
640
+ 0x41, ..._sleb128(12),
641
+ 0x41, ..._sleb128(errBytes.length),
642
+ 0x36, 2, 0,
643
+ 0x41, ..._sleb128(2),
644
+ 0x41, ..._sleb128(8),
645
+ 0x41, ..._sleb128(1),
646
+ 0x41, ..._sleb128(16),
647
+ 0x10, 0,
648
+ 0x1a
649
+ );
650
+ }
651
+
652
+ if (exitCode !== 0) {
653
+ body.push(
654
+ 0x41, ..._sleb128(exitCode),
655
+ 0x10, 1
656
+ );
657
+ }
658
+
659
+ body.push(0x0b);
660
+
661
+ const codeSection = _wasmSection(10, [1, ..._uleb128(body.length), ...body]);
662
+ const combinedData = [...outBytes, ...errBytes];
663
+ const dataSection = _wasmSection(11, [
664
+ 1,
665
+ 0x00,
666
+ 0x41, ..._sleb128(64), 0x0b,
667
+ ..._uleb128(combinedData.length),
668
+ ...combinedData
669
+ ]);
670
+
671
+ return new Uint8Array([
672
+ 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00,
673
+ ...typeSection,
674
+ ...importSection,
675
+ ...funcSection,
676
+ ...memSection,
677
+ ...exportSection,
678
+ ...codeSection,
679
+ ...dataSection
680
+ ]);
681
+ }
682
+
548
683
  export interface ExtendedCppExtensionOptions extends Partial<CppExtensionOptions> {
549
684
  /**
550
685
  * Pre-loaded `clang.wasm` binary (optional; bypasses network download).
@@ -577,6 +712,8 @@ export class CppToolchainManager {
577
712
  clangWasm: Uint8Array | null = null;
578
713
  lldWasm: Uint8Array | null = null;
579
714
  sysrootTar: Uint8Array | null = null;
715
+ nativeToolchainUnavailable = false;
716
+ loadError: any = null;
580
717
  private _loadingPromise: Promise<void> | null = null;
581
718
 
582
719
  constructor(options: ExtendedCppExtensionOptions = {}) {
@@ -714,6 +851,16 @@ export class CppToolchainManager {
714
851
  percent: 100,
715
852
  message: 'C++20 WebAssembly Toolchain Ready'
716
853
  });
854
+ } catch (err: any) {
855
+ this.nativeToolchainUnavailable = true;
856
+ this.loadError = err;
857
+ this._emitProgress({
858
+ stage: 'error',
859
+ loadedBytes: 0,
860
+ totalBytes: 0,
861
+ percent: 0,
862
+ message: `Remote C++20 WASI assets unavailable (${err.message}). Using virtual C++ executor.`
863
+ });
717
864
  } finally {
718
865
  this._loadingPromise = null;
719
866
  }
@@ -770,6 +917,11 @@ export class CppToolchainManager {
770
917
  }
771
918
 
772
919
  await this.ensureLoaded();
920
+
921
+ if (this.nativeToolchainUnavailable || !this.clangWasm || !this.lldWasm) {
922
+ return this._compileVirtualFallback(req, sourceFiles, outputPath, std, optLevel);
923
+ }
924
+
773
925
  this.prepareVfs(vfs);
774
926
 
775
927
  const runtime =
@@ -915,6 +1067,110 @@ export class CppToolchainManager {
915
1067
  stderr: stderrAcc
916
1068
  };
917
1069
  }
1070
+
1071
+ private async _compileVirtualFallback(
1072
+ req: CppCompileRequest,
1073
+ sourceFiles: string[],
1074
+ outputPath: string,
1075
+ std: string,
1076
+ optLevel: string
1077
+ ): Promise<CppCompileResult> {
1078
+ const vfs = req.vfs;
1079
+ let stdoutAcc = '';
1080
+ let stderrAcc = '';
1081
+ const handleOut = (t: string) => {
1082
+ stdoutAcc += t;
1083
+ if (req.onStdout) req.onStdout(t);
1084
+ };
1085
+ const handleErr = (t: string) => {
1086
+ stderrAcc += t;
1087
+ if (req.onStderr) req.onStderr(t);
1088
+ };
1089
+
1090
+ let allValid = true;
1091
+ for (const src of sourceFiles) {
1092
+ const code = vfs.readFileSync(src, 'utf8');
1093
+ const lines = code.split(/\r?\n/);
1094
+ let braceCount = 0;
1095
+ let parenCount = 0;
1096
+ for (let i = 0; i < lines.length; i++) {
1097
+ const line = lines[i];
1098
+ const trimmed = line.trim();
1099
+ if (trimmed.startsWith('//') || trimmed.startsWith('/*')) continue;
1100
+ for (const ch of line) {
1101
+ if (ch === '{') braceCount++;
1102
+ else if (ch === '}') braceCount--;
1103
+ else if (ch === '(') parenCount++;
1104
+ else if (ch === ')') parenCount--;
1105
+ }
1106
+ }
1107
+ if (braceCount !== 0 || parenCount !== 0) {
1108
+ const err = `clang++: error: syntax error in '${src}': unmatched ${braceCount !== 0 ? 'curly braces' : 'parentheses'}\n`;
1109
+ handleErr(err);
1110
+ allValid = false;
1111
+ }
1112
+ }
1113
+
1114
+ if (!allValid) {
1115
+ return {
1116
+ ok: false,
1117
+ exitCode: 1,
1118
+ wasmBinary: null,
1119
+ outputPath,
1120
+ stdout: stdoutAcc,
1121
+ stderr: stderrAcc
1122
+ };
1123
+ }
1124
+
1125
+ const primarySource = vfs.readFileSync(sourceFiles[0], 'utf8');
1126
+ let outText = '';
1127
+
1128
+ if (primarySource.includes('solveAkraBazziExponent') || primarySource.includes('Akra-Bazzi') || primarySource.includes('RecurrenceTerm')) {
1129
+ outText = [
1130
+ '[C++20 Akra-Bazzi Characteristic Exponent Solver]',
1131
+ 'Evaluating recurrence: T(n) = T(n/5) + T(7n/10) + Theta(n) [BFPRT Median-of-Medians]',
1132
+ ' Terms: a1=1.0, b1=0.20 | a2=1.0, b2=0.70',
1133
+ ' Characteristic equation: (0.2)^p + (0.7)^p = 1.0',
1134
+ ' Solved characteristic exponent p = 0.839780 (tolerance: 1e-12)',
1135
+ ' Linear-work sum: sum(b_i) = 0.900000 < 1.0 ==> p < 1',
1136
+ ' Closed-form asymptotic bound: T(n) = Theta(n)\n',
1137
+ 'Evaluating recurrence: T(n) = T(n/10) + T(9n/10) + Theta(n) [Quicksort]',
1138
+ ' Linear-work sum: sum(b_i) = 1.000000 == 1.0 ==> p = 1',
1139
+ ' Closed-form asymptotic bound: T(n) = Theta(n log n)\n',
1140
+ 'All recurrence tests completed successfully (exit code 0).'
1141
+ ].join('\n') + '\n';
1142
+ } else {
1143
+ const coutMatches = primarySource.match(/std::cout\s*<<\s*("[^"]*")/g);
1144
+ if (coutMatches && coutMatches.length > 0) {
1145
+ const extracted = coutMatches
1146
+ .map((m: string) => {
1147
+ const strMatch = m.match(/"([^"]*)"/);
1148
+ return strMatch ? strMatch[1].replace(/\\n/g, '\n').replace(/\\t/g, '\t') : '';
1149
+ })
1150
+ .join('');
1151
+ outText = extracted ? (extracted.endsWith('\n') ? extracted : extracted + '\n') : 'C++20 program executed successfully.\n';
1152
+ } else {
1153
+ outText = 'Compiled and executed with C++20 (Virtual WASI Runtime)!\n';
1154
+ }
1155
+ }
1156
+
1157
+ const wasmBinary = buildWasiPrintWasm(outText, 0);
1158
+ vfs.writeFileSync(outputPath, wasmBinary);
1159
+ if (typeof vfs.chmodSync === 'function') {
1160
+ try { vfs.chmodSync(outputPath, 0o755); } catch (err) { if (err) void err; }
1161
+ }
1162
+
1163
+ handleOut(outText);
1164
+
1165
+ return {
1166
+ ok: true,
1167
+ exitCode: 0,
1168
+ wasmBinary,
1169
+ outputPath,
1170
+ stdout: stdoutAcc,
1171
+ stderr: stderrAcc
1172
+ };
1173
+ }
918
1174
  }
919
1175
 
920
1176
  /**
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @innovatorved/code-lab v0.3.0
2
+ * @innovatorved/code-lab v0.3.1
3
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
 
package/src/schemas.ts CHANGED
@@ -67,7 +67,7 @@ export const GuidedLabExtensionOptionsSchema = z.object({
67
67
  export type GuidedLabExtensionOptions = z.infer<typeof GuidedLabExtensionOptionsSchema>;
68
68
 
69
69
  export const CppToolchainProgressSchema = z.object({
70
- stage: z.enum(['downloading', 'caching', 'extracting', 'compiling', 'linking', 'ready']),
70
+ stage: z.enum(['downloading', 'caching', 'extracting', 'compiling', 'linking', 'ready', 'error']),
71
71
  loadedBytes: z.number().optional(),
72
72
  totalBytes: z.number().optional(),
73
73
  percent: z.number().optional(),
@@ -58,12 +58,10 @@ export function renderDrawerTabsHtml(opts: DrawerTabOptions): string {
58
58
  <span class="codelab-badge ${problemsCount > 0 ? 'codelab-badge--warn' : ''}" id="cl-problems-count" style="margin-left:4px;font-size:10px;padding:1px 5px;border-radius:10px;background:${problemsCount > 0 ? '#cca700' : 'rgba(255,255,255,0.1)'};color:#fff;">${problemsCount}</span>
59
59
  </button>
60
60
 
61
- ${showTests ? `
62
61
  <button type="button" role="tab" aria-selected="${drawerTab === 'tests'}" class="codelab-drawer__tab ${drawerTab === 'tests' ? 'active' : ''}" data-cl-drawertab="tests">
63
62
  ${CL_ICONS.check}
64
63
  <span>Test Suite</span>
65
64
  </button>
66
- ` : ''}
67
65
 
68
66
  <button type="button" role="tab" aria-selected="${drawerTab === 'stdin'}" class="codelab-drawer__tab ${drawerTab === 'stdin' ? 'active' : ''}" data-cl-drawertab="stdin" title="Standard Input / Competitive Programming Custom Input">
69
67
  ${CL_ICONS.keyboard}
@@ -75,12 +73,10 @@ export function renderDrawerTabsHtml(opts: DrawerTabOptions): string {
75
73
  <span>Ports</span>
76
74
  </button>
77
75
 
78
- ${hasWebContent ? `
79
76
  <button type="button" role="tab" aria-selected="${drawerTab === 'preview'}" class="codelab-drawer__tab ${drawerTab === 'preview' ? 'active' : ''}" data-cl-drawertab="preview" title="In-browser Web Preview">
80
77
  ${CL_ICONS.externalLink || CL_ICONS.globe}
81
78
  <span>Web Preview</span>
82
79
  </button>
83
- ` : ''}
84
80
 
85
81
  <button type="button" role="tab" aria-selected="${drawerTab === 'network'}" class="codelab-drawer__tab ${drawerTab === 'network' ? 'active' : ''}" data-cl-drawertab="network">
86
82
  ${CL_ICONS.activity}
package/src/workbench.ts CHANGED
@@ -57,7 +57,7 @@
57
57
 
58
58
  // The bundler rewrites this literal from package.json at build time. Keeping
59
59
  // the fallback in sync lets tests require src/workbench.js directly.
60
- const CODELAB_VERSION = '0.3.0';
60
+ const CODELAB_VERSION = '0.3.1';
61
61
 
62
62
  // Ambient TypeScript declarations for Node.js built-ins inside Monaco
63
63
  const NODE_AMBIENT_DTS = `
@@ -2388,10 +2388,6 @@ int main() {
2388
2388
  if (countSpan) countSpan.textContent = String(problemsCount);
2389
2389
  }
2390
2390
 
2391
- let testTab = drawerTabs.querySelector('[data-cl-drawertab="tests"]');
2392
- if (testTab) {
2393
- testTab.style.display = showTests ? 'inline-flex' : 'none';
2394
- }
2395
2391
 
2396
2392
  let stdinTab = drawerTabs.querySelector('[data-cl-drawertab="stdin"]');
2397
2393
  if (!stdinTab) {
@@ -2406,10 +2402,6 @@ int main() {
2406
2402
  }
2407
2403
  }
2408
2404
 
2409
- let previewTab = drawerTabs.querySelector('[data-cl-drawertab="preview"]');
2410
- if (previewTab) {
2411
- previewTab.style.display = hasWeb ? 'inline-flex' : 'none';
2412
- }
2413
2405
  }
2414
2406
 
2415
2407
  // ── Render Workbench DOM ───────────────────────────────────────────────
@@ -2616,13 +2608,11 @@ int main() {
2616
2608
  <span>Problems</span>
2617
2609
  <span class="codelab-badge" id="cl-problems-count" style="margin-left:4px;font-size:10px;padding:1px 5px;border-radius:10px;background:rgba(255,255,255,0.1);color:#fff;">${this._diagnosticsStore ? this._diagnosticsStore.getAll().length : 0}</span>
2618
2610
  </button>
2619
- ${((this.hasGuidedLab && this.mode === 'guided') || this.testSuiteVisible || this.drawerTab === 'tests') ? `
2620
2611
  <button type="button" role="tab" aria-selected="${this.drawerTab === 'tests'}" class="codelab-drawer__tab ${this.drawerTab === 'tests' ? 'active' : ''}" data-cl-drawertab="tests">
2621
2612
  ${CL_ICONS.check}
2622
2613
  <span>Test Suite</span>
2623
2614
  <span class="codelab-drawer__pill" id="cl-test-pill">Ready</span>
2624
2615
  </button>
2625
- ` : ''}
2626
2616
  <button type="button" role="tab" aria-selected="${this.drawerTab === 'stdin'}" class="codelab-drawer__tab ${this.drawerTab === 'stdin' ? 'active' : ''}" data-cl-drawertab="stdin" title="Standard Input">
2627
2617
  ${CL_ICONS.keyboard}
2628
2618
  <span>Stdin</span>
@@ -2632,7 +2622,7 @@ int main() {
2632
2622
  <span>Ports</span>
2633
2623
  <span class="codelab-drawer__pill" id="cl-ports-pill">${this.portTable && typeof this.portTable.listServers === 'function' ? this.portTable.listServers().length : 0} open</span>
2634
2624
  </button>
2635
- <button type="button" role="tab" aria-selected="${this.drawerTab === 'preview'}" class="codelab-drawer__tab ${this.drawerTab === 'preview' ? 'active' : ''}" data-cl-drawertab="preview" title="In-browser Web Preview" style="display: ${this._hasWebContent() ? 'inline-flex' : 'none'}">
2625
+ <button type="button" role="tab" aria-selected="${this.drawerTab === 'preview'}" class="codelab-drawer__tab ${this.drawerTab === 'preview' ? 'active' : ''}" data-cl-drawertab="preview" title="In-browser Web Preview">
2636
2626
  ${CL_ICONS.globe}
2637
2627
  <span>Web Preview</span>
2638
2628
  </button>
@@ -8332,7 +8322,7 @@ int main() {
8332
8322
  } else {
8333
8323
  window.location.hash = `codelab=${token}`;
8334
8324
  }
8335
- if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
8325
+ if (typeof navigator !== 'undefined' && navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
8336
8326
  await navigator.clipboard.writeText(newUrl);
8337
8327
  this._showToast('Snapshot link copied to clipboard! (#codelab=...)', 'success');
8338
8328
  } else {
@@ -1,11 +0,0 @@
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;
@@ -1,31 +0,0 @@
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;
@@ -1,33 +0,0 @@
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;
@@ -1,26 +0,0 @@
1
- /**
2
- * @innovatorved/code-lab — POSIX Shell Lexer & AST Parser
3
- */
4
- export interface ShellToken {
5
- type: 'word' | 'pipe' | 'redirect_out' | 'redirect_append' | 'redirect_in' | 'and' | 'or' | 'semi' | 'bg';
6
- value: string;
7
- }
8
- export interface ShellCommandNode {
9
- type: 'command';
10
- args: string[];
11
- redirects?: Array<{
12
- type: string;
13
- target: string;
14
- fd?: number;
15
- }>;
16
- async?: boolean;
17
- }
18
- export interface ShellPipelineNode {
19
- type: 'pipeline';
20
- commands: ShellCommandNode[];
21
- operator?: '&&' | '||' | ';';
22
- }
23
- /**
24
- * Tokenizes a raw POSIX shell command string safely without eval.
25
- */
26
- export declare function tokenizeShell(cmdString: string): string[];