@innovatorved/code-lab 0.3.1 → 0.3.2

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 (48) hide show
  1. package/ARCHITECTURE.md +4 -2
  2. package/CHANGELOG.md +25 -0
  3. package/README.md +15 -5
  4. package/dist/code-lab.css +52 -2
  5. package/dist/code-lab.d.ts +1 -1
  6. package/dist/code-lab.esm.js +1247 -377
  7. package/dist/code-lab.js +1246 -376
  8. package/dist/diagnostics.d.ts +5 -0
  9. package/dist/extensions/cpp.esm.js +51 -9
  10. package/dist/extensions/cpp.js +51 -9
  11. package/dist/extensions/python.esm.js +116 -103
  12. package/dist/extensions/python.js +116 -103
  13. package/dist/index.d.ts +1 -1
  14. package/dist/preview-sw.js +34 -17
  15. package/dist/runtime.esm.js +38 -31
  16. package/dist/runtime.js +38 -31
  17. package/dist/schemas.d.ts +1 -1
  18. package/dist/scm.d.ts +13 -2
  19. package/dist/search.d.ts +5 -1
  20. package/dist/shell.esm.js +72 -16
  21. package/dist/shell.js +72 -16
  22. package/dist/terminal.esm.js +183 -54
  23. package/dist/terminal.js +183 -54
  24. package/dist/workbench/index.d.ts +1 -1
  25. package/dist/workbench/styles.d.ts +1 -1
  26. package/dist/zip.d.ts +4 -3
  27. package/package.json +1 -1
  28. package/src/code-lab.css +52 -2
  29. package/src/csp.ts +7 -10
  30. package/src/diagnostics.ts +42 -3
  31. package/src/extensions/cpp.ts +47 -9
  32. package/src/extensions/python.ts +128 -116
  33. package/src/index.ts +1 -1
  34. package/src/preview-sw.js +25 -5
  35. package/src/runtime.ts +36 -29
  36. package/src/schemas.ts +1 -1
  37. package/src/scm.ts +106 -19
  38. package/src/search.ts +71 -27
  39. package/src/shell.ts +70 -14
  40. package/src/terminal.ts +181 -52
  41. package/src/workbench/diff-editor.ts +41 -13
  42. package/src/workbench/drawer.ts +17 -4
  43. package/src/workbench/guided-pane.ts +12 -2
  44. package/src/workbench/share.ts +37 -8
  45. package/src/workbench/styles.ts +2 -1
  46. package/src/workbench/toolbar.ts +15 -4
  47. package/src/workbench.ts +482 -79
  48. package/src/zip.ts +29 -7
package/dist/terminal.js CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.3.1 — Standalone Browser Code IDE & Virtual Runtime
3
+ * @innovatorved/code-lab v0.3.2 — Standalone Browser Code IDE & Virtual Runtime
4
4
  * ============================================================
5
5
  * Features:
6
6
  * - Sandboxed Web Worker Execution Engine with Multi-Instance Isolation & Watchdog Timer
7
7
  * - First-Class Node.js and Bun Runtimes (Bun.serve, bun:test, bun:sqlite, Bun.*)
8
- * - Full POSIX Shell AST & 55+ UNIX Coreutils (pipes, redirects, globs, env vars, git & git clone)
8
+ * - Full POSIX Shell AST & 71 UNIX Coreutils (pipes, redirects, globs, env vars, git & git clone)
9
9
  * - Interactive PTY Terminal Emulator with inline prompt, Tab completion & ANSI colors
10
10
  * - Persistent HTTP/TCP Servers, CLI curl & Live Port/HTTP Preview
11
11
  * - Modular VS Code Workbench: File Tree, Tabs, Command Palette, Diff Viewer
@@ -423,6 +423,14 @@ var CodeLabLogger = (() => {
423
423
 
424
424
  const parseAnsiToHtml = ansiToHtml;
425
425
 
426
+ const MAX_SCROLLBACK = 2000;
427
+ const VALID_LOG_TYPES = new Set(['stdout', 'stderr', 'system', 'info', 'warn', 'error', 'success']);
428
+
429
+ function sanitizeLogType(type) {
430
+ const t = String(type || 'stdout').trim();
431
+ return VALID_LOG_TYPES.has(t) ? t : 'stdout';
432
+ }
433
+
426
434
  class PTYTerminalEngine {
427
435
  constructor(container, options = {}) {
428
436
  if (
@@ -437,6 +445,9 @@ var CodeLabLogger = (() => {
437
445
  }
438
446
  this.container = container || null;
439
447
  this.options = options || {};
448
+ this.maxScrollback = typeof this.options.maxScrollback === 'number' && this.options.maxScrollback > 0
449
+ ? this.options.maxScrollback
450
+ : MAX_SCROLLBACK;
440
451
  this.logs = Array.isArray(this.options.logs) ? this.options.logs : [];
441
452
  this.cwd = this.options.cwd || '/workspace';
442
453
  this.replMode = Boolean(this.options.replMode);
@@ -450,6 +461,7 @@ var CodeLabLogger = (() => {
450
461
  this.searchQuery = '';
451
462
  this.searchMatchIdx = -1;
452
463
  this._readLineQueue = [];
464
+ this.isBusy = false;
453
465
  this.onCommand = typeof this.options.onCommand === 'function' ? this.options.onCommand : null;
454
466
  this.getCompletions = typeof this.options.getCompletions === 'function' ? this.options.getCompletions : null;
455
467
  this.onKey = typeof this.options.onKey === 'function' ? this.options.onKey : null;
@@ -600,13 +612,40 @@ var CodeLabLogger = (() => {
600
612
  this.writeStreamChunk(String(data) + '\n', type);
601
613
  }
602
614
 
615
+ isCommandRunning() {
616
+ return Boolean(this.isBusy && (!this._readLineQueue || this._readLineQueue.length === 0));
617
+ }
618
+
619
+ _pushLog(entry) {
620
+ const normalized = {
621
+ type: sanitizeLogType(entry && entry.type),
622
+ text: String(entry && entry.text != null ? entry.text : '')
623
+ };
624
+ this.logs.push(normalized);
625
+ if (this.logs.length > this.maxScrollback) {
626
+ const excess = this.logs.length - this.maxScrollback;
627
+ this.logs.splice(0, excess);
628
+ if (this._targetLineIdx >= 0) {
629
+ this._targetLineIdx = Math.max(0, this._targetLineIdx - excess);
630
+ }
631
+ if (this.container && typeof this.container.querySelector === 'function') {
632
+ const logEl = this.container.querySelector('#cl-terminal-log');
633
+ if (logEl && logEl.children && logEl.children.length > this.maxScrollback) {
634
+ while (logEl.children.length > this.maxScrollback && typeof logEl.removeChild === 'function' && logEl.firstChild) {
635
+ logEl.removeChild(logEl.firstChild);
636
+ }
637
+ }
638
+ }
639
+ }
640
+ return normalized;
641
+ }
642
+
603
643
  _getActiveLine(type) {
604
644
  if (this._targetLineIdx >= 0 && this._targetLineIdx < this.logs.length) {
605
645
  return this.logs[this._targetLineIdx];
606
646
  }
607
647
  if (this._activeLineCommitted || this.logs.length === 0) {
608
- const newLine = { text: '', type };
609
- this.logs.push(newLine);
648
+ const newLine = this._pushLog({ text: '', type });
610
649
  this._activeLineCommitted = false;
611
650
  this._cursorCol = 0;
612
651
  this._targetLineIdx = this.logs.length - 1;
@@ -623,7 +662,7 @@ var CodeLabLogger = (() => {
623
662
  const logEl = this.container.querySelector('#cl-terminal-log');
624
663
  if (!logEl) return;
625
664
  const lineEl = document.createElement('div');
626
- lineEl.className = 'codelab-log-line ' + (line.type || 'stdout');
665
+ lineEl.className = 'codelab-log-line ' + sanitizeLogType(line.type);
627
666
  lineEl.innerHTML = ansiToHtml(line.text);
628
667
  logEl.appendChild(lineEl);
629
668
  this._activeLineEl = lineEl;
@@ -646,7 +685,7 @@ var CodeLabLogger = (() => {
646
685
  }
647
686
  }
648
687
  if (lineEl) {
649
- lineEl.className = 'codelab-log-line ' + (line.type || 'stdout');
688
+ lineEl.className = 'codelab-log-line ' + sanitizeLogType(line.type);
650
689
  lineEl.innerHTML = ansiToHtml(line.text);
651
690
  }
652
691
  }
@@ -685,17 +724,29 @@ var CodeLabLogger = (() => {
685
724
  return [...this.history];
686
725
  }
687
726
 
688
- readLine(promptText = '') {
689
- const prevPrompt = this.promptOverride;
690
- if (promptText) {
691
- this.setPrompt(promptText);
727
+ _activateNextReadLine() {
728
+ if (!this._readLineQueue || this._readLineQueue.length === 0) return;
729
+ const head = this._readLineQueue[0];
730
+ if (head && typeof head === 'object' && !head._activated) {
731
+ head._activated = true;
732
+ head.prevPrompt = this.promptOverride;
733
+ if (head.promptText) {
734
+ this.promptOverride = head.promptText;
735
+ }
692
736
  }
737
+ }
738
+
739
+ readLine(promptText = '') {
693
740
  return new Promise((resolve) => {
694
- this._readLineQueue.push((line) => {
695
- this.promptOverride = prevPrompt;
696
- this.updateActiveLine();
697
- resolve(line);
698
- });
741
+ const item = {
742
+ promptText: String(promptText || ''),
743
+ prevPrompt: null,
744
+ _activated: false,
745
+ resolve
746
+ };
747
+ this._readLineQueue.push(item);
748
+ this._activateNextReadLine();
749
+ this.updateActiveLine();
699
750
  });
700
751
  }
701
752
 
@@ -765,6 +816,10 @@ var CodeLabLogger = (() => {
765
816
  if (input) {
766
817
  this._addListener(input, 'keydown', (e) => this.handleKeyDown(e));
767
818
  this._addListener(input, 'input', () => {
819
+ if (this.isCommandRunning()) {
820
+ input.value = '';
821
+ return;
822
+ }
768
823
  if (input.value !== this.buffer) {
769
824
  this.buffer = input.value;
770
825
  this.cursor = typeof input.selectionStart === 'number' ? input.selectionStart : this.buffer.length;
@@ -806,6 +861,35 @@ var CodeLabLogger = (() => {
806
861
  const key = e.key;
807
862
  const isCtrl = Boolean(e.ctrlKey || e.metaKey);
808
863
 
864
+ if (isCtrl && (key === 'l' || key === 'L')) {
865
+ if (e.preventDefault) e.preventDefault();
866
+ this.clear();
867
+ return;
868
+ }
869
+
870
+ if (isCtrl && (key === 'c' || key === 'C')) {
871
+ if (e.preventDefault) e.preventDefault();
872
+ const wasBusy = this.isBusy;
873
+ this.isBusy = false;
874
+ this._pushLog({ type: 'system', text: wasBusy ? '^C' : `${this.getPrompt()}${this.buffer}^C` });
875
+ this.buffer = '';
876
+ this.cursor = 0;
877
+ this.historyIdx = -1;
878
+ if (this.replMode) {
879
+ this.replMode = false;
880
+ }
881
+ if (this.onInterrupt) {
882
+ try { this.onInterrupt(); } catch (err) { _terminalLogger.warn('Terminal onInterrupt callback threw.', err); }
883
+ }
884
+ this.render();
885
+ return;
886
+ }
887
+
888
+ if (this.isCommandRunning()) {
889
+ if (e.preventDefault) e.preventDefault();
890
+ return;
891
+ }
892
+
809
893
  if (isCtrl && (key === 'r' || key === 'R')) {
810
894
  if (e.preventDefault) e.preventDefault();
811
895
  if (!this.searchMode) {
@@ -937,33 +1021,11 @@ var CodeLabLogger = (() => {
937
1021
  return;
938
1022
  }
939
1023
 
940
- if (isCtrl && (key === 'l' || key === 'L')) {
941
- if (e.preventDefault) e.preventDefault();
942
- this.clear();
943
- return;
944
- }
945
-
946
- if (isCtrl && (key === 'c' || key === 'C')) {
947
- if (e.preventDefault) e.preventDefault();
948
- this.logs.push({ type: 'system', text: `${this.getPrompt()}${this.buffer}^C` });
949
- this.buffer = '';
950
- this.cursor = 0;
951
- this.historyIdx = -1;
952
- if (this.replMode) {
953
- this.replMode = false;
954
- }
955
- if (this.onInterrupt) {
956
- try { this.onInterrupt(); } catch (err) { _terminalLogger.warn('Terminal onInterrupt callback threw.', err); }
957
- }
958
- this.render();
959
- return;
960
- }
961
-
962
1024
  if (isCtrl && (key === 'd' || key === 'D')) {
963
1025
  if (this.buffer === '') {
964
1026
  if (e.preventDefault) e.preventDefault();
965
1027
  if (this.replMode) {
966
- this.logs.push({ type: 'system', text: `${this.getPrompt()}.exit` });
1028
+ this._pushLog({ type: 'system', text: `${this.getPrompt()}.exit` });
967
1029
  this.replMode = false;
968
1030
  this.render();
969
1031
  return;
@@ -1057,14 +1119,41 @@ var CodeLabLogger = (() => {
1057
1119
  }
1058
1120
 
1059
1121
  // Print candidate matches
1060
- this.logs.push({ type: 'system', text: `${this.getPrompt()}${this.buffer}` });
1061
- this.logs.push({ type: 'stdout', text: matches.join(' ') });
1122
+ this._pushLog({ type: 'system', text: `${this.getPrompt()}${this.buffer}` });
1123
+ this._pushLog({ type: 'stdout', text: matches.join(' ') });
1062
1124
  this.render();
1063
1125
  }
1064
1126
  }
1065
1127
 
1066
1128
  submitLine() {
1129
+ if (this._readLineQueue && this._readLineQueue.length > 0) {
1130
+ const line = this.buffer;
1131
+ this.buffer = '';
1132
+ this.cursor = 0;
1133
+ this.historyIdx = -1;
1134
+ this.searchMode = false;
1135
+ this.searchQuery = '';
1136
+ this.searchMatchIdx = -1;
1137
+
1138
+ const entry = this._readLineQueue.shift();
1139
+ if (typeof entry === 'function') {
1140
+ this.updateActiveLine();
1141
+ entry(line);
1142
+ } else if (entry && typeof entry.resolve === 'function') {
1143
+ this.promptOverride = entry.prevPrompt;
1144
+ this._activateNextReadLine();
1145
+ this.updateActiveLine();
1146
+ entry.resolve(line);
1147
+ }
1148
+ return;
1149
+ }
1150
+
1151
+ if (this.isBusy) {
1152
+ return;
1153
+ }
1154
+
1067
1155
  const line = this.buffer;
1156
+ const promptSnap = this.getPrompt();
1068
1157
  this.buffer = '';
1069
1158
  this.cursor = 0;
1070
1159
  this.historyIdx = -1;
@@ -1072,22 +1161,49 @@ var CodeLabLogger = (() => {
1072
1161
  this.searchQuery = '';
1073
1162
  this.searchMatchIdx = -1;
1074
1163
 
1164
+ const echoed = this._pushLog({ type: 'system', text: `${promptSnap}${line}` });
1165
+ this._activeLineCommitted = true;
1166
+ this._cursorCol = 0;
1167
+ this._targetLineIdx = -1;
1168
+ this._needsRewrite = false;
1169
+ this._appendDomLine(echoed);
1170
+ this._activeLineEl = null;
1171
+
1075
1172
  if (line.trim()) {
1076
1173
  if (this.history[this.history.length - 1] !== line.trim()) {
1077
1174
  this.history.push(line.trim());
1078
1175
  }
1079
1176
  }
1080
1177
 
1081
- if (this._readLineQueue && this._readLineQueue.length > 0) {
1082
- const resolver = this._readLineQueue.shift();
1178
+ if (!this.onCommand) {
1083
1179
  this.updateActiveLine();
1084
- resolver(line);
1085
1180
  return;
1086
1181
  }
1087
1182
 
1183
+ this.isBusy = true;
1088
1184
  this.updateActiveLine();
1089
- if (this.onCommand) {
1090
- this.onCommand(line);
1185
+
1186
+ let cmdResult;
1187
+ try {
1188
+ cmdResult = this.onCommand(line);
1189
+ } catch (err) {
1190
+ this.isBusy = false;
1191
+ this.updateActiveLine();
1192
+ throw err;
1193
+ }
1194
+
1195
+ if (cmdResult && typeof cmdResult.then === 'function') {
1196
+ Promise.resolve(cmdResult)
1197
+ .catch((err) => {
1198
+ _terminalLogger.debug('Terminal onCommand promise rejected.', err);
1199
+ })
1200
+ .finally(() => {
1201
+ this.isBusy = false;
1202
+ this.updateActiveLine();
1203
+ });
1204
+ } else {
1205
+ this.isBusy = false;
1206
+ this.updateActiveLine();
1091
1207
  }
1092
1208
  }
1093
1209
 
@@ -1100,6 +1216,16 @@ var CodeLabLogger = (() => {
1100
1216
  const lineEl = this.container.querySelector('#cl-pty-active-line');
1101
1217
  if (!lineEl) return;
1102
1218
 
1219
+ if (this.isCommandRunning()) {
1220
+ if (typeof lineEl.setAttribute === 'function') lineEl.setAttribute('data-busy', 'true');
1221
+ if (lineEl.style) lineEl.style.display = 'none';
1222
+ lineEl.innerHTML = `<span class="codelab-pty__prompt"></span><span class="codelab-pty__before"></span><span class="codelab-pty__cursor"></span><span class="codelab-pty__after"></span>`;
1223
+ return;
1224
+ }
1225
+
1226
+ if (typeof lineEl.removeAttribute === 'function') lineEl.removeAttribute('data-busy');
1227
+ if (lineEl.style) lineEl.style.display = '';
1228
+
1103
1229
  const prompt = this.searchMode
1104
1230
  ? `(reverse-i-search)\`${this.searchQuery}\`: `
1105
1231
  : this.getPrompt();
@@ -1120,21 +1246,24 @@ var CodeLabLogger = (() => {
1120
1246
  );
1121
1247
 
1122
1248
  const logsHtml = this.logs
1123
- .map(item => `<div class="codelab-log-line ${escapeHtml(item.type || '')}">${ansiToHtml(item.text)}</div>`)
1249
+ .map(item => `<div class="codelab-log-line ${sanitizeLogType(item.type)}">${ansiToHtml(item.text)}</div>`)
1124
1250
  .join('');
1125
1251
 
1126
- const prompt = this.searchMode
1127
- ? `(reverse-i-search)\`${this.searchQuery}\`: `
1128
- : this.getPrompt();
1129
- const before = this.buffer.slice(0, this.cursor);
1130
- const cursorChar = this.cursor < this.buffer.length ? this.buffer[this.cursor] : ' ';
1131
- const after = this.cursor < this.buffer.length ? this.buffer.slice(this.cursor + 1) : '';
1252
+ const busy = this.isCommandRunning();
1253
+ const prompt = busy
1254
+ ? ''
1255
+ : (this.searchMode ? `(reverse-i-search)\`${this.searchQuery}\`: ` : this.getPrompt());
1256
+ const before = busy ? '' : this.buffer.slice(0, this.cursor);
1257
+ const cursorChar = busy ? '' : (this.cursor < this.buffer.length ? this.buffer[this.cursor] : ' ');
1258
+ const after = busy ? '' : (this.cursor < this.buffer.length ? this.buffer.slice(this.cursor + 1) : '');
1259
+ const busyAttr = busy ? ' data-busy="true" style="display:none;"' : '';
1260
+ const cursorClass = busy ? 'codelab-pty__cursor' : 'codelab-pty__cursor blink';
1132
1261
 
1133
1262
  this.container.innerHTML = `
1134
1263
  <div class="codelab-terminal" id="cl-terminal-surface" tabindex="0">
1135
1264
  <div class="codelab-terminal__log" id="cl-terminal-log">${logsHtml}</div>
1136
- <div class="codelab-pty__active-line" id="cl-pty-active-line">
1137
- <span class="codelab-pty__prompt">${escapeHtml(prompt)}</span><span class="codelab-pty__before">${escapeHtml(before)}</span><span class="codelab-pty__cursor blink">${escapeHtml(cursorChar)}</span><span class="codelab-pty__after">${escapeHtml(after)}</span>
1265
+ <div class="codelab-pty__active-line" id="cl-pty-active-line"${busyAttr}>
1266
+ <span class="codelab-pty__prompt">${escapeHtml(prompt)}</span><span class="codelab-pty__before">${escapeHtml(before)}</span><span class="${cursorClass}">${escapeHtml(cursorChar)}</span><span class="codelab-pty__after">${escapeHtml(after)}</span>
1138
1267
  </div>
1139
1268
  <form class="codelab-repl" id="cl-repl-form" style="position:absolute;opacity:0;pointer-events:none;height:0;overflow:hidden;">
1140
1269
  <input type="text" class="codelab-repl__input" id="cl-repl-input" autocomplete="off" spellcheck="false" aria-label="Terminal command input" value="${escapeHtml(this.buffer)}">
@@ -34,6 +34,6 @@ export declare const CodeLabWorkbenchComponents: {
34
34
  renderStdinPanelHtml(workbench: any): string;
35
35
  renderLanguageSwitcherHtml(workbench: any): string;
36
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";
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.codelab-split-menu.active {\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
38
  CL_ICONS: Record<string, string>;
39
39
  };
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * @innovatorved/code-lab — Workbench CSS Tokens, Themes & Styles
3
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";
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.codelab-split-menu.active {\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";
package/dist/zip.d.ts CHANGED
@@ -18,7 +18,8 @@ export declare function toUint8Array(input: string | Uint8Array | ArrayBuffer):
18
18
  */
19
19
  export declare function computeCrc32(data: string | Uint8Array | ArrayBuffer): number;
20
20
  /**
21
- * Sanitizes an archive entry path to prevent Zip-Slip directory traversal attacks.
21
+ * Sanitizes an archive entry path to prevent Zip-Slip directory traversal attacks
22
+ * and prototype-pollution key injection.
22
23
  * Normalizes backslashes, strips drive prefixes and leading slashes, and collapses
23
24
  * or removes `..` and `.` segments so the resulting path is strictly relative.
24
25
  */
@@ -26,12 +27,12 @@ export declare function sanitizeZipPath(rawPath: string): string;
26
27
  /**
27
28
  * Creates a standard PKZip v2.0 archive from a map of file paths to contents.
28
29
  */
29
- export declare function createZip(files: Record<string, string | Uint8Array>): Promise<Uint8Array>;
30
+ export declare function createZip(files: Record<string, string | Uint8Array>): Uint8Array;
30
31
  /**
31
32
  * Extracts a PKZip v2.0 archive into a UTF-8 file dictionary (`Record<string, string>`).
32
33
  * Validates magic headers, checks boundaries, and sanitizes paths against Zip-Slip.
33
34
  */
34
- export declare function extractZip(data: Uint8Array | ArrayBuffer): Promise<Record<string, string>>;
35
+ export declare function extractZip(data: Uint8Array | ArrayBuffer): Record<string, string>;
35
36
  declare const _default: {
36
37
  createZip: typeof createZip;
37
38
  extractZip: typeof extractZip;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innovatorved/code-lab",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
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",
package/src/code-lab.css CHANGED
@@ -3027,6 +3027,10 @@ code-lab,
3027
3027
  padding: 2px 0;
3028
3028
  }
3029
3029
 
3030
+ .codelab-pty__active-line[data-busy="true"] {
3031
+ display: none !important;
3032
+ }
3033
+
3030
3034
  .codelab-pty__prompt {
3031
3035
  color: var(--cl-green);
3032
3036
  font-weight: 600;
@@ -5357,7 +5361,8 @@ code-lab,
5357
5361
  padding: 4px 0;
5358
5362
  display: none;
5359
5363
  }
5360
- .codelab-split-menu.open {
5364
+ .codelab-split-menu.open,
5365
+ .codelab-split-menu.active {
5361
5366
  display: block;
5362
5367
  }
5363
5368
  .codelab-split-menu__item {
@@ -5490,12 +5495,57 @@ code-lab,
5490
5495
  .codelab-problem-item--info {
5491
5496
  color: #3794ff;
5492
5497
  }
5493
- .codelab-problem-item__location {
5498
+ .codelab-problem-item__location,
5499
+ .codelab-problem-item__loc {
5494
5500
  color: var(--cl-fg-muted, #858585);
5495
5501
  font-size: 11px;
5496
5502
  margin-left: auto;
5497
5503
  }
5498
5504
 
5505
+ /* ── Search, SCM & Terminal Session UI Polish ── */
5506
+ .codelab-modal-input {
5507
+ flex: 1;
5508
+ padding: 6px 10px;
5509
+ background: var(--cl-input-bg, #252526);
5510
+ color: var(--cl-fg, #cccccc);
5511
+ border: 1px solid var(--cl-border, #3c3c3c);
5512
+ border-radius: var(--cl-radius, 4px);
5513
+ font-family: var(--cl-font-mono, monospace);
5514
+ font-size: 12px;
5515
+ outline: none;
5516
+ }
5517
+ .codelab-modal-input:focus {
5518
+ border-color: var(--cl-accent, #007acc);
5519
+ }
5520
+ .codelab-search-match:hover,
5521
+ .codelab-problem-entry:hover,
5522
+ .codelab-scm-entry:hover {
5523
+ background: var(--cl-tree-hover, rgba(255, 255, 255, 0.06));
5524
+ }
5525
+ .codelab-terminal-sessions {
5526
+ display: inline-flex;
5527
+ align-items: center;
5528
+ gap: 4px;
5529
+ }
5530
+ .codelab-session-pill {
5531
+ display: inline-flex;
5532
+ align-items: center;
5533
+ gap: 4px;
5534
+ padding: 1px 7px;
5535
+ font-size: 11px;
5536
+ font-family: var(--cl-font-mono, monospace);
5537
+ border-radius: 4px;
5538
+ border: 1px solid var(--cl-border, #3c3c3c);
5539
+ background: transparent;
5540
+ color: var(--cl-fg-muted, #858585);
5541
+ cursor: pointer;
5542
+ }
5543
+ .codelab-session-pill.active {
5544
+ background: var(--cl-hud-bg, rgba(0, 122, 204, 0.18));
5545
+ border-color: var(--cl-accent, #007acc);
5546
+ color: var(--cl-fg, #ffffff);
5547
+ }
5548
+
5499
5549
  /* ── Monaco Side-by-Side Diff Editor ── */
5500
5550
  .codelab-diff-container {
5501
5551
  display: flex;
package/src/csp.ts CHANGED
@@ -217,7 +217,12 @@ export function buildPreviewPolicy(options: PreviewCspOptions = {}): string {
217
217
  directive('worker-src', [self, 'blob:'].concat(sourcesFor(mode, allow, 'workerSrc'))),
218
218
  directive('frame-src', withData('frameSrc')),
219
219
  directive('form-action', [self]),
220
- directive('frame-ancestors', [options.frameAncestors || "'self'"])
220
+ directive('frame-ancestors', (() => {
221
+ const rawFa = typeof options.frameAncestors === 'string' ? options.frameAncestors.trim() : '';
222
+ if (!rawFa) return ["'self'"];
223
+ const tokens = cleanSources(rawFa.split(/\s+/));
224
+ return tokens.length > 0 ? tokens : ["'self'"];
225
+ })())
221
226
  ].join('; ');
222
227
  }
223
228
 
@@ -272,15 +277,6 @@ export function buildPreviewShims(): string {
272
277
  };
273
278
  }
274
279
  function shim(name) {
275
- var blocked = false;
276
- try {
277
- var existing = window[name];
278
- if (existing) { existing.getItem('__codelab_probe__'); return; }
279
- } catch (err) {
280
- // Expected on an opaque origin: the accessor itself throws.
281
- blocked = Boolean(err);
282
- }
283
- void blocked;
284
280
  try {
285
281
  Object.defineProperty(window, name, { configurable: true, value: memoryStorage() });
286
282
  } catch (err) {
@@ -440,6 +436,7 @@ export function buildPreviewShims(): string {
440
436
  }
441
437
 
442
438
  window.addEventListener('message', function (event) {
439
+ if (event && event.source && event.source !== window.parent) return;
443
440
  var data = event && event.data;
444
441
  if (!data || typeof data !== 'object') return;
445
442
  if (data.type === 'codelab:preview-fetch-res' && data.reqId) {
@@ -31,10 +31,12 @@ export type DiagnosticListener = (items: DiagnosticItem[]) => void;
31
31
  export class DiagnosticsStore {
32
32
  private readonly items: Map<string, DiagnosticItem> = new Map();
33
33
  private readonly listeners: Set<DiagnosticListener> = new Set();
34
+ private batchDepth = 0;
35
+ private batchDirty = false;
34
36
 
35
- public add(item: DiagnosticItem): void {
36
- if (!item || typeof item.id !== 'string' || !item.id) return;
37
- const normalized: DiagnosticItem = {
37
+ private normalizeItem(item: DiagnosticItem): DiagnosticItem | null {
38
+ if (!item || typeof item.id !== 'string' || !item.id) return null;
39
+ return {
38
40
  ...item,
39
41
  file: String(item.file || ''),
40
42
  line: typeof item.line === 'number' && item.line > 0 ? Math.floor(item.line) : 1,
@@ -44,10 +46,43 @@ export class DiagnosticsStore {
44
46
  message: String(item.message || ''),
45
47
  severity: item.severity || 'error'
46
48
  };
49
+ }
50
+
51
+ public add(item: DiagnosticItem): void {
52
+ const normalized = this.normalizeItem(item);
53
+ if (!normalized) return;
47
54
  this.items.set(normalized.id, normalized);
48
55
  this.notify();
49
56
  }
50
57
 
58
+ public setMany(items: ReadonlyArray<DiagnosticItem>, clearSource?: string): void {
59
+ this.batch(() => {
60
+ if (clearSource !== undefined) {
61
+ this.clear(clearSource);
62
+ }
63
+ for (const item of items) {
64
+ const normalized = this.normalizeItem(item);
65
+ if (normalized) {
66
+ this.items.set(normalized.id, normalized);
67
+ this.batchDirty = true;
68
+ }
69
+ }
70
+ });
71
+ }
72
+
73
+ public batch(fn: () => void): void {
74
+ this.batchDepth++;
75
+ try {
76
+ fn();
77
+ } finally {
78
+ this.batchDepth--;
79
+ if (this.batchDepth === 0 && this.batchDirty) {
80
+ this.batchDirty = false;
81
+ this.notify();
82
+ }
83
+ }
84
+ }
85
+
51
86
  public remove(id: string): void {
52
87
  if (this.items.delete(id)) {
53
88
  this.notify();
@@ -94,6 +129,10 @@ export class DiagnosticsStore {
94
129
  }
95
130
 
96
131
  private notify(): void {
132
+ if (this.batchDepth > 0) {
133
+ this.batchDirty = true;
134
+ return;
135
+ }
97
136
  if (this.listeners.size === 0) return;
98
137
  const snapshot = this.getAll();
99
138
  for (const listener of this.listeners) {