@innovatorved/code-lab 0.3.1 → 0.4.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.
- package/ARCHITECTURE.md +8 -4
- package/CHANGELOG.md +45 -0
- package/README.md +70 -158
- package/dist/apps/web/src/index.d.ts +34 -0
- package/dist/code-lab-sql.css +482 -0
- package/dist/code-lab-sql.d.ts +179 -0
- package/dist/code-lab-sql.esm.js +542 -0
- package/dist/code-lab-sql.umd.js +531 -0
- package/dist/code-lab.css +298 -2
- package/dist/code-lab.d.ts +110 -15
- package/dist/code-lab.esm.js +35284 -18253
- package/dist/code-lab.js +40434 -23431
- package/dist/code-lab.umd.js +65502 -0
- package/dist/diagnostics.d.ts +5 -0
- package/dist/extensions/cpp.esm.js +19532 -3772
- package/dist/extensions/cpp.js +19529 -3769
- package/dist/extensions/guided-lab.esm.js +19401 -3725
- package/dist/extensions/guided-lab.js +19400 -3724
- package/dist/extensions/python.d.ts +1 -0
- package/dist/extensions/python.esm.js +19666 -3843
- package/dist/extensions/python.js +19668 -3845
- package/dist/extensions/umbrella.d.ts +5 -0
- package/dist/index.d.ts +1 -1
- package/dist/modular-kernel.d.ts +11 -0
- package/dist/packages/commands/src/index.d.ts +96 -0
- package/dist/packages/core/src/di.d.ts +36 -0
- package/dist/packages/core/src/disposable.d.ts +27 -0
- package/dist/packages/core/src/errors.d.ts +69 -0
- package/dist/packages/core/src/events.d.ts +38 -0
- package/dist/packages/core/src/index.d.ts +6 -0
- package/dist/packages/core/src/path.d.ts +14 -0
- package/dist/packages/core/src/registry.d.ts +23 -0
- package/dist/packages/editor/src/index.d.ts +118 -0
- package/dist/packages/fs/src/backends.d.ts +37 -0
- package/dist/packages/fs/src/index.d.ts +3 -0
- package/dist/packages/fs/src/types.d.ts +40 -0
- package/dist/packages/fs/src/vfs-service.d.ts +33 -0
- package/dist/packages/preview/src/index.d.ts +34 -0
- package/dist/packages/runtime/src/index.d.ts +47 -0
- package/dist/packages/settings/src/builtin-schemas.d.ts +15 -0
- package/dist/packages/settings/src/configuration-service.d.ts +100 -0
- package/dist/packages/settings/src/index.d.ts +4 -0
- package/dist/packages/settings/src/jsonc.d.ts +20 -0
- package/dist/packages/settings/src/schema.d.ts +28 -0
- package/dist/packages/sql/src/completions.d.ts +8 -0
- package/dist/packages/sql/src/diagnostics.d.ts +2 -0
- package/dist/packages/sql/src/formatter.d.ts +2 -0
- package/dist/packages/sql/src/index.d.ts +7 -0
- package/dist/packages/sql/src/sql-editor.d.ts +2 -0
- package/dist/packages/sql/src/styles.d.ts +2 -0
- package/dist/packages/sql/src/tokenizer.d.ts +13 -0
- package/dist/packages/sql/src/types.d.ts +130 -0
- package/dist/packages/terminal/src/index.d.ts +54 -0
- package/dist/packages/ui/src/index.d.ts +4 -0
- package/dist/packages/ui/src/observability.d.ts +22 -0
- package/dist/packages/ui/src/plugin-registry.d.ts +89 -0
- package/dist/packages/ui/src/settings-dialog.d.ts +25 -0
- package/dist/packages/ui/src/themes.d.ts +35 -0
- package/dist/preview-sw.js +82 -24
- package/dist/runtime.d.ts +3 -3
- package/dist/runtime.esm.js +503 -73
- package/dist/runtime.js +501 -73
- package/dist/schemas.d.ts +234 -814
- package/dist/schemas.esm.js +19401 -3725
- package/dist/schemas.js +19404 -3728
- package/dist/scm.d.ts +13 -2
- package/dist/search.d.ts +5 -1
- package/dist/shell.d.ts +1 -1
- package/dist/shell.esm.js +435 -54
- package/dist/shell.js +435 -54
- package/dist/terminal.esm.js +242 -54
- package/dist/terminal.js +242 -54
- package/dist/workbench/diff-editor.d.ts +1 -0
- package/dist/workbench/index.d.ts +1 -1
- package/dist/workbench/styles.d.ts +1 -1
- package/dist/zip.d.ts +4 -3
- package/package.json +37 -8
- package/packages/commands/README.md +7 -0
- package/packages/commands/package.json +16 -0
- package/packages/commands/src/index.ts +467 -0
- package/packages/commands/tsconfig.json +22 -0
- package/packages/core/README.md +12 -0
- package/packages/core/package.json +13 -0
- package/packages/core/src/di.ts +147 -0
- package/packages/core/src/disposable.ts +112 -0
- package/packages/core/src/errors.ts +205 -0
- package/packages/core/src/events.ts +157 -0
- package/packages/core/src/index.ts +49 -0
- package/packages/core/src/path.ts +118 -0
- package/packages/core/src/registry.ts +61 -0
- package/packages/core/tsconfig.json +19 -0
- package/packages/editor/README.md +9 -0
- package/packages/editor/package.json +18 -0
- package/packages/editor/src/index.ts +344 -0
- package/packages/editor/tsconfig.json +24 -0
- package/packages/fs/README.md +7 -0
- package/packages/fs/package.json +16 -0
- package/packages/fs/src/backends.ts +301 -0
- package/packages/fs/src/index.ts +18 -0
- package/packages/fs/src/types.ts +44 -0
- package/packages/fs/src/vfs-service.ts +257 -0
- package/packages/fs/tsconfig.json +22 -0
- package/packages/preview/README.md +3 -0
- package/packages/preview/package.json +16 -0
- package/packages/preview/src/index.ts +125 -0
- package/packages/preview/tsconfig.json +22 -0
- package/packages/runtime/README.md +3 -0
- package/packages/runtime/package.json +17 -0
- package/packages/runtime/src/index.ts +134 -0
- package/packages/runtime/tsconfig.json +23 -0
- package/packages/settings/README.md +7 -0
- package/packages/settings/package.json +16 -0
- package/packages/settings/src/builtin-schemas.ts +235 -0
- package/packages/settings/src/configuration-service.ts +543 -0
- package/packages/settings/src/index.ts +37 -0
- package/packages/settings/src/jsonc.ts +189 -0
- package/packages/settings/src/schema.ts +164 -0
- package/packages/settings/tsconfig.json +22 -0
- package/packages/sql/README.md +12 -0
- package/packages/sql/package.json +13 -0
- package/packages/sql/src/completions.ts +359 -0
- package/packages/sql/src/diagnostics.ts +200 -0
- package/packages/sql/src/formatter.ts +271 -0
- package/packages/sql/src/index.ts +54 -0
- package/packages/sql/src/sql-editor.ts +802 -0
- package/packages/sql/src/styles.ts +501 -0
- package/packages/sql/src/tokenizer.ts +457 -0
- package/packages/sql/src/types.ts +148 -0
- package/packages/sql/tsconfig.json +19 -0
- package/packages/terminal/README.md +3 -0
- package/packages/terminal/package.json +16 -0
- package/packages/terminal/src/index.ts +183 -0
- package/packages/terminal/tsconfig.json +22 -0
- package/packages/ui/README.md +8 -0
- package/packages/ui/package.json +18 -0
- package/packages/ui/src/index.ts +36 -0
- package/packages/ui/src/observability.ts +175 -0
- package/packages/ui/src/plugin-registry.ts +274 -0
- package/packages/ui/src/settings-dialog.ts +293 -0
- package/packages/ui/src/themes.ts +174 -0
- package/packages/ui/tsconfig.json +24 -0
- package/src/code-lab.css +298 -2
- package/src/csp.ts +7 -10
- package/src/diagnostics.ts +42 -3
- package/src/extensions/cpp.ts +105 -24
- package/src/extensions/python.ts +260 -116
- package/src/extensions/umbrella.ts +5 -0
- package/src/index.ts +1 -1
- package/src/modular-kernel.ts +11 -0
- package/src/preview-sw.js +73 -12
- package/src/runtime.ts +501 -74
- package/src/schemas.ts +62 -62
- package/src/scm.ts +106 -19
- package/src/search.ts +71 -27
- package/src/shell.ts +433 -53
- package/src/terminal.ts +239 -52
- package/src/workbench/diff-editor.ts +106 -18
- package/src/workbench/drawer.ts +17 -4
- package/src/workbench/guided-pane.ts +12 -2
- package/src/workbench/icons.ts +5 -2
- package/src/workbench/share.ts +37 -8
- package/src/workbench/styles.ts +2 -1
- package/src/workbench/toolbar.ts +15 -4
- package/src/workbench.ts +2877 -284
- package/src/zip.ts +29 -7
- package/dist/runtime/index.d.ts +0 -4
- package/dist/shell/coreutils/compilers-cli.d.ts +0 -24
- package/dist/shell/index.d.ts +0 -4
- package/src/runtime/index.ts +0 -5
- package/src/shell/coreutils/compilers-cli.ts +0 -103
- package/src/shell/index.ts +0 -5
package/dist/terminal.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ============================================================
|
|
3
|
-
* @innovatorved/code-lab v0.
|
|
3
|
+
* @innovatorved/code-lab v0.4.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
|
|
7
7
|
* - First-Class Node.js and Bun Runtimes (Bun.serve, bun:test, bun:sqlite, Bun.*)
|
|
8
|
-
* - Full POSIX Shell AST &
|
|
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
|
|
@@ -87,6 +87,7 @@ var CodeLabLogger = (() => {
|
|
|
87
87
|
} catch (err) {
|
|
88
88
|
sinkError = err;
|
|
89
89
|
}
|
|
90
|
+
void sinkError;
|
|
90
91
|
}
|
|
91
92
|
const consoleObj = typeof console !== "undefined" ? console : null;
|
|
92
93
|
const fn = consoleObj ? consoleObj[level] : null;
|
|
@@ -423,6 +424,14 @@ var CodeLabLogger = (() => {
|
|
|
423
424
|
|
|
424
425
|
const parseAnsiToHtml = ansiToHtml;
|
|
425
426
|
|
|
427
|
+
const MAX_SCROLLBACK = 2000;
|
|
428
|
+
const VALID_LOG_TYPES = new Set(['stdout', 'stderr', 'system', 'info', 'warn', 'error', 'success']);
|
|
429
|
+
|
|
430
|
+
function sanitizeLogType(type) {
|
|
431
|
+
const t = String(type || 'stdout').trim();
|
|
432
|
+
return VALID_LOG_TYPES.has(t) ? t : 'stdout';
|
|
433
|
+
}
|
|
434
|
+
|
|
426
435
|
class PTYTerminalEngine {
|
|
427
436
|
constructor(container, options = {}) {
|
|
428
437
|
if (
|
|
@@ -437,6 +446,12 @@ var CodeLabLogger = (() => {
|
|
|
437
446
|
}
|
|
438
447
|
this.container = container || null;
|
|
439
448
|
this.options = options || {};
|
|
449
|
+
this.maxScrollback = typeof this.options.maxScrollback === 'number' && this.options.maxScrollback > 0
|
|
450
|
+
? this.options.maxScrollback
|
|
451
|
+
: MAX_SCROLLBACK;
|
|
452
|
+
this.maxHistory = typeof this.options.maxHistory === 'number' && this.options.maxHistory > 0
|
|
453
|
+
? this.options.maxHistory
|
|
454
|
+
: 1000;
|
|
440
455
|
this.logs = Array.isArray(this.options.logs) ? this.options.logs : [];
|
|
441
456
|
this.cwd = this.options.cwd || '/workspace';
|
|
442
457
|
this.replMode = Boolean(this.options.replMode);
|
|
@@ -450,6 +465,7 @@ var CodeLabLogger = (() => {
|
|
|
450
465
|
this.searchQuery = '';
|
|
451
466
|
this.searchMatchIdx = -1;
|
|
452
467
|
this._readLineQueue = [];
|
|
468
|
+
this.isBusy = false;
|
|
453
469
|
this.onCommand = typeof this.options.onCommand === 'function' ? this.options.onCommand : null;
|
|
454
470
|
this.getCompletions = typeof this.options.getCompletions === 'function' ? this.options.getCompletions : null;
|
|
455
471
|
this.onKey = typeof this.options.onKey === 'function' ? this.options.onKey : null;
|
|
@@ -600,13 +616,40 @@ var CodeLabLogger = (() => {
|
|
|
600
616
|
this.writeStreamChunk(String(data) + '\n', type);
|
|
601
617
|
}
|
|
602
618
|
|
|
619
|
+
isCommandRunning() {
|
|
620
|
+
return Boolean(this.isBusy && (!this._readLineQueue || this._readLineQueue.length === 0));
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
_pushLog(entry) {
|
|
624
|
+
const normalized = {
|
|
625
|
+
type: sanitizeLogType(entry && entry.type),
|
|
626
|
+
text: String(entry && entry.text != null ? entry.text : '')
|
|
627
|
+
};
|
|
628
|
+
this.logs.push(normalized);
|
|
629
|
+
if (this.logs.length > this.maxScrollback) {
|
|
630
|
+
const excess = this.logs.length - this.maxScrollback;
|
|
631
|
+
this.logs.splice(0, excess);
|
|
632
|
+
if (this._targetLineIdx >= 0) {
|
|
633
|
+
this._targetLineIdx = Math.max(0, this._targetLineIdx - excess);
|
|
634
|
+
}
|
|
635
|
+
if (this.container && typeof this.container.querySelector === 'function') {
|
|
636
|
+
const logEl = this.container.querySelector('#cl-terminal-log');
|
|
637
|
+
if (logEl && logEl.children && logEl.children.length > this.maxScrollback) {
|
|
638
|
+
while (logEl.children.length > this.maxScrollback && typeof logEl.removeChild === 'function' && logEl.firstChild) {
|
|
639
|
+
logEl.removeChild(logEl.firstChild);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
return normalized;
|
|
645
|
+
}
|
|
646
|
+
|
|
603
647
|
_getActiveLine(type) {
|
|
604
648
|
if (this._targetLineIdx >= 0 && this._targetLineIdx < this.logs.length) {
|
|
605
649
|
return this.logs[this._targetLineIdx];
|
|
606
650
|
}
|
|
607
651
|
if (this._activeLineCommitted || this.logs.length === 0) {
|
|
608
|
-
const newLine = { text: '', type };
|
|
609
|
-
this.logs.push(newLine);
|
|
652
|
+
const newLine = this._pushLog({ text: '', type });
|
|
610
653
|
this._activeLineCommitted = false;
|
|
611
654
|
this._cursorCol = 0;
|
|
612
655
|
this._targetLineIdx = this.logs.length - 1;
|
|
@@ -623,7 +666,7 @@ var CodeLabLogger = (() => {
|
|
|
623
666
|
const logEl = this.container.querySelector('#cl-terminal-log');
|
|
624
667
|
if (!logEl) return;
|
|
625
668
|
const lineEl = document.createElement('div');
|
|
626
|
-
lineEl.className = 'codelab-log-line ' + (line.type
|
|
669
|
+
lineEl.className = 'codelab-log-line ' + sanitizeLogType(line.type);
|
|
627
670
|
lineEl.innerHTML = ansiToHtml(line.text);
|
|
628
671
|
logEl.appendChild(lineEl);
|
|
629
672
|
this._activeLineEl = lineEl;
|
|
@@ -646,7 +689,7 @@ var CodeLabLogger = (() => {
|
|
|
646
689
|
}
|
|
647
690
|
}
|
|
648
691
|
if (lineEl) {
|
|
649
|
-
lineEl.className = 'codelab-log-line ' + (line.type
|
|
692
|
+
lineEl.className = 'codelab-log-line ' + sanitizeLogType(line.type);
|
|
650
693
|
lineEl.innerHTML = ansiToHtml(line.text);
|
|
651
694
|
}
|
|
652
695
|
}
|
|
@@ -685,17 +728,75 @@ var CodeLabLogger = (() => {
|
|
|
685
728
|
return [...this.history];
|
|
686
729
|
}
|
|
687
730
|
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
731
|
+
_activateNextReadLine() {
|
|
732
|
+
if (!this._readLineQueue || this._readLineQueue.length === 0) return;
|
|
733
|
+
const head = this._readLineQueue[0];
|
|
734
|
+
if (head && typeof head === 'object' && !head._activated) {
|
|
735
|
+
head._activated = true;
|
|
736
|
+
head.prevPrompt = this.promptOverride;
|
|
737
|
+
if (head.promptText) {
|
|
738
|
+
this.promptOverride = head.promptText;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
_drainReadLineQueue(result = null) {
|
|
744
|
+
if (!Array.isArray(this._readLineQueue) || this._readLineQueue.length === 0) return;
|
|
745
|
+
const queued = this._readLineQueue.splice(0, this._readLineQueue.length);
|
|
746
|
+
let restoredPrompt = undefined;
|
|
747
|
+
for (const entry of queued) {
|
|
748
|
+
if (entry && typeof entry === 'object' && entry._activated && restoredPrompt === undefined) {
|
|
749
|
+
restoredPrompt = entry.prevPrompt;
|
|
750
|
+
}
|
|
751
|
+
if (entry && typeof entry.cleanup === 'function') {
|
|
752
|
+
entry.cleanup();
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
if (restoredPrompt !== undefined) {
|
|
756
|
+
this.promptOverride = restoredPrompt;
|
|
757
|
+
}
|
|
758
|
+
for (const entry of queued) {
|
|
759
|
+
if (typeof entry === 'function') {
|
|
760
|
+
try { entry(result); } catch (err) { _terminalLogger.debug('readLine callback threw during drain.', err); }
|
|
761
|
+
} else if (entry && typeof entry.resolve === 'function') {
|
|
762
|
+
try { entry.resolve(result); } catch (err) { _terminalLogger.debug('readLine resolve threw during drain.', err); }
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
readLine(promptText = '', options = {}) {
|
|
768
|
+
if (options && options.signal && options.signal.aborted) {
|
|
769
|
+
return Promise.resolve(null);
|
|
692
770
|
}
|
|
693
771
|
return new Promise((resolve) => {
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
772
|
+
const item = {
|
|
773
|
+
promptText: String(promptText || ''),
|
|
774
|
+
prevPrompt: null,
|
|
775
|
+
_activated: false,
|
|
776
|
+
cleanup: null,
|
|
777
|
+
resolve
|
|
778
|
+
};
|
|
779
|
+
if (options && options.signal && typeof options.signal.addEventListener === 'function') {
|
|
780
|
+
const onAbort = () => {
|
|
781
|
+
const idx = this._readLineQueue.indexOf(item);
|
|
782
|
+
if (idx !== -1) {
|
|
783
|
+
this._readLineQueue.splice(idx, 1);
|
|
784
|
+
if (item._activated) {
|
|
785
|
+
this.promptOverride = item.prevPrompt;
|
|
786
|
+
this._activateNextReadLine();
|
|
787
|
+
}
|
|
788
|
+
this.updateActiveLine();
|
|
789
|
+
resolve(null);
|
|
790
|
+
}
|
|
791
|
+
};
|
|
792
|
+
options.signal.addEventListener('abort', onAbort, { once: true });
|
|
793
|
+
item.cleanup = () => {
|
|
794
|
+
try { options.signal.removeEventListener('abort', onAbort); } catch (err) { _terminalLogger.debug('readLine abort listener cleanup failed.', err); }
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
this._readLineQueue.push(item);
|
|
798
|
+
this._activateNextReadLine();
|
|
799
|
+
this.updateActiveLine();
|
|
699
800
|
});
|
|
700
801
|
}
|
|
701
802
|
|
|
@@ -736,6 +837,7 @@ var CodeLabLogger = (() => {
|
|
|
736
837
|
}
|
|
737
838
|
|
|
738
839
|
destroy() {
|
|
840
|
+
this._drainReadLineQueue(null);
|
|
739
841
|
this._cleanupListeners();
|
|
740
842
|
this._mounted = false;
|
|
741
843
|
}
|
|
@@ -765,6 +867,10 @@ var CodeLabLogger = (() => {
|
|
|
765
867
|
if (input) {
|
|
766
868
|
this._addListener(input, 'keydown', (e) => this.handleKeyDown(e));
|
|
767
869
|
this._addListener(input, 'input', () => {
|
|
870
|
+
if (this.isCommandRunning()) {
|
|
871
|
+
input.value = '';
|
|
872
|
+
return;
|
|
873
|
+
}
|
|
768
874
|
if (input.value !== this.buffer) {
|
|
769
875
|
this.buffer = input.value;
|
|
770
876
|
this.cursor = typeof input.selectionStart === 'number' ? input.selectionStart : this.buffer.length;
|
|
@@ -806,6 +912,36 @@ var CodeLabLogger = (() => {
|
|
|
806
912
|
const key = e.key;
|
|
807
913
|
const isCtrl = Boolean(e.ctrlKey || e.metaKey);
|
|
808
914
|
|
|
915
|
+
if (isCtrl && (key === 'l' || key === 'L')) {
|
|
916
|
+
if (e.preventDefault) e.preventDefault();
|
|
917
|
+
this.clear();
|
|
918
|
+
return;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
if (isCtrl && (key === 'c' || key === 'C')) {
|
|
922
|
+
if (e.preventDefault) e.preventDefault();
|
|
923
|
+
const wasBusy = this.isBusy || (this._readLineQueue && this._readLineQueue.length > 0);
|
|
924
|
+
this.isBusy = false;
|
|
925
|
+
this._pushLog({ type: 'system', text: wasBusy ? '^C' : `${this.getPrompt()}${this.buffer}^C` });
|
|
926
|
+
this.buffer = '';
|
|
927
|
+
this.cursor = 0;
|
|
928
|
+
this.historyIdx = -1;
|
|
929
|
+
this._drainReadLineQueue(null);
|
|
930
|
+
if (this.replMode) {
|
|
931
|
+
this.replMode = false;
|
|
932
|
+
}
|
|
933
|
+
if (this.onInterrupt) {
|
|
934
|
+
try { this.onInterrupt(); } catch (err) { _terminalLogger.warn('Terminal onInterrupt callback threw.', err); }
|
|
935
|
+
}
|
|
936
|
+
this.render();
|
|
937
|
+
return;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
if (this.isCommandRunning()) {
|
|
941
|
+
if (e.preventDefault) e.preventDefault();
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
|
|
809
945
|
if (isCtrl && (key === 'r' || key === 'R')) {
|
|
810
946
|
if (e.preventDefault) e.preventDefault();
|
|
811
947
|
if (!this.searchMode) {
|
|
@@ -937,33 +1073,11 @@ var CodeLabLogger = (() => {
|
|
|
937
1073
|
return;
|
|
938
1074
|
}
|
|
939
1075
|
|
|
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
1076
|
if (isCtrl && (key === 'd' || key === 'D')) {
|
|
963
1077
|
if (this.buffer === '') {
|
|
964
1078
|
if (e.preventDefault) e.preventDefault();
|
|
965
1079
|
if (this.replMode) {
|
|
966
|
-
this.
|
|
1080
|
+
this._pushLog({ type: 'system', text: `${this.getPrompt()}.exit` });
|
|
967
1081
|
this.replMode = false;
|
|
968
1082
|
this.render();
|
|
969
1083
|
return;
|
|
@@ -1057,14 +1171,44 @@ var CodeLabLogger = (() => {
|
|
|
1057
1171
|
}
|
|
1058
1172
|
|
|
1059
1173
|
// Print candidate matches
|
|
1060
|
-
this.
|
|
1061
|
-
this.
|
|
1174
|
+
this._pushLog({ type: 'system', text: `${this.getPrompt()}${this.buffer}` });
|
|
1175
|
+
this._pushLog({ type: 'stdout', text: matches.join(' ') });
|
|
1062
1176
|
this.render();
|
|
1063
1177
|
}
|
|
1064
1178
|
}
|
|
1065
1179
|
|
|
1066
1180
|
submitLine() {
|
|
1181
|
+
if (this._readLineQueue && this._readLineQueue.length > 0) {
|
|
1182
|
+
const line = this.buffer;
|
|
1183
|
+
this.buffer = '';
|
|
1184
|
+
this.cursor = 0;
|
|
1185
|
+
this.historyIdx = -1;
|
|
1186
|
+
this.searchMode = false;
|
|
1187
|
+
this.searchQuery = '';
|
|
1188
|
+
this.searchMatchIdx = -1;
|
|
1189
|
+
|
|
1190
|
+
const entry = this._readLineQueue.shift();
|
|
1191
|
+
if (entry && typeof entry.cleanup === 'function') {
|
|
1192
|
+
entry.cleanup();
|
|
1193
|
+
}
|
|
1194
|
+
if (typeof entry === 'function') {
|
|
1195
|
+
this.updateActiveLine();
|
|
1196
|
+
entry(line);
|
|
1197
|
+
} else if (entry && typeof entry.resolve === 'function') {
|
|
1198
|
+
this.promptOverride = entry.prevPrompt;
|
|
1199
|
+
this._activateNextReadLine();
|
|
1200
|
+
this.updateActiveLine();
|
|
1201
|
+
entry.resolve(line);
|
|
1202
|
+
}
|
|
1203
|
+
return;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
if (this.isBusy) {
|
|
1207
|
+
return;
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1067
1210
|
const line = this.buffer;
|
|
1211
|
+
const promptSnap = this.getPrompt();
|
|
1068
1212
|
this.buffer = '';
|
|
1069
1213
|
this.cursor = 0;
|
|
1070
1214
|
this.historyIdx = -1;
|
|
@@ -1072,22 +1216,53 @@ var CodeLabLogger = (() => {
|
|
|
1072
1216
|
this.searchQuery = '';
|
|
1073
1217
|
this.searchMatchIdx = -1;
|
|
1074
1218
|
|
|
1219
|
+
const echoed = this._pushLog({ type: 'system', text: `${promptSnap}${line}` });
|
|
1220
|
+
this._activeLineCommitted = true;
|
|
1221
|
+
this._cursorCol = 0;
|
|
1222
|
+
this._targetLineIdx = -1;
|
|
1223
|
+
this._needsRewrite = false;
|
|
1224
|
+
this._appendDomLine(echoed);
|
|
1225
|
+
this._activeLineEl = null;
|
|
1226
|
+
|
|
1075
1227
|
if (line.trim()) {
|
|
1076
1228
|
if (this.history[this.history.length - 1] !== line.trim()) {
|
|
1077
1229
|
this.history.push(line.trim());
|
|
1230
|
+
const maxHist = typeof this.maxHistory === 'number' && this.maxHistory > 0 ? this.maxHistory : 1000;
|
|
1231
|
+
if (this.history.length > maxHist) {
|
|
1232
|
+
this.history.splice(0, this.history.length - maxHist);
|
|
1233
|
+
}
|
|
1078
1234
|
}
|
|
1079
1235
|
}
|
|
1080
1236
|
|
|
1081
|
-
if (this.
|
|
1082
|
-
const resolver = this._readLineQueue.shift();
|
|
1237
|
+
if (!this.onCommand) {
|
|
1083
1238
|
this.updateActiveLine();
|
|
1084
|
-
resolver(line);
|
|
1085
1239
|
return;
|
|
1086
1240
|
}
|
|
1087
1241
|
|
|
1242
|
+
this.isBusy = true;
|
|
1088
1243
|
this.updateActiveLine();
|
|
1089
|
-
|
|
1090
|
-
|
|
1244
|
+
|
|
1245
|
+
let cmdResult;
|
|
1246
|
+
try {
|
|
1247
|
+
cmdResult = this.onCommand(line);
|
|
1248
|
+
} catch (err) {
|
|
1249
|
+
this.isBusy = false;
|
|
1250
|
+
this.updateActiveLine();
|
|
1251
|
+
throw err;
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
if (cmdResult && typeof cmdResult.then === 'function') {
|
|
1255
|
+
Promise.resolve(cmdResult)
|
|
1256
|
+
.catch((err) => {
|
|
1257
|
+
_terminalLogger.debug('Terminal onCommand promise rejected.', err);
|
|
1258
|
+
})
|
|
1259
|
+
.finally(() => {
|
|
1260
|
+
this.isBusy = false;
|
|
1261
|
+
this.updateActiveLine();
|
|
1262
|
+
});
|
|
1263
|
+
} else {
|
|
1264
|
+
this.isBusy = false;
|
|
1265
|
+
this.updateActiveLine();
|
|
1091
1266
|
}
|
|
1092
1267
|
}
|
|
1093
1268
|
|
|
@@ -1100,6 +1275,16 @@ var CodeLabLogger = (() => {
|
|
|
1100
1275
|
const lineEl = this.container.querySelector('#cl-pty-active-line');
|
|
1101
1276
|
if (!lineEl) return;
|
|
1102
1277
|
|
|
1278
|
+
if (this.isCommandRunning()) {
|
|
1279
|
+
if (typeof lineEl.setAttribute === 'function') lineEl.setAttribute('data-busy', 'true');
|
|
1280
|
+
if (lineEl.style) lineEl.style.display = 'none';
|
|
1281
|
+
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>`;
|
|
1282
|
+
return;
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
if (typeof lineEl.removeAttribute === 'function') lineEl.removeAttribute('data-busy');
|
|
1286
|
+
if (lineEl.style) lineEl.style.display = '';
|
|
1287
|
+
|
|
1103
1288
|
const prompt = this.searchMode
|
|
1104
1289
|
? `(reverse-i-search)\`${this.searchQuery}\`: `
|
|
1105
1290
|
: this.getPrompt();
|
|
@@ -1120,21 +1305,24 @@ var CodeLabLogger = (() => {
|
|
|
1120
1305
|
);
|
|
1121
1306
|
|
|
1122
1307
|
const logsHtml = this.logs
|
|
1123
|
-
.map(item => `<div class="codelab-log-line ${
|
|
1308
|
+
.map(item => `<div class="codelab-log-line ${sanitizeLogType(item.type)}">${ansiToHtml(item.text)}</div>`)
|
|
1124
1309
|
.join('');
|
|
1125
1310
|
|
|
1126
|
-
const
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
const
|
|
1131
|
-
const
|
|
1311
|
+
const busy = this.isCommandRunning();
|
|
1312
|
+
const prompt = busy
|
|
1313
|
+
? ''
|
|
1314
|
+
: (this.searchMode ? `(reverse-i-search)\`${this.searchQuery}\`: ` : this.getPrompt());
|
|
1315
|
+
const before = busy ? '' : this.buffer.slice(0, this.cursor);
|
|
1316
|
+
const cursorChar = busy ? '' : (this.cursor < this.buffer.length ? this.buffer[this.cursor] : ' ');
|
|
1317
|
+
const after = busy ? '' : (this.cursor < this.buffer.length ? this.buffer.slice(this.cursor + 1) : '');
|
|
1318
|
+
const busyAttr = busy ? ' data-busy="true" style="display:none;"' : '';
|
|
1319
|
+
const cursorClass = busy ? 'codelab-pty__cursor' : 'codelab-pty__cursor blink';
|
|
1132
1320
|
|
|
1133
1321
|
this.container.innerHTML = `
|
|
1134
1322
|
<div class="codelab-terminal" id="cl-terminal-surface" tabindex="0">
|
|
1135
1323
|
<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="
|
|
1324
|
+
<div class="codelab-pty__active-line" id="cl-pty-active-line"${busyAttr}>
|
|
1325
|
+
<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
1326
|
</div>
|
|
1139
1327
|
<form class="codelab-repl" id="cl-repl-form" style="position:absolute;opacity:0;pointer-events:none;height:0;overflow:hidden;">
|
|
1140
1328
|
<input type="text" class="codelab-repl__input" id="cl-repl-input" autocomplete="off" spellcheck="false" aria-label="Terminal command input" value="${escapeHtml(this.buffer)}">
|
|
@@ -22,5 +22,6 @@ export declare class CodeLabDiffEditorManager {
|
|
|
22
22
|
currentTarget: 'starter' | 'solution';
|
|
23
23
|
constructor(workbench: any);
|
|
24
24
|
openInlineDiff(file: string, target?: 'starter' | 'solution'): boolean;
|
|
25
|
+
syncFileToWorkbench(file: string, nextVal: string): void;
|
|
25
26
|
closeInlineDiff(): void;
|
|
26
27
|
}
|
|
@@ -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>):
|
|
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):
|
|
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,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@innovatorved/code-lab",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Modular browser-native IDE Workbench, Lightweight SQL Playground & Inline Editor (@innovatorved/code-lab/sql), POSIX Shell & Coreutils, PTY Terminal, Web Worker Node.js/Bun Virtual Runtime, C++20 WASI, and Python 3.12 Extension.",
|
|
5
|
+
"workspaces": [
|
|
6
|
+
"packages/*",
|
|
7
|
+
"apps/*"
|
|
8
|
+
],
|
|
5
9
|
"main": "./dist/code-lab.js",
|
|
6
10
|
"module": "./dist/code-lab.esm.js",
|
|
11
|
+
"umd": "./dist/code-lab.umd.js",
|
|
7
12
|
"types": "./dist/code-lab.d.ts",
|
|
8
13
|
"style": "./dist/code-lab.css",
|
|
9
14
|
"exports": {
|
|
@@ -13,6 +18,16 @@
|
|
|
13
18
|
"require": "./dist/code-lab.js",
|
|
14
19
|
"default": "./dist/code-lab.js"
|
|
15
20
|
},
|
|
21
|
+
"./umd": "./dist/code-lab.umd.js",
|
|
22
|
+
"./sql": {
|
|
23
|
+
"types": "./dist/code-lab-sql.d.ts",
|
|
24
|
+
"import": "./dist/code-lab-sql.esm.js",
|
|
25
|
+
"require": "./dist/code-lab-sql.umd.js",
|
|
26
|
+
"default": "./dist/code-lab-sql.umd.js"
|
|
27
|
+
},
|
|
28
|
+
"./sql.css": "./dist/code-lab-sql.css",
|
|
29
|
+
"./code-lab-sql.css": "./dist/code-lab-sql.css",
|
|
30
|
+
"./dist/code-lab-sql.css": "./dist/code-lab-sql.css",
|
|
16
31
|
"./runtime": {
|
|
17
32
|
"types": "./dist/runtime.d.ts",
|
|
18
33
|
"import": "./dist/runtime.esm.js",
|
|
@@ -80,6 +95,7 @@
|
|
|
80
95
|
"files": [
|
|
81
96
|
"dist",
|
|
82
97
|
"src",
|
|
98
|
+
"packages",
|
|
83
99
|
"README.md",
|
|
84
100
|
"ARCHITECTURE.md",
|
|
85
101
|
"CHANGELOG.md",
|
|
@@ -97,6 +113,8 @@
|
|
|
97
113
|
"scripts": {
|
|
98
114
|
"build": "bun run tools/bundle.js",
|
|
99
115
|
"lint": "node tools/lint.js",
|
|
116
|
+
"check:boundaries": "node tools/check-boundaries.js",
|
|
117
|
+
"check:size": "node tools/check-bundle-size.js",
|
|
100
118
|
"typecheck": "bun x tsc --noEmit",
|
|
101
119
|
"typecheck:strict": "bun x tsc -p tsconfig.strict.json",
|
|
102
120
|
"test": "bun run tools/bundle.js && bun run tests/run-all.js",
|
|
@@ -106,16 +124,23 @@
|
|
|
106
124
|
"test:browser": "bunx playwright test --project=chromium",
|
|
107
125
|
"test:browser:all": "bunx playwright test",
|
|
108
126
|
"test:browser:install": "bunx playwright install --with-deps chromium firefox webkit",
|
|
109
|
-
"pack:check": "bun pm pack --dry-run"
|
|
127
|
+
"pack:check": "bun pm pack --dry-run",
|
|
128
|
+
"prepublishOnly": "bun run build && node tests/test-esm-exports.js && node tests/test-version-sync.js"
|
|
129
|
+
},
|
|
130
|
+
"lint-staged": {
|
|
131
|
+
"*.{ts,js}": [
|
|
132
|
+
"node tools/lint.js",
|
|
133
|
+
"node tools/check-boundaries.js"
|
|
134
|
+
]
|
|
110
135
|
},
|
|
111
136
|
"dependencies": {
|
|
112
|
-
"zod": "^
|
|
137
|
+
"zod": "^4.6.7"
|
|
113
138
|
},
|
|
114
139
|
"devDependencies": {
|
|
115
|
-
"@playwright/test": "^1.
|
|
116
|
-
"@types/node": "
|
|
117
|
-
"esbuild": "^0.
|
|
118
|
-
"typescript": "
|
|
140
|
+
"@playwright/test": "^1.65.0",
|
|
141
|
+
"@types/node": "26.6.6",
|
|
142
|
+
"esbuild": "^0.28.2",
|
|
143
|
+
"typescript": "6.0.3"
|
|
119
144
|
},
|
|
120
145
|
"publishConfig": {
|
|
121
146
|
"access": "public",
|
|
@@ -123,6 +148,10 @@
|
|
|
123
148
|
},
|
|
124
149
|
"keywords": [
|
|
125
150
|
"ide",
|
|
151
|
+
"sql-editor",
|
|
152
|
+
"sql-playground",
|
|
153
|
+
"postgres",
|
|
154
|
+
"sqlite",
|
|
126
155
|
"code-playground",
|
|
127
156
|
"monaco-editor",
|
|
128
157
|
"virtual-runtime",
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# `@code-lab/commands`
|
|
2
|
+
|
|
3
|
+
Layer 1 (`platform`) command execution, `when`-clause context evaluation, and customizable keybinding dispatch:
|
|
4
|
+
|
|
5
|
+
- `ContextKeyService` — evaluates VS Code-style `when` expressions (`editorFocus && !editorReadonly && resourceLangId == 'sql'`).
|
|
6
|
+
- `CommandRegistry` — registers typed commands (`registerCommand` -> `IDisposable`) and dispatches `executeCommand`.
|
|
7
|
+
- `KeybindingService` — normalizes cross-platform `Mod`/`Cmd`/`Ctrl` chords, supports `.codelab/keybindings.json` overrides and `-command` unbinding rules.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@code-lab/commands",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "CommandRegistry, VS Code-style ContextKeyService (when-clause evaluator), and KeybindingService for CodeLab.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./src/index.ts",
|
|
7
|
+
"types": "./src/index.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./src/index.ts"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@code-lab/core": "workspace:*"
|
|
13
|
+
},
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"license": "MIT"
|
|
16
|
+
}
|