@innovatorved/code-lab 0.5.0 → 0.6.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 +3 -3
- package/CHANGELOG.md +15 -0
- package/README.md +3 -3
- package/dist/code-lab-sql.esm.js +1 -1
- package/dist/code-lab-sql.umd.js +2 -2
- package/dist/code-lab.css +32 -7273
- package/dist/code-lab.d.ts +1 -1
- package/dist/code-lab.esm.js +4669 -74678
- package/dist/code-lab.js +4655 -74665
- package/dist/code-lab.umd.js +4655 -74665
- package/dist/extensions/cpp.d.ts +2 -2
- package/dist/extensions/cpp.esm.js +1788 -14707
- package/dist/extensions/cpp.js +1788 -14707
- package/dist/extensions/guided-lab.esm.js +2938 -16127
- package/dist/extensions/guided-lab.js +2938 -16127
- package/dist/extensions/python.d.ts +2 -2
- package/dist/extensions/python.esm.js +1769 -14701
- package/dist/extensions/python.js +1769 -14701
- package/dist/index.d.ts +1 -1
- package/dist/preview-sw.js +4 -188
- package/dist/runtime.esm.js +109 -10284
- package/dist/runtime.js +107 -10284
- package/dist/schemas.d.ts +2 -2
- package/dist/schemas.esm.js +2938 -16127
- package/dist/schemas.js +2941 -16130
- package/dist/scm.d.ts +221 -20
- package/dist/shell.esm.js +811 -10002
- package/dist/shell.js +811 -10002
- package/dist/storage.d.ts +9 -0
- package/dist/terminal.esm.js +20 -1347
- package/dist/terminal.js +20 -1347
- package/dist/workbench/command-palette.d.ts +16 -1
- package/dist/workbench/diff-editor.d.ts +27 -1
- package/dist/workbench/icons.d.ts +6 -2
- package/dist/workbench/index.d.ts +32 -0
- package/dist/workbench/intellisense.d.ts +194 -0
- package/dist/workbench/xterm-adapter.d.ts +122 -0
- package/package.json +7 -1
- package/packages/commands/package.json +1 -1
- package/packages/core/package.json +1 -1
- package/packages/editor/package.json +1 -1
- package/packages/fs/package.json +1 -1
- package/packages/preview/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/settings/package.json +1 -1
- package/packages/sql/package.json +1 -1
- package/packages/terminal/package.json +1 -1
- package/packages/ui/package.json +1 -1
- package/packages/ui/src/settings-dialog.ts +36 -24
- package/packages/ui/src/themes.ts +89 -23
- package/src/code-lab.css +1345 -481
- package/src/extensions/cpp.ts +304 -38
- package/src/extensions/python.ts +342 -43
- package/src/index.ts +1 -1
- package/src/runtime.ts +272 -43
- package/src/schemas.ts +2 -2
- package/src/scm.ts +1467 -92
- package/src/shell.ts +1075 -93
- package/src/storage.ts +66 -3
- package/src/terminal.ts +148 -12
- package/src/workbench/command-palette.ts +289 -48
- package/src/workbench/diff-editor.ts +240 -78
- package/src/workbench/icons.ts +250 -53
- package/src/workbench/index.ts +7 -1
- package/src/workbench/intellisense.ts +1859 -0
- package/src/workbench/xterm-adapter.ts +1566 -0
- package/src/workbench.ts +1605 -236
package/src/workbench.ts
CHANGED
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
|
|
84
84
|
// The bundler rewrites this literal from package.json at build time. Keeping
|
|
85
85
|
// the fallback in sync lets tests require src/workbench.js directly.
|
|
86
|
-
const CODELAB_VERSION = '0.
|
|
86
|
+
const CODELAB_VERSION = '0.6.0';
|
|
87
87
|
|
|
88
88
|
// Ambient TypeScript declarations for Node.js built-ins inside Monaco
|
|
89
89
|
const NODE_AMBIENT_DTS = `
|
|
@@ -1078,25 +1078,35 @@ declare module 'bun:sqlite' {
|
|
|
1078
1078
|
}
|
|
1079
1079
|
});
|
|
1080
1080
|
|
|
1081
|
-
// Configure TS/JS defaults & ambient Node types
|
|
1081
|
+
// Configure TS/JS defaults, Modern themes & ambient Node types
|
|
1082
|
+
const wbComp = (root && root.CodeLabWorkbenchComponents) ||
|
|
1083
|
+
(typeof globalThis !== 'undefined' && globalThis.CodeLabWorkbenchComponents) ||
|
|
1084
|
+
null;
|
|
1085
|
+
if (wbComp && typeof wbComp.registerCodeLabMonacoThemes === 'function') {
|
|
1086
|
+
wbComp.registerCodeLabMonacoThemes(m);
|
|
1087
|
+
}
|
|
1082
1088
|
if (m.languages && m.languages.typescript) {
|
|
1083
1089
|
const tsDefaults = m.languages.typescript.typescriptDefaults;
|
|
1084
1090
|
const jsDefaults = m.languages.typescript.javascriptDefaults;
|
|
1085
1091
|
const compilerOpts = {
|
|
1086
|
-
target: m.languages.typescript.ScriptTarget.ES2020,
|
|
1087
|
-
module: m.languages.typescript.ModuleKind.CommonJS,
|
|
1092
|
+
target: m.languages.typescript.ScriptTarget.ESNext || m.languages.typescript.ScriptTarget.ES2020,
|
|
1093
|
+
module: m.languages.typescript.ModuleKind.ESNext || m.languages.typescript.ModuleKind.CommonJS,
|
|
1088
1094
|
moduleResolution: m.languages.typescript.ModuleResolutionKind.NodeJs,
|
|
1089
1095
|
allowNonTsExtensions: true,
|
|
1090
1096
|
allowJs: true,
|
|
1091
1097
|
checkJs: false,
|
|
1092
1098
|
strict: false,
|
|
1093
1099
|
noEmit: true,
|
|
1094
|
-
esModuleInterop: true
|
|
1100
|
+
esModuleInterop: true,
|
|
1101
|
+
allowSyntheticDefaultImports: true,
|
|
1102
|
+
resolveJsonModule: true
|
|
1095
1103
|
};
|
|
1096
1104
|
tsDefaults.setCompilerOptions(compilerOpts);
|
|
1097
1105
|
jsDefaults.setCompilerOptions(compilerOpts);
|
|
1106
|
+
if (typeof tsDefaults.setEagerModelSync === 'function') tsDefaults.setEagerModelSync(true);
|
|
1107
|
+
if (typeof jsDefaults.setEagerModelSync === 'function') jsDefaults.setEagerModelSync(true);
|
|
1098
1108
|
tsDefaults.setDiagnosticsOptions({ noSemanticValidation: false, noSyntaxValidation: false });
|
|
1099
|
-
jsDefaults.setDiagnosticsOptions({ noSemanticValidation:
|
|
1109
|
+
jsDefaults.setDiagnosticsOptions({ noSemanticValidation: false, noSyntaxValidation: false });
|
|
1100
1110
|
tsDefaults.addExtraLib(NODE_AMBIENT_DTS, 'file:///node-ambient.d.ts');
|
|
1101
1111
|
jsDefaults.addExtraLib(NODE_AMBIENT_DTS, 'file:///node-ambient.d.ts');
|
|
1102
1112
|
}
|
|
@@ -1269,7 +1279,12 @@ int main() {
|
|
|
1269
1279
|
'test.js': `'use strict';\nconst { describe, it } = require('node:test');\nconst assert = require('node:assert/strict');\nconst { solve } = require('./index.js');\n\ndescribe('Standalone Sandbox', () => {\n it('returns the input payload', () => {\n assert.deepEqual(solve({ a: 1 }), { a: 1 });\n });\n});\n`
|
|
1270
1280
|
};
|
|
1271
1281
|
|
|
1272
|
-
const
|
|
1282
|
+
const _wbComponents = (typeof CodeLabWorkbenchComponents !== 'undefined' && CodeLabWorkbenchComponents) ||
|
|
1283
|
+
(root && root.CodeLabWorkbenchComponents) ||
|
|
1284
|
+
(typeof globalThis !== 'undefined' && globalThis.CodeLabWorkbenchComponents) ||
|
|
1285
|
+
{};
|
|
1286
|
+
|
|
1287
|
+
const CL_ICONS = Object.assign({
|
|
1273
1288
|
arrowLeft: '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg>',
|
|
1274
1289
|
target: '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><circle cx="12" cy="12" r="6"/><circle cx="12" cy="12" r="2"/></svg>',
|
|
1275
1290
|
code: '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>',
|
|
@@ -1320,8 +1335,9 @@ int main() {
|
|
|
1320
1335
|
panelBottom: '<svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="3" y1="15" x2="21" y2="15"/></svg>',
|
|
1321
1336
|
chevronUp: '<svg aria-hidden="true" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="18 15 12 9 6 15"/></svg>',
|
|
1322
1337
|
collapseAll: '<svg aria-hidden="true" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="4" width="16" height="16" rx="2"/><line x1="8" y1="12" x2="16" y2="12"/></svg>',
|
|
1323
|
-
close: '<svg aria-hidden="true" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>'
|
|
1324
|
-
|
|
1338
|
+
close: '<svg aria-hidden="true" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',
|
|
1339
|
+
splitHorizontal: '<svg aria-hidden="true" width="14" height="14" viewBox="0 0 16 16" fill="currentColor"><path d="M14 1H3L2 2v11l1 1h11l1-1V2l-1-1zM8 13H3V2h5v11zm6 0H9V2h5v11z"/></svg>'
|
|
1340
|
+
}, (_wbComponents && _wbComponents.CL_ICONS) || {});
|
|
1325
1341
|
|
|
1326
1342
|
let _workbenchInstanceCounter = 0;
|
|
1327
1343
|
const _fallbackStorage = new Map();
|
|
@@ -1551,13 +1567,13 @@ int main() {
|
|
|
1551
1567
|
...(options.guided || {}),
|
|
1552
1568
|
...(options.starterFiles ? { starterFiles: options.starterFiles } : {}),
|
|
1553
1569
|
...(options.tsStarterFiles ? { tsStarterFiles: options.tsStarterFiles } : {}),
|
|
1554
|
-
...((options.tsSolutionFiles || options.tsFiles) ? { tsSolutionFiles: options.tsSolutionFiles || options.tsFiles } : {}),
|
|
1570
|
+
...((options.tsSolutionFiles || options.tsFiles || options.filesTs) ? { tsSolutionFiles: options.tsSolutionFiles || options.tsFiles || options.filesTs } : {}),
|
|
1555
1571
|
...(options.cppStarterFiles ? { cppStarterFiles: options.cppStarterFiles } : {}),
|
|
1556
|
-
...((options.cppSolutionFiles || options.cppFiles) ? { cppSolutionFiles: options.cppSolutionFiles || options.cppFiles } : {}),
|
|
1572
|
+
...((options.cppSolutionFiles || options.cppFiles || options.filesCpp) ? { cppSolutionFiles: options.cppSolutionFiles || options.cppFiles || options.filesCpp } : {}),
|
|
1557
1573
|
...(options.pyStarterFiles ? { pyStarterFiles: options.pyStarterFiles } : {}),
|
|
1558
|
-
...((options.pySolutionFiles || options.pyFiles) ? { pySolutionFiles: options.pySolutionFiles || options.pyFiles } : {}),
|
|
1574
|
+
...((options.pySolutionFiles || options.pyFiles || options.filesPy) ? { pySolutionFiles: options.pySolutionFiles || options.pyFiles || options.filesPy } : {}),
|
|
1559
1575
|
...(options.sqlStarterFiles ? { sqlStarterFiles: options.sqlStarterFiles } : {}),
|
|
1560
|
-
...((options.sqlSolutionFiles || options.sqlFiles) ? { sqlSolutionFiles: options.sqlSolutionFiles || options.sqlFiles } : {})
|
|
1576
|
+
...((options.sqlSolutionFiles || options.sqlFiles || options.filesSql) ? { sqlSolutionFiles: options.sqlSolutionFiles || options.sqlFiles || options.filesSql } : {})
|
|
1561
1577
|
};
|
|
1562
1578
|
this.steps = options.steps || this.guidedConfig?.steps || [];
|
|
1563
1579
|
this.hasGuidedLab = Boolean(
|
|
@@ -1684,7 +1700,9 @@ int main() {
|
|
|
1684
1700
|
: (typeof this.savedState?.sidebarVisible === 'boolean' ? this.savedState.sidebarVisible : true);
|
|
1685
1701
|
this.panelVisible = typeof options.panelVisible === 'boolean'
|
|
1686
1702
|
? options.panelVisible
|
|
1687
|
-
: (typeof
|
|
1703
|
+
: (typeof options.drawerCollapsed === 'boolean'
|
|
1704
|
+
? !options.drawerCollapsed
|
|
1705
|
+
: (typeof this.savedState?.panelVisible === 'boolean' ? this.savedState.panelVisible : true));
|
|
1688
1706
|
this.drawerCollapsed = !this.panelVisible;
|
|
1689
1707
|
this.panelHeight = (typeof this.savedState?.panelHeight === 'number' && this.savedState.panelHeight >= 100)
|
|
1690
1708
|
? this.savedState.panelHeight
|
|
@@ -2311,9 +2329,11 @@ int main() {
|
|
|
2311
2329
|
if (typeof createPosixShell === 'function') {
|
|
2312
2330
|
try {
|
|
2313
2331
|
this.shell = createPosixShell({
|
|
2332
|
+
instanceId: this.instanceId,
|
|
2314
2333
|
cwd: this.cwd,
|
|
2315
2334
|
files: this.files,
|
|
2316
2335
|
portTable: this.portTable,
|
|
2336
|
+
onRequestStdin: (promptText) => this._requestInteractiveTerminalStdin(promptText),
|
|
2317
2337
|
env: {
|
|
2318
2338
|
PWD: this.cwd || '/workspace',
|
|
2319
2339
|
TERM: 'xterm-256color',
|
|
@@ -2970,12 +2990,43 @@ int main() {
|
|
|
2970
2990
|
}
|
|
2971
2991
|
}
|
|
2972
2992
|
|
|
2993
|
+
_ensureSystemColorSchemeListener() {
|
|
2994
|
+
if (this._systemSchemeMedia || typeof window === 'undefined' || typeof window.matchMedia !== 'function') return;
|
|
2995
|
+
try {
|
|
2996
|
+
const mql = window.matchMedia('(prefers-color-scheme: dark)');
|
|
2997
|
+
if (!mql) return;
|
|
2998
|
+
const onChange = () => {
|
|
2999
|
+
if (this._destroyed) return;
|
|
3000
|
+
if (this.themeOption === 'auto') {
|
|
3001
|
+
this.setTheme('auto');
|
|
3002
|
+
}
|
|
3003
|
+
};
|
|
3004
|
+
if (typeof mql.addEventListener === 'function') {
|
|
3005
|
+
mql.addEventListener('change', onChange);
|
|
3006
|
+
this._systemSchemeCleanup = () => {
|
|
3007
|
+
try { mql.removeEventListener('change', onChange); } catch (_err) { void _err; }
|
|
3008
|
+
};
|
|
3009
|
+
} else if (typeof mql.addListener === 'function') {
|
|
3010
|
+
mql.addListener(onChange);
|
|
3011
|
+
this._systemSchemeCleanup = () => {
|
|
3012
|
+
try { mql.removeListener(onChange); } catch (_err) { void _err; }
|
|
3013
|
+
};
|
|
3014
|
+
}
|
|
3015
|
+
this._systemSchemeMedia = mql;
|
|
3016
|
+
} catch (_err) {
|
|
3017
|
+
void _err;
|
|
3018
|
+
}
|
|
3019
|
+
}
|
|
3020
|
+
|
|
2973
3021
|
setTheme(nextTheme) {
|
|
2974
3022
|
const normalized = (nextTheme === 'light' || nextTheme === 'dark' || nextTheme === 'high-contrast' || nextTheme === 'auto')
|
|
2975
3023
|
? nextTheme
|
|
2976
3024
|
: 'dark';
|
|
2977
3025
|
this.themeOption = normalized;
|
|
2978
3026
|
this.theme = normalized;
|
|
3027
|
+
if (normalized === 'auto') {
|
|
3028
|
+
this._ensureSystemColorSchemeListener();
|
|
3029
|
+
}
|
|
2979
3030
|
const resolved = this._resolvedTheme();
|
|
2980
3031
|
if (this.themes && typeof this.themes.setTheme === 'function' && !this._applyingThemeFromService) {
|
|
2981
3032
|
try {
|
|
@@ -2999,7 +3050,11 @@ int main() {
|
|
|
2999
3050
|
}
|
|
3000
3051
|
if (shellEl) {
|
|
3001
3052
|
shellEl.setAttribute('data-cl-theme', resolved);
|
|
3002
|
-
|
|
3053
|
+
const shouldSyncRootHtml = Boolean(
|
|
3054
|
+
(this.options && (this.options.fullbleed || this.options.syncDocumentTheme)) ||
|
|
3055
|
+
(typeof document !== 'undefined' && document.documentElement && typeof document.documentElement.hasAttribute === 'function' && document.documentElement.hasAttribute('data-theme'))
|
|
3056
|
+
);
|
|
3057
|
+
if (shouldSyncRootHtml && typeof document !== 'undefined' && document.documentElement && typeof document.documentElement.setAttribute === 'function') {
|
|
3003
3058
|
try {
|
|
3004
3059
|
document.documentElement.setAttribute('data-theme', resolved);
|
|
3005
3060
|
} catch (_err) {
|
|
@@ -3010,12 +3065,12 @@ int main() {
|
|
|
3010
3065
|
if (typeof shellEl.removeAttribute === 'function') shellEl.removeAttribute('data-theme');
|
|
3011
3066
|
} else {
|
|
3012
3067
|
shellEl.setAttribute('data-theme', normalized);
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3068
|
+
}
|
|
3069
|
+
if (this.themes && typeof this.themes.applyToElement === 'function' && shellEl.style && typeof shellEl.style.setProperty === 'function') {
|
|
3070
|
+
try {
|
|
3071
|
+
this.themes.applyToElement(shellEl);
|
|
3072
|
+
} catch (err) {
|
|
3073
|
+
this.logger.debug('themes.applyToElement failed.', err);
|
|
3019
3074
|
}
|
|
3020
3075
|
}
|
|
3021
3076
|
if (shellEl.style) {
|
|
@@ -3035,17 +3090,26 @@ int main() {
|
|
|
3035
3090
|
}
|
|
3036
3091
|
}
|
|
3037
3092
|
if (this.monaco && this.monaco.editor && typeof this.monaco.editor.setTheme === 'function') {
|
|
3038
|
-
const monacoTheme =
|
|
3039
|
-
?
|
|
3040
|
-
: resolved === '
|
|
3041
|
-
? 'codelab-
|
|
3042
|
-
: '
|
|
3093
|
+
const monacoTheme = (_wbComponents && typeof _wbComponents.getMonacoThemeName === 'function')
|
|
3094
|
+
? _wbComponents.getMonacoThemeName(resolved, this.monaco)
|
|
3095
|
+
: (resolved === 'light'
|
|
3096
|
+
? 'codelab-light'
|
|
3097
|
+
: resolved === 'high-contrast'
|
|
3098
|
+
? 'codelab-hc-dark'
|
|
3099
|
+
: 'codelab-dark');
|
|
3043
3100
|
try {
|
|
3044
3101
|
this.monaco.editor.setTheme(monacoTheme);
|
|
3045
3102
|
} catch (err) {
|
|
3046
3103
|
this.logger.debug('monaco.editor.setTheme failed.', err);
|
|
3047
3104
|
}
|
|
3048
3105
|
}
|
|
3106
|
+
if (this._xtermEngines instanceof Map) {
|
|
3107
|
+
for (const eng of this._xtermEngines.values()) {
|
|
3108
|
+
if (eng && typeof eng.setTheme === 'function') {
|
|
3109
|
+
try { eng.setTheme(resolved); } catch (_err) { void _err; }
|
|
3110
|
+
}
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3049
3113
|
if (this._sqlWorkbenchEditor && typeof this._sqlWorkbenchEditor.setTheme === 'function') {
|
|
3050
3114
|
try {
|
|
3051
3115
|
this._sqlWorkbenchEditor.setTheme(resolved === 'light' ? 'light' : 'dark');
|
|
@@ -3582,9 +3646,50 @@ int main() {
|
|
|
3582
3646
|
}
|
|
3583
3647
|
if (!this.activeFile && this.openTabs.length > 0) {
|
|
3584
3648
|
this.activeFile = this._pickDefaultFile() || this.openTabs[0];
|
|
3585
|
-
if (this.activeTab !== '__settings__') this.activeTab = this.activeFile;
|
|
3649
|
+
if (this.activeTab !== '__settings__' && this.activeTab !== '__welcome__') this.activeTab = this.activeFile;
|
|
3586
3650
|
}
|
|
3587
3651
|
this._syncFilesToShellVfs({ pruneExtraneous: forceHydrate });
|
|
3652
|
+
if (this.shell && this.shell.vfs && typeof this.shell.vfs.writeFileSync === 'function') {
|
|
3653
|
+
if (project.binaryFiles && typeof project.binaryFiles === 'object') {
|
|
3654
|
+
for (const [relBin, bytes] of Object.entries(project.binaryFiles)) {
|
|
3655
|
+
if (!relBin || !(bytes instanceof Uint8Array)) continue;
|
|
3656
|
+
try {
|
|
3657
|
+
const absBin = '/workspace/' + String(relBin).replace(/^\/+/, '');
|
|
3658
|
+
const parentBin = absBin.split('/').slice(0, -1).join('/');
|
|
3659
|
+
if (parentBin && typeof this.shell.vfs.mkdirSync === 'function') {
|
|
3660
|
+
this.shell.vfs.mkdirSync(parentBin, { recursive: true });
|
|
3661
|
+
}
|
|
3662
|
+
this.shell.vfs.writeFileSync(absBin, bytes);
|
|
3663
|
+
} catch (_err) { void _err; }
|
|
3664
|
+
}
|
|
3665
|
+
}
|
|
3666
|
+
if (project.gitFiles && typeof project.gitFiles === 'object') {
|
|
3667
|
+
for (const [relGit, bytes] of Object.entries(project.gitFiles)) {
|
|
3668
|
+
if (!relGit) continue;
|
|
3669
|
+
try {
|
|
3670
|
+
const absGit = '/workspace/.git/' + String(relGit).replace(/^(?:\.git\/|\/)+/, '');
|
|
3671
|
+
const parentGit = absGit.split('/').slice(0, -1).join('/');
|
|
3672
|
+
if (parentGit && typeof this.shell.vfs.mkdirSync === 'function') {
|
|
3673
|
+
this.shell.vfs.mkdirSync(parentGit, { recursive: true });
|
|
3674
|
+
}
|
|
3675
|
+
this.shell.vfs.writeFileSync(absGit, bytes instanceof Uint8Array ? bytes : String(bytes));
|
|
3676
|
+
} catch (_err) { void _err; }
|
|
3677
|
+
}
|
|
3678
|
+
}
|
|
3679
|
+
}
|
|
3680
|
+
if (project.gitMeta && typeof project.gitMeta === 'object' && typeof this._restoreSavedGitState === 'function') {
|
|
3681
|
+
this._restoreSavedGitState(project.gitMeta);
|
|
3682
|
+
} else if (project.gitFiles && root.CodeLabScm && typeof root.CodeLabScm.hydrateFromIsoGitRepo === 'function' && this.shell && this.shell.vfs) {
|
|
3683
|
+
const gs = this._getGitState();
|
|
3684
|
+
if (gs) {
|
|
3685
|
+
Promise.resolve(root.CodeLabScm.hydrateFromIsoGitRepo(this.shell.vfs, gs)).then((hydrated) => {
|
|
3686
|
+
if (hydrated && !this._destroyed) {
|
|
3687
|
+
if (this.activeSidebarView === 'scm') this._renderScmSidebar();
|
|
3688
|
+
this._updateStatusBar();
|
|
3689
|
+
}
|
|
3690
|
+
}).catch((_e) => { void _e; });
|
|
3691
|
+
}
|
|
3692
|
+
}
|
|
3588
3693
|
this._buildSavedStateSnapshot({ flushFiles: true });
|
|
3589
3694
|
this._syncAllModels();
|
|
3590
3695
|
this._syncDotCodelabConfig();
|
|
@@ -3663,12 +3768,52 @@ int main() {
|
|
|
3663
3768
|
const stateSnapshot = state;
|
|
3664
3769
|
const targetLabId = this.labId;
|
|
3665
3770
|
const targetTitle = this.title || this.labId;
|
|
3771
|
+
const binaryFilesSnapshot = {};
|
|
3772
|
+
const gitFilesSnapshot = {};
|
|
3773
|
+
if (this.shell && this.shell.vfs && typeof this.shell.vfs.readdirSync === 'function') {
|
|
3774
|
+
const collectRawDir = (dirPath, isGitTree) => {
|
|
3775
|
+
let entries = [];
|
|
3776
|
+
try { entries = this.shell.vfs.readdirSync(dirPath) || []; } catch (_e) { void _e; return; }
|
|
3777
|
+
for (const ent of entries) {
|
|
3778
|
+
const name = typeof ent === 'string' ? ent : (ent && ent.name ? ent.name : '');
|
|
3779
|
+
if (!name || name === '.' || name === '..' || name === 'node_modules') continue;
|
|
3780
|
+
const full = (dirPath === '/' ? '' : dirPath) + '/' + name;
|
|
3781
|
+
if (!isGitTree && name === '.git') {
|
|
3782
|
+
collectRawDir(full, true);
|
|
3783
|
+
continue;
|
|
3784
|
+
}
|
|
3785
|
+
let st = null;
|
|
3786
|
+
try { st = this.shell.vfs.statSync(full); } catch (_e) { void _e; }
|
|
3787
|
+
if (st && typeof st.isDirectory === 'function' && st.isDirectory()) {
|
|
3788
|
+
collectRawDir(full, isGitTree);
|
|
3789
|
+
} else {
|
|
3790
|
+
try {
|
|
3791
|
+
const rawBuf = this.shell.vfs.readFileSync(full);
|
|
3792
|
+
if (rawBuf instanceof Uint8Array) {
|
|
3793
|
+
if (isGitTree) {
|
|
3794
|
+
gitFilesSnapshot[full.slice('/workspace/.git/'.length)] = new Uint8Array(rawBuf);
|
|
3795
|
+
} else {
|
|
3796
|
+
const rel = full.slice('/workspace/'.length);
|
|
3797
|
+
if (!Object.prototype.hasOwnProperty.call(filesSnapshot, rel)) {
|
|
3798
|
+
binaryFilesSnapshot[rel] = new Uint8Array(rawBuf);
|
|
3799
|
+
}
|
|
3800
|
+
}
|
|
3801
|
+
}
|
|
3802
|
+
} catch (_e) { void _e; }
|
|
3803
|
+
}
|
|
3804
|
+
}
|
|
3805
|
+
};
|
|
3806
|
+
collectRawDir('/workspace', false);
|
|
3807
|
+
}
|
|
3666
3808
|
this._idbSaveChain = Promise.resolve(this._idbSaveChain).then(() => {
|
|
3667
3809
|
if (this._idbStorage && typeof this._idbStorage.saveProject === 'function') {
|
|
3668
3810
|
return this._idbStorage.saveProject({
|
|
3669
3811
|
id: targetLabId,
|
|
3670
3812
|
name: targetTitle,
|
|
3671
3813
|
files: filesSnapshot,
|
|
3814
|
+
binaryFiles: Object.keys(binaryFilesSnapshot).length > 0 ? binaryFilesSnapshot : undefined,
|
|
3815
|
+
gitFiles: Object.keys(gitFilesSnapshot).length > 0 ? gitFilesSnapshot : undefined,
|
|
3816
|
+
gitMeta: stateSnapshot && stateSnapshot.gitState ? stateSnapshot.gitState : undefined,
|
|
3672
3817
|
updatedAt: savedAt
|
|
3673
3818
|
});
|
|
3674
3819
|
}
|
|
@@ -3856,7 +4001,7 @@ int main() {
|
|
|
3856
4001
|
}
|
|
3857
4002
|
}
|
|
3858
4003
|
if (curEl) {
|
|
3859
|
-
const showCursor = Boolean(this.activeFile && this.openTabs && this.openTabs.length > 0 && this.activeTab !== '__settings__');
|
|
4004
|
+
const showCursor = Boolean(this.activeFile && this.openTabs && this.openTabs.length > 0 && this.activeTab !== '__settings__' && this.activeTab !== '__welcome__');
|
|
3860
4005
|
curEl.style.display = showCursor ? 'inline-flex' : 'none';
|
|
3861
4006
|
if (showCursor && this.cursorPos) {
|
|
3862
4007
|
curEl.textContent = `Ln ${this.cursorPos.lineNumber || 1}, Col ${this.cursorPos.column || 1}`;
|
|
@@ -3871,16 +4016,20 @@ int main() {
|
|
|
3871
4016
|
if (langEl) {
|
|
3872
4017
|
if (this.activeTab === '__settings__') {
|
|
3873
4018
|
langEl.textContent = 'Settings (UI)';
|
|
4019
|
+
} else if (this.activeTab === '__welcome__') {
|
|
4020
|
+
langEl.textContent = 'Welcome';
|
|
4021
|
+
} else if (this.lang === 'sql' || (this.activeFile && /\.sql$/i.test(this.activeFile))) {
|
|
4022
|
+
langEl.textContent = this.sqlDialect === 'sqlite' ? 'SQLite 3' : 'PostgreSQL 18';
|
|
4023
|
+
} else if (!this.hasGuidedLab && this.activeFile && _wbComponents && typeof _wbComponents.getLanguageDisplayLabel === 'function') {
|
|
4024
|
+
langEl.textContent = _wbComponents.getLanguageDisplayLabel(this.activeFile, this.lang);
|
|
3874
4025
|
} else {
|
|
3875
|
-
langEl.textContent = this.lang === '
|
|
3876
|
-
?
|
|
3877
|
-
: this.lang === '
|
|
3878
|
-
? '
|
|
3879
|
-
: this.lang === '
|
|
3880
|
-
? '
|
|
3881
|
-
:
|
|
3882
|
-
? 'TypeScript 5.x'
|
|
3883
|
-
: 'JavaScript (CJS/ESM)';
|
|
4026
|
+
langEl.textContent = this.lang === 'cpp'
|
|
4027
|
+
? 'C++20 (Clang/WASI)'
|
|
4028
|
+
: this.lang === 'py'
|
|
4029
|
+
? 'Python 3.12 (CPython WASI)'
|
|
4030
|
+
: this.lang === 'ts'
|
|
4031
|
+
? 'TypeScript 5.x'
|
|
4032
|
+
: 'JavaScript (CJS/ESM)';
|
|
3884
4033
|
}
|
|
3885
4034
|
}
|
|
3886
4035
|
if (typeof this._updateScmActivityBadge === 'function') {
|
|
@@ -4154,9 +4303,14 @@ int main() {
|
|
|
4154
4303
|
}
|
|
4155
4304
|
|
|
4156
4305
|
_renderLanguageSwitcherHtml() {
|
|
4306
|
+
const isGuided = Boolean(this.hasGuidedLab || (Array.isArray(this.steps) && this.steps.length > 0));
|
|
4307
|
+
if (!isGuided && !(this.options && this.options.showLanguageSelector)) {
|
|
4308
|
+
return '';
|
|
4309
|
+
}
|
|
4157
4310
|
const hasMulti = Boolean(
|
|
4158
4311
|
this.hasMultipleLanguages ||
|
|
4159
|
-
(this.enabledLanguages && this.enabledLanguages.size > 1)
|
|
4312
|
+
(this.enabledLanguages && this.enabledLanguages.size > 1) ||
|
|
4313
|
+
(this.options && this.options.showLanguageSelector)
|
|
4160
4314
|
);
|
|
4161
4315
|
if (!hasMulti) return '';
|
|
4162
4316
|
const showJs = Boolean(!this.enabledLanguages || this.enabledLanguages.has('js'));
|
|
@@ -4400,10 +4554,20 @@ int main() {
|
|
|
4400
4554
|
return `<button type="button" class="codelab-activitybar__btn codelab-activitybar__item ${isAct ? 'active' : ''}" data-cl-activity="${escapeHtml(viewId)}" title="${escapeHtml(panel.title || panel.id)}" aria-label="${escapeHtml(panel.title || panel.id)}" aria-pressed="${isAct}">${CL_ICONS.box}</button>`;
|
|
4401
4555
|
}).join('')
|
|
4402
4556
|
: '';
|
|
4557
|
+
if (this._hostHasExplicitHeight === undefined) {
|
|
4558
|
+
this._hostHasExplicitHeight = Boolean(
|
|
4559
|
+
this.container &&
|
|
4560
|
+
this.container.children &&
|
|
4561
|
+
this.container.children.length === 0 &&
|
|
4562
|
+
typeof this.container.getBoundingClientRect === 'function' &&
|
|
4563
|
+
this.container.getBoundingClientRect().height > 20
|
|
4564
|
+
);
|
|
4565
|
+
}
|
|
4403
4566
|
const shellClasses = [
|
|
4404
4567
|
'codelab',
|
|
4405
4568
|
'codelab-workbench',
|
|
4406
4569
|
this.options && this.options.fullbleed ? 'codelab--fullbleed' : '',
|
|
4570
|
+
this._hostHasExplicitHeight ? 'codelab--sized-host' : '',
|
|
4407
4571
|
isGuideCollapsed ? 'guide-collapsed' : '',
|
|
4408
4572
|
isSingleSql ? 'is-sql-single-file' : '',
|
|
4409
4573
|
!this.sidebarVisible ? 'sidebar-collapsed files-collapsed' : '',
|
|
@@ -4447,9 +4611,9 @@ int main() {
|
|
|
4447
4611
|
<span>${escapeHtml(this.backLabel)}</span>
|
|
4448
4612
|
</button>
|
|
4449
4613
|
` : ''}
|
|
4450
|
-
<span class="codelab-brand ${this.onClose ? 'codelab-brand--with-back' : ''}" title="${escapeHtml(brandLabel)}">
|
|
4614
|
+
<span class="codelab-brand ${this.onClose ? 'codelab-brand--with-back' : ''} ${(!this.hasGuidedLab && !this.onClose) ? 'codelab-brand--compact' : ''}" title="${escapeHtml(brandLabel)}">
|
|
4451
4615
|
<span class="codelab-brand__dot"></span>
|
|
4452
|
-
<span>${escapeHtml(brandLabel)}</span>
|
|
4616
|
+
<span class="codelab-brand__label">${escapeHtml(brandLabel)}</span>
|
|
4453
4617
|
</span>
|
|
4454
4618
|
<div class="codelab-menubar" id="cl-menubar" role="menubar" aria-label="Application Menu">
|
|
4455
4619
|
${menubarHtml}
|
|
@@ -4626,9 +4790,19 @@ int main() {
|
|
|
4626
4790
|
<button type="button" class="codelab-explorer__btn" data-cl-action="new-folder-root" title="New Folder" aria-label="New Folder">${CL_ICONS.folder}</button>
|
|
4627
4791
|
<button type="button" class="codelab-explorer__btn" data-cl-action="collapse-all-folders" title="Collapse Folders in Explorer" aria-label="Collapse Folders">${CL_ICONS.collapseAll}</button>
|
|
4628
4792
|
</div>
|
|
4629
|
-
<span id="cl-explorer-lang">${this.lang.toUpperCase()}</span>
|
|
4793
|
+
<span id="cl-explorer-lang" style="display:none">${this.lang.toUpperCase()}</span>
|
|
4630
4794
|
</div>
|
|
4631
4795
|
<div class="codelab-explorer__list" id="cl-explorer-list"></div>
|
|
4796
|
+
<div class="codelab-explorer__sections" id="cl-explorer-sections">
|
|
4797
|
+
<details class="codelab-explorer-section" id="cl-explorer-outline">
|
|
4798
|
+
<summary class="codelab-explorer-section__summary"><span>Outline</span></summary>
|
|
4799
|
+
<div class="codelab-explorer-section__body" id="cl-explorer-outline-body"></div>
|
|
4800
|
+
</details>
|
|
4801
|
+
<details class="codelab-explorer-section" id="cl-explorer-timeline">
|
|
4802
|
+
<summary class="codelab-explorer-section__summary"><span>Timeline</span></summary>
|
|
4803
|
+
<div class="codelab-explorer-section__body" id="cl-explorer-timeline-body"></div>
|
|
4804
|
+
</details>
|
|
4805
|
+
</div>
|
|
4632
4806
|
</div>
|
|
4633
4807
|
|
|
4634
4808
|
<div class="codelab-sidebar__view" id="cl-sidebar-search" data-sidebar-view="search" ${this.activeSidebarView === 'search' ? '' : 'hidden'}>
|
|
@@ -4690,6 +4864,7 @@ int main() {
|
|
|
4690
4864
|
</div>
|
|
4691
4865
|
<div class="codelab-md-preview prose" id="cl-md-preview" style="display:none"></div>
|
|
4692
4866
|
<div class="codelab-settings-host" id="cl-settings-host" role="region" aria-label="Settings Editor" hidden style="display:none"></div>
|
|
4867
|
+
<div class="codelab-welcome-host" id="cl-welcome-host" role="region" aria-label="Welcome" hidden style="display:none"></div>
|
|
4693
4868
|
<div class="codelab-inline-diff-host" id="cl-inline-diff-container" data-role="scm-diff-host" role="region" aria-label="Source Control Diff View" hidden style="display:none"></div>
|
|
4694
4869
|
<div class="codelab-empty-editor" id="cl-empty-editor" style="display:none"></div>
|
|
4695
4870
|
</div>
|
|
@@ -4701,10 +4876,10 @@ int main() {
|
|
|
4701
4876
|
</div>
|
|
4702
4877
|
|
|
4703
4878
|
<!-- Interactive Horizontal Splitter -->
|
|
4704
|
-
<div class="codelab-splitter-h" id="cl-splitter-h" role="separator" aria-orientation="horizontal" title="Drag to resize bottom panel (double-click to reset)"></div>
|
|
4879
|
+
<div class="codelab-splitter-h" id="cl-splitter-h" role="separator" aria-orientation="horizontal" title="Drag to resize or snap-collapse bottom panel (double-click to reset)"></div>
|
|
4705
4880
|
|
|
4706
4881
|
<!-- Region 5: Bottom Panel (Problems / Output / Terminal / Ports / ...) -->
|
|
4707
|
-
<section class="codelab-drawer codelab-bottom" id="cl-drawer" aria-label="Bottom Panel">
|
|
4882
|
+
<section class="codelab-drawer codelab-bottom ${this.panelVisible === false ? 'is-minimized' : ''}" id="cl-drawer" aria-label="Bottom Panel">
|
|
4708
4883
|
<div class="codelab-drawer__bar">
|
|
4709
4884
|
<div class="codelab-drawer__tabs" role="tablist" aria-label="Execution Output Panels">
|
|
4710
4885
|
<button type="button" role="tab" tabindex="${this.drawerTab === 'sql-results' ? '0' : '-1'}" aria-selected="${this.drawerTab === 'sql-results'}" class="codelab-drawer__tab ${this.drawerTab === 'sql-results' ? 'active' : ''}" data-cl-drawertab="sql-results" title="SQL Query Results & EXPLAIN Plan" style="display:${showSqlTab ? 'inline-flex' : 'none'}">
|
|
@@ -4714,7 +4889,7 @@ int main() {
|
|
|
4714
4889
|
<button type="button" role="tab" tabindex="${this.drawerTab === 'problems' ? '0' : '-1'}" aria-selected="${this.drawerTab === 'problems'}" class="codelab-drawer__tab ${this.drawerTab === 'problems' ? 'active' : ''}" data-cl-drawertab="problems" title="Compiler & Runtime Problems">
|
|
4715
4890
|
${CL_ICONS.warning}
|
|
4716
4891
|
<span>Problems</span>
|
|
4717
|
-
<span class="codelab-badge" id="cl-problems-count">${this._diagnosticsStore ? this._diagnosticsStore.getAll().length : 0}</span>
|
|
4892
|
+
<span class="codelab-badge" id="cl-problems-count" style="display:${(this._diagnosticsStore && this._diagnosticsStore.getAll().length > 0) ? 'inline-flex' : 'none'}">${this._diagnosticsStore ? this._diagnosticsStore.getAll().length : 0}</span>
|
|
4718
4893
|
</button>
|
|
4719
4894
|
<button type="button" role="tab" tabindex="${this.drawerTab === 'output' ? '0' : '-1'}" aria-selected="${this.drawerTab === 'output'}" class="codelab-drawer__tab ${this.drawerTab === 'output' ? 'active' : ''}" data-cl-drawertab="output" title="Workbench & Runtime Output" style="${isSingleSql ? 'display:none' : ''}">
|
|
4720
4895
|
${CL_ICONS.code}
|
|
@@ -4727,12 +4902,12 @@ int main() {
|
|
|
4727
4902
|
<button type="button" role="tab" tabindex="${this.drawerTab === 'ports' ? '0' : '-1'}" aria-selected="${this.drawerTab === 'ports'}" class="codelab-drawer__tab ${this.drawerTab === 'ports' ? 'active' : ''}" data-cl-drawertab="ports" style="${isSingleSql ? 'display:none' : ''}">
|
|
4728
4903
|
${CL_ICONS.radio}
|
|
4729
4904
|
<span>Ports</span>
|
|
4730
|
-
<span class="codelab-drawer__pill" id="cl-ports-pill">${this.portTable && typeof this.portTable.listServers === 'function' ? this.portTable.listServers().length : 0} open</span>
|
|
4905
|
+
<span class="codelab-drawer__pill" id="cl-ports-pill" style="display:${(this.portTable && typeof this.portTable.listServers === 'function' && this.portTable.listServers().length > 0) ? 'inline-flex' : 'none'}">${this.portTable && typeof this.portTable.listServers === 'function' ? this.portTable.listServers().length : 0} open</span>
|
|
4731
4906
|
</button>
|
|
4732
4907
|
<button type="button" role="tab" tabindex="${this.drawerTab === 'tests' ? '0' : '-1'}" aria-selected="${this.drawerTab === 'tests'}" class="codelab-drawer__tab ${this.drawerTab === 'tests' ? 'active' : ''}" data-cl-drawertab="tests" style="${(isSingleSql && !this._findEntryFile('test')) ? 'display:none' : ''}">
|
|
4733
4908
|
${CL_ICONS.check}
|
|
4734
4909
|
<span>Test Suite</span>
|
|
4735
|
-
<span class="codelab-drawer__pill" id="cl-test-pill">Ready</span>
|
|
4910
|
+
<span class="codelab-drawer__pill" id="cl-test-pill" style="display:none">Ready</span>
|
|
4736
4911
|
</button>
|
|
4737
4912
|
<button type="button" role="tab" tabindex="${this.drawerTab === 'stdin' ? '0' : '-1'}" aria-selected="${this.drawerTab === 'stdin'}" class="codelab-drawer__tab ${this.drawerTab === 'stdin' ? 'active' : ''}" data-cl-drawertab="stdin" title="Standard Input" style="${isSingleSql ? 'display:none' : ''}">
|
|
4738
4913
|
${CL_ICONS.keyboard}
|
|
@@ -4745,12 +4920,12 @@ int main() {
|
|
|
4745
4920
|
<button type="button" role="tab" tabindex="${this.drawerTab === 'network' ? '0' : '-1'}" aria-selected="${this.drawerTab === 'network'}" class="codelab-drawer__tab ${this.drawerTab === 'network' ? 'active' : ''}" data-cl-drawertab="network" style="${isSingleSql ? 'display:none' : ''}">
|
|
4746
4921
|
${CL_ICONS.activity}
|
|
4747
4922
|
<span>Network</span>
|
|
4748
|
-
<span class="codelab-drawer__pill" id="cl-network-pill">${(this.lastHttpTrace || []).length} reqs</span>
|
|
4923
|
+
<span class="codelab-drawer__pill" id="cl-network-pill" style="display:${(this.lastHttpTrace || []).length > 0 ? 'inline-flex' : 'none'}">${(this.lastHttpTrace || []).length} reqs</span>
|
|
4749
4924
|
</button>
|
|
4750
4925
|
<button type="button" role="tab" tabindex="${this.drawerTab === 'inspector' ? '0' : '-1'}" aria-selected="${this.drawerTab === 'inspector'}" class="codelab-drawer__tab ${this.drawerTab === 'inspector' ? 'active' : ''}" data-cl-drawertab="inspector" style="${isSingleSql ? 'display:none' : ''}">
|
|
4751
4926
|
${CL_ICONS.database}
|
|
4752
4927
|
<span>Virtual Disk & HTTP</span>
|
|
4753
|
-
<span class="codelab-drawer__pill" id="cl-vfs-pill">0 files</span>
|
|
4928
|
+
<span class="codelab-drawer__pill" id="cl-vfs-pill" style="display:none">0 files</span>
|
|
4754
4929
|
</button>
|
|
4755
4930
|
${this.kernel ? `
|
|
4756
4931
|
<button type="button" role="tab" tabindex="${this.drawerTab === 'observability' ? '0' : '-1'}" aria-selected="${this.drawerTab === 'observability'}" class="codelab-drawer__tab ${this.drawerTab === 'observability' ? 'active' : ''}" data-cl-drawertab="observability" title="Services, Settings & Event Telemetry">
|
|
@@ -4764,13 +4939,14 @@ int main() {
|
|
|
4764
4939
|
<div class="codelab-drawer__actions">
|
|
4765
4940
|
<div class="codelab-drawer__term-actions" id="cl-drawer-term-actions" style="display:${isTermDrawer ? 'inline-flex' : 'none'}">
|
|
4766
4941
|
<div class="codelab-terminal-sessions" id="cl-terminal-sessions"></div>
|
|
4767
|
-
<button type="button" class="codelab-btn codelab-btn--icon" id="cl-new-terminal-btn" data-cl-action="new-terminal-session" title="New Terminal (⌃⇧\`)" aria-label="New Terminal Session"
|
|
4768
|
-
<button type="button" class="codelab-btn codelab-btn--icon" id="cl-
|
|
4769
|
-
<button type="button" class="codelab-btn codelab-btn--icon
|
|
4770
|
-
<button type="button" class="codelab-btn codelab-btn--icon" data-cl-action="
|
|
4942
|
+
<button type="button" class="codelab-btn codelab-btn--icon" id="cl-new-terminal-btn" data-cl-action="new-terminal-session" title="New Terminal (⌃⇧\`)" aria-label="New Terminal Session">${CL_ICONS.plus}</button>
|
|
4943
|
+
<button type="button" class="codelab-btn codelab-btn--icon" id="cl-split-terminal-btn" data-cl-action="split-terminal-session" title="Split Terminal (⌘\\)" aria-label="Split Terminal">${CL_ICONS.splitHorizontal}</button>
|
|
4944
|
+
<button type="button" class="codelab-btn codelab-btn--icon" id="cl-kill-terminal-btn" data-cl-action="kill-terminal-session" title="Kill Terminal" aria-label="Kill Active Terminal">${CL_ICONS.trash}</button>
|
|
4945
|
+
<button type="button" class="codelab-btn codelab-btn--icon codelab-btn--ctrl-c" id="cl-ctrl-c-btn" data-cl-action="interrupt" title="Send Ctrl+C — interrupt a running command" aria-label="Send Ctrl+C interrupt">^C</button>
|
|
4946
|
+
<button type="button" class="codelab-btn codelab-btn--icon" data-cl-action="clear-terminal" title="Clear Terminal (⌘K)" aria-label="Clear Terminal">Clear</button>
|
|
4771
4947
|
</div>
|
|
4772
|
-
<button type="button" class="codelab-btn codelab-btn--icon" id="cl-maximize-drawer-btn" data-cl-action="maximize-drawer" title="Maximize / Restore Panel Size" aria-label="Maximize or Restore Panel Size" aria-pressed="${this.panelMaximized ? 'true' : 'false'}"
|
|
4773
|
-
<button type="button" class="codelab-btn codelab-btn--icon" id="cl-close-drawer-btn" data-cl-action="close-drawer" title="Close Panel (⌘J)" aria-label="Close Panel"
|
|
4948
|
+
<button type="button" class="codelab-btn codelab-btn--icon" id="cl-maximize-drawer-btn" data-cl-action="maximize-drawer" title="Maximize / Restore Panel Size" aria-label="Maximize or Restore Panel Size" aria-pressed="${this.panelMaximized ? 'true' : 'false'}">${this.panelMaximized ? CL_ICONS.chevronDown : CL_ICONS.chevronUp}</button>
|
|
4949
|
+
<button type="button" class="codelab-btn codelab-btn--icon" id="cl-close-drawer-btn" data-cl-action="close-drawer" title="Close Panel (⌘J)" aria-label="Close Panel">${CL_ICONS.close}</button>
|
|
4774
4950
|
</div>
|
|
4775
4951
|
</div>
|
|
4776
4952
|
<div class="codelab-drawer__body" id="cl-drawer-body"></div>
|
|
@@ -4778,7 +4954,7 @@ int main() {
|
|
|
4778
4954
|
</div>
|
|
4779
4955
|
</div>
|
|
4780
4956
|
|
|
4781
|
-
<!-- Interactive
|
|
4957
|
+
<!-- Interactive 22px Status Bar Footer -->
|
|
4782
4958
|
<footer class="codelab-statusbar" id="cl-statusbar" role="status" aria-live="polite">
|
|
4783
4959
|
<div class="codelab-statusbar__left">
|
|
4784
4960
|
<span class="codelab-statusbar__item" id="cl-status-runtime">
|
|
@@ -4802,7 +4978,8 @@ int main() {
|
|
|
4802
4978
|
<button type="button" class="codelab-statusbar__btn" id="cl-status-cursor" data-cl-action="go-to-line" title="Go to Line/Column">Ln 1, Col 1</button>
|
|
4803
4979
|
<button type="button" class="codelab-statusbar__btn" id="cl-status-indent" data-cl-action="open-settings" title="Select Indentation">Spaces: ${tabSizeVal}</button>
|
|
4804
4980
|
<span class="codelab-statusbar__item">UTF-8</span>
|
|
4805
|
-
<button type="button" class="codelab-statusbar__btn" id="cl-status-lang" data-cl-action="open-settings" title="Language Mode">${this.lang === 'sql' ? (this.sqlDialect === 'sqlite' ? 'SQLite 3' : 'PostgreSQL 18') : this.lang === 'cpp' ? 'C++20 (Clang/WASI)' : this.lang === 'py' ? 'Python 3.12 (CPython WASI)' : this.lang === 'ts' ? 'TypeScript 5.x' : 'JavaScript (CJS/ESM)'}</button>
|
|
4981
|
+
<button type="button" class="codelab-statusbar__btn" id="cl-status-lang" data-cl-action="open-settings" title="Select Language Mode">${this.lang === 'sql' ? (this.sqlDialect === 'sqlite' ? 'SQLite 3' : 'PostgreSQL 18') : this.lang === 'cpp' ? 'C++20 (Clang/WASI)' : this.lang === 'py' ? 'Python 3.12 (CPython WASI)' : this.lang === 'ts' ? 'TypeScript 5.x' : 'JavaScript (CJS/ESM)'}</button>
|
|
4982
|
+
<button type="button" class="codelab-statusbar__btn" id="cl-status-panel-toggle" data-cl-action="toggle-drawer" title="Toggle Panel (⌘J)" aria-label="Toggle Panel">${CL_ICONS.panelBottom}</button>
|
|
4806
4983
|
</div>
|
|
4807
4984
|
</footer>
|
|
4808
4985
|
|
|
@@ -4815,7 +4992,10 @@ int main() {
|
|
|
4815
4992
|
</div>
|
|
4816
4993
|
`;
|
|
4817
4994
|
|
|
4818
|
-
if (this.themeOption
|
|
4995
|
+
if (this.themeOption === 'auto') {
|
|
4996
|
+
this._ensureSystemColorSchemeListener();
|
|
4997
|
+
}
|
|
4998
|
+
if (this.themes && typeof this.themes.applyToElement === 'function') {
|
|
4819
4999
|
const shellEl = this.container.querySelector('.codelab');
|
|
4820
5000
|
if (shellEl && shellEl.style && typeof shellEl.style.setProperty === 'function') {
|
|
4821
5001
|
try {
|
|
@@ -4906,6 +5086,13 @@ int main() {
|
|
|
4906
5086
|
}
|
|
4907
5087
|
}
|
|
4908
5088
|
const code = this.files[filePath];
|
|
5089
|
+
if (_wbComponents && typeof _wbComponents.findEnclosingSymbolAtLine === 'function') {
|
|
5090
|
+
const curLine = (this.cursorPos && this.cursorPos.lineNumber) ? this.cursorPos.lineNumber : 1;
|
|
5091
|
+
const sym = _wbComponents.findEnclosingSymbolAtLine(filePath, code, curLine);
|
|
5092
|
+
if (sym && sym.name) {
|
|
5093
|
+
return sym.containerName ? `${sym.containerName}.${sym.name}` : sym.name;
|
|
5094
|
+
}
|
|
5095
|
+
}
|
|
4909
5096
|
const classMatch = code.match(/\bclass\s+([A-Za-z_$][A-Za-z0-9_$]*)/);
|
|
4910
5097
|
if (classMatch) return classMatch[1];
|
|
4911
5098
|
const fnMatch = code.match(/\b(?:async\s+)?function\s+([A-Za-z_$][A-Za-z0-9_$]*)/);
|
|
@@ -4916,7 +5103,7 @@ int main() {
|
|
|
4916
5103
|
_renderBreadcrumbs() {
|
|
4917
5104
|
const host = this.container.querySelector('#cl-breadcrumbs');
|
|
4918
5105
|
if (!host) return;
|
|
4919
|
-
if (!this.activeFile || !this.openTabs || this.openTabs.length === 0 || this.activeTab === '__settings__') {
|
|
5106
|
+
if (!this.activeFile || !this.openTabs || this.openTabs.length === 0 || this.activeTab === '__settings__' || this.activeTab === '__welcome__') {
|
|
4920
5107
|
host.innerHTML = '';
|
|
4921
5108
|
host.hidden = true;
|
|
4922
5109
|
if (host.style) host.style.display = 'none';
|
|
@@ -5441,13 +5628,31 @@ int main() {
|
|
|
5441
5628
|
}
|
|
5442
5629
|
}
|
|
5443
5630
|
|
|
5631
|
+
const gitStatusMap = new Map();
|
|
5632
|
+
if (typeof this.getGitStatus === 'function') {
|
|
5633
|
+
try {
|
|
5634
|
+
for (const entry of (this.getGitStatus() || [])) {
|
|
5635
|
+
if (entry && entry.path) {
|
|
5636
|
+
const rawSt = String(entry.status || '').toLowerCase();
|
|
5637
|
+
const code = rawSt.includes('untracked') ? 'U'
|
|
5638
|
+
: rawSt.includes('added') ? 'A'
|
|
5639
|
+
: rawSt.includes('deleted') ? 'D'
|
|
5640
|
+
: 'M';
|
|
5641
|
+
gitStatusMap.set(entry.path, code);
|
|
5642
|
+
}
|
|
5643
|
+
}
|
|
5644
|
+
} catch (_e) { void _e; }
|
|
5645
|
+
}
|
|
5444
5646
|
const sortedFiles = Array.from(node.files.entries()).sort((a, b) => a[0].localeCompare(b[0]));
|
|
5445
5647
|
for (const [baseName, fullPath] of sortedFiles) {
|
|
5446
5648
|
const isActive = fullPath === this.activeFile;
|
|
5447
5649
|
const badge = fullPath.endsWith('.md') ? 'DOC' : fullPath.endsWith('.json') ? 'PKG' : /\.sql$/i.test(fullPath) ? 'SQL' : /(^|\/)test\./i.test(fullPath) ? 'TEST' : /(^|\/)(demo|main)\./i.test(fullPath) ? 'DEMO' : /\.(hpp|h)$/i.test(fullPath) ? 'HDR' : 'SRC';
|
|
5448
5650
|
const ext = /\.(cpp|cc|cxx|hpp|h)$/i.test(fullPath) ? 'cpp' : /\.sql$/i.test(fullPath) ? 'sql' : fullPath.endsWith('.py') ? 'py' : fullPath.endsWith('.ts') ? 'ts' : fullPath.endsWith('.js') ? 'js' : fullPath.endsWith('.json') ? 'json' : fullPath.endsWith('.md') ? 'md' : 'txt';
|
|
5449
|
-
const fileIcon = (
|
|
5651
|
+
const fileIcon = (_wbComponents && typeof _wbComponents.getFileIconSvg === 'function')
|
|
5652
|
+
? _wbComponents.getFileIconSvg(baseName)
|
|
5653
|
+
: ((ext === 'json' || ext === 'sql') ? CL_ICONS.database : ext === 'md' ? CL_ICONS.book : CL_ICONS.file);
|
|
5450
5654
|
const indent = depth * 14 + 10;
|
|
5655
|
+
const gitBadgeCode = gitStatusMap.get(fullPath) || '';
|
|
5451
5656
|
const isRenamingFile = Boolean(
|
|
5452
5657
|
this.renamingItem &&
|
|
5453
5658
|
this.renamingItem.type === 'file' &&
|
|
@@ -5466,11 +5671,11 @@ int main() {
|
|
|
5466
5671
|
} else {
|
|
5467
5672
|
const isFileDirty = Boolean(this._dirtyFiles && this._dirtyFiles.has(fullPath));
|
|
5468
5673
|
treeHtml += `
|
|
5469
|
-
<button type="button" class="codelab-file-item ${isActive ? 'active' : ''}"${isFileDirty ? ' data-dirty="true"' : ''} draggable="true" data-cl-file="${escapeHtml(fullPath)}" data-file="${escapeHtml(fullPath)}" data-depth="${depth}" style="padding-left: ${indent}px;">
|
|
5674
|
+
<button type="button" class="codelab-file-item ${isActive ? 'active' : ''}"${isFileDirty ? ' data-dirty="true"' : ''}${gitBadgeCode ? ` data-git-status="${gitBadgeCode}"` : ''} draggable="true" data-cl-file="${escapeHtml(fullPath)}" data-file="${escapeHtml(fullPath)}" data-depth="${depth}" style="padding-left: ${indent}px;">
|
|
5470
5675
|
<span class="codelab-file-icon">${fileIcon}</span>
|
|
5471
5676
|
<span class="codelab-file-name" title="${escapeHtml(baseName)}">${escapeHtml(baseName)}</span>
|
|
5472
5677
|
${isFileDirty ? '<span class="codelab-file-dirty" title="Unsaved changes" aria-hidden="true"></span>' : ''}
|
|
5473
|
-
|
|
5678
|
+
${gitBadgeCode ? `<span class="codelab-file-git-status codelab-file-git-status--${gitBadgeCode.toLowerCase()}" aria-label="Git ${gitBadgeCode}">${gitBadgeCode}</span>` : `<span class="codelab-file-badge">${badge}</span>`}
|
|
5474
5679
|
</button>
|
|
5475
5680
|
`;
|
|
5476
5681
|
}
|
|
@@ -5815,22 +6020,37 @@ int main() {
|
|
|
5815
6020
|
|
|
5816
6021
|
// Tabs rendering (strictly WAI-ARIA compliant: zero nested <button> inside [role="tab"]!)
|
|
5817
6022
|
const openTabs = Array.isArray(this.openTabs) ? this.openTabs : [];
|
|
5818
|
-
const effectiveActiveTab = this.settingsTabOpen && this.activeTab === '__settings__'
|
|
6023
|
+
const effectiveActiveTab = (this.settingsTabOpen && this.activeTab === '__settings__')
|
|
5819
6024
|
? '__settings__'
|
|
5820
|
-
: this.
|
|
6025
|
+
: (this.welcomeTabOpen && this.activeTab === '__welcome__')
|
|
6026
|
+
? '__welcome__'
|
|
6027
|
+
: this.activeFile;
|
|
6028
|
+
const hasCustomFileIcons = Boolean(_wbComponents && typeof _wbComponents.getFileIconSvg === 'function');
|
|
5821
6029
|
const tabsHtml = openTabs.map(f => {
|
|
5822
6030
|
const isActive = f === effectiveActiveTab;
|
|
5823
6031
|
const isDirty = Boolean(this._dirtyFiles && this._dirtyFiles.has(f));
|
|
5824
6032
|
const ext = /\.(cpp|cc|cxx|hpp|h)$/i.test(f) ? 'cpp' : /\.sql$/i.test(f) ? 'sql' : f.endsWith('.py') ? 'py' : f.endsWith('.ts') ? 'ts' : f.endsWith('.js') ? 'js' : f.endsWith('.json') ? 'json' : f.endsWith('.md') ? 'md' : 'txt';
|
|
6033
|
+
const tabIconHtml = hasCustomFileIcons
|
|
6034
|
+
? _wbComponents.getFileIconSvg(f)
|
|
6035
|
+
: (ext === 'cpp' ? 'C++' : ext.toUpperCase());
|
|
5825
6036
|
return `
|
|
5826
6037
|
<div role="tab" tabindex="${isActive ? '0' : '-1'}" aria-selected="${isActive}"${isDirty ? ' data-dirty="true"' : ''} class="codelab-tab ${isActive ? 'active' : ''}" data-cl-file="${escapeHtml(f)}" data-tab-file="${escapeHtml(f)}">
|
|
5827
|
-
<span class="codelab-tab__ext codelab-tab__ext--${ext}">${
|
|
6038
|
+
<span class="codelab-tab__ext codelab-tab__ext--${ext}">${tabIconHtml}</span>
|
|
5828
6039
|
<span class="codelab-tab__label">${escapeHtml(f)}</span>
|
|
5829
6040
|
${isDirty ? '<span class="codelab-tab__dirty" title="Unsaved changes" aria-hidden="true"></span>' : ''}
|
|
5830
6041
|
<span role="button" tabindex="0" class="codelab-tab__close" data-action="close-tab" data-cl-close-file="${escapeHtml(f)}" title="Close ${escapeHtml(f)}" aria-label="Close ${escapeHtml(f)}">×</span>
|
|
5831
6042
|
</div>
|
|
5832
6043
|
`;
|
|
5833
6044
|
}).join('');
|
|
6045
|
+
const welcomeTabHtml = this.welcomeTabOpen
|
|
6046
|
+
? `
|
|
6047
|
+
<div role="tab" tabindex="${effectiveActiveTab === '__welcome__' ? '0' : '-1'}" aria-selected="${effectiveActiveTab === '__welcome__'}" class="codelab-tab ${effectiveActiveTab === '__welcome__' ? 'active' : ''}" data-cl-tab="__welcome__" data-tab-file="__welcome__">
|
|
6048
|
+
<span class="codelab-tab__ext codelab-tab__ext--md">${CL_ICONS.code}</span>
|
|
6049
|
+
<span class="codelab-tab__label">Welcome</span>
|
|
6050
|
+
<span role="button" tabindex="0" class="codelab-tab__close" data-action="close-tab" data-cl-close-tab="__welcome__" title="Close Welcome" aria-label="Close Welcome">×</span>
|
|
6051
|
+
</div>
|
|
6052
|
+
`
|
|
6053
|
+
: '';
|
|
5834
6054
|
const settingsTabHtml = this.settingsTabOpen
|
|
5835
6055
|
? `
|
|
5836
6056
|
<div role="tab" tabindex="${effectiveActiveTab === '__settings__' ? '0' : '-1'}" aria-selected="${effectiveActiveTab === '__settings__'}" class="codelab-tab ${effectiveActiveTab === '__settings__' ? 'active' : ''}" data-cl-tab="__settings__" data-tab-file="__settings__">
|
|
@@ -5857,13 +6077,14 @@ int main() {
|
|
|
5857
6077
|
</button>
|
|
5858
6078
|
`;
|
|
5859
6079
|
|
|
5860
|
-
const mdToggleHtml = (this.activeFile && /\.md$/i.test(this.activeFile) && effectiveActiveTab !== '__settings__')
|
|
6080
|
+
const mdToggleHtml = (this.activeFile && /\.md$/i.test(this.activeFile) && effectiveActiveTab !== '__settings__' && effectiveActiveTab !== '__welcome__')
|
|
5861
6081
|
? `<button type="button" class="codelab-pkg-btn ${this._mdPreviewOpen ? 'active' : ''}" data-cl-action="toggle-md-preview" aria-pressed="${Boolean(this._mdPreviewOpen)}" title="${this._mdPreviewOpen ? 'Edit Markdown Source' : 'Open Markdown Preview'}">
|
|
5862
6082
|
<span>${this._mdPreviewOpen ? 'Edit Source' : 'Preview'}</span>
|
|
5863
6083
|
</button>`
|
|
5864
6084
|
: '';
|
|
5865
6085
|
|
|
5866
|
-
tabsEl.innerHTML = tabsHtml + settingsTabHtml;
|
|
6086
|
+
tabsEl.innerHTML = welcomeTabHtml + tabsHtml + settingsTabHtml;
|
|
6087
|
+
this._renderExplorerOutlineAndTimeline();
|
|
5867
6088
|
const tabsActionsEl = this.container.querySelector('#cl-file-tabs-actions');
|
|
5868
6089
|
if (tabsActionsEl) {
|
|
5869
6090
|
tabsActionsEl.innerHTML = mdToggleHtml + newFileControl + pkgBtnHtml;
|
|
@@ -6539,6 +6760,10 @@ int main() {
|
|
|
6539
6760
|
this.closeSettings();
|
|
6540
6761
|
return;
|
|
6541
6762
|
}
|
|
6763
|
+
if (filename === '__welcome__') {
|
|
6764
|
+
this.closeWelcomeTab();
|
|
6765
|
+
return;
|
|
6766
|
+
}
|
|
6542
6767
|
if (!Array.isArray(this.openTabs) || !this.openTabs.includes(filename)) {
|
|
6543
6768
|
return;
|
|
6544
6769
|
}
|
|
@@ -6553,7 +6778,7 @@ int main() {
|
|
|
6553
6778
|
this.activeFile = null;
|
|
6554
6779
|
}
|
|
6555
6780
|
}
|
|
6556
|
-
if (this.activeTab !== '__settings__') {
|
|
6781
|
+
if (this.activeTab !== '__settings__' && this.activeTab !== '__welcome__') {
|
|
6557
6782
|
this.activeTab = this.activeFile;
|
|
6558
6783
|
}
|
|
6559
6784
|
|
|
@@ -6565,16 +6790,31 @@ int main() {
|
|
|
6565
6790
|
if (keepFilename === '__settings__') {
|
|
6566
6791
|
this.openTabs = [];
|
|
6567
6792
|
this.activeFile = null;
|
|
6793
|
+
this.welcomeTabOpen = false;
|
|
6568
6794
|
this.activeTab = '__settings__';
|
|
6569
6795
|
this._saveState();
|
|
6570
6796
|
this._syncActiveFileToView();
|
|
6571
6797
|
return;
|
|
6572
6798
|
}
|
|
6799
|
+
if (keepFilename === '__welcome__') {
|
|
6800
|
+
this.openTabs = [];
|
|
6801
|
+
this.activeFile = null;
|
|
6802
|
+
this.settingsTabOpen = false;
|
|
6803
|
+
this.welcomeTabOpen = true;
|
|
6804
|
+
this.activeTab = '__welcome__';
|
|
6805
|
+
if (this._settingsDialog && typeof this._settingsDialog.unmountInline === 'function') {
|
|
6806
|
+
this._settingsDialog.unmountInline();
|
|
6807
|
+
}
|
|
6808
|
+
this._saveState();
|
|
6809
|
+
this._syncActiveFileToView();
|
|
6810
|
+
return;
|
|
6811
|
+
}
|
|
6573
6812
|
if (!Array.isArray(this.openTabs)) return;
|
|
6574
6813
|
if (keepFilename && this.files[keepFilename] !== undefined) {
|
|
6575
6814
|
this.openTabs = [keepFilename];
|
|
6576
6815
|
this.activeFile = keepFilename;
|
|
6577
6816
|
this.settingsTabOpen = false;
|
|
6817
|
+
this.welcomeTabOpen = false;
|
|
6578
6818
|
this.activeTab = keepFilename;
|
|
6579
6819
|
if (this._settingsDialog && typeof this._settingsDialog.unmountInline === 'function') {
|
|
6580
6820
|
this._settingsDialog.unmountInline();
|
|
@@ -6588,6 +6828,7 @@ int main() {
|
|
|
6588
6828
|
this.openTabs = [];
|
|
6589
6829
|
this.activeFile = null;
|
|
6590
6830
|
this.settingsTabOpen = false;
|
|
6831
|
+
this.welcomeTabOpen = false;
|
|
6591
6832
|
this.activeTab = null;
|
|
6592
6833
|
if (this._settingsDialog && typeof this._settingsDialog.unmountInline === 'function') {
|
|
6593
6834
|
this._settingsDialog.unmountInline();
|
|
@@ -6688,6 +6929,9 @@ int main() {
|
|
|
6688
6929
|
? this._diagnosticsStore.getAll().length
|
|
6689
6930
|
: 0;
|
|
6690
6931
|
problemsCountEl.textContent = String(count);
|
|
6932
|
+
if (problemsCountEl.style) {
|
|
6933
|
+
problemsCountEl.style.display = count > 0 ? 'inline-flex' : 'none';
|
|
6934
|
+
}
|
|
6691
6935
|
}
|
|
6692
6936
|
this._updateTelemetryHud();
|
|
6693
6937
|
|
|
@@ -6695,11 +6939,13 @@ int main() {
|
|
|
6695
6939
|
if (!this.lastTestResults.length) {
|
|
6696
6940
|
testPill.textContent = 'Ready';
|
|
6697
6941
|
testPill.className = 'codelab-drawer__pill';
|
|
6942
|
+
if (testPill.style) testPill.style.display = 'none';
|
|
6698
6943
|
} else {
|
|
6699
6944
|
const passed = this.lastTestResults.filter(t => t.status === 'pass').length;
|
|
6700
6945
|
const total = this.lastTestResults.length;
|
|
6701
6946
|
testPill.textContent = `${passed}/${total} Passed`;
|
|
6702
6947
|
testPill.className = `codelab-drawer__pill ${passed === total ? 'pass' : 'fail'}`;
|
|
6948
|
+
if (testPill.style) testPill.style.display = 'inline-flex';
|
|
6703
6949
|
}
|
|
6704
6950
|
}
|
|
6705
6951
|
if (portsPill) {
|
|
@@ -6707,15 +6953,25 @@ int main() {
|
|
|
6707
6953
|
? this.portTable.listServers().length
|
|
6708
6954
|
: 0;
|
|
6709
6955
|
portsPill.textContent = `${portCount} open`;
|
|
6956
|
+
if (portsPill.style) portsPill.style.display = portCount > 0 ? 'inline-flex' : 'none';
|
|
6710
6957
|
}
|
|
6711
6958
|
if (networkPill) {
|
|
6712
6959
|
const netCount = (this.lastHttpTrace || []).length;
|
|
6713
6960
|
networkPill.textContent = `${netCount} reqs`;
|
|
6961
|
+
if (networkPill.style) networkPill.style.display = netCount > 0 ? 'inline-flex' : 'none';
|
|
6714
6962
|
}
|
|
6715
6963
|
if (vfsPill) {
|
|
6716
6964
|
const diskCount = this.lastFsSnapshot.length;
|
|
6717
6965
|
const httpCount = this.lastHttpTrace.length;
|
|
6718
6966
|
vfsPill.textContent = httpCount > 0 ? `${diskCount} files · ${httpCount} reqs` : `${diskCount} files`;
|
|
6967
|
+
if (vfsPill.style) vfsPill.style.display = (diskCount > 0 || httpCount > 0) ? 'inline-flex' : 'none';
|
|
6968
|
+
}
|
|
6969
|
+
|
|
6970
|
+
if (bodyEl && bodyEl.classList) {
|
|
6971
|
+
bodyEl.classList.toggle('is-flush-panel', this.drawerTab === 'terminal');
|
|
6972
|
+
}
|
|
6973
|
+
if (this.drawerTab !== 'terminal' && this._xtermWrapEl && this._xtermWrapEl.parentNode === bodyEl) {
|
|
6974
|
+
try { bodyEl.removeChild(this._xtermWrapEl); } catch (_err) { void _err; }
|
|
6719
6975
|
}
|
|
6720
6976
|
|
|
6721
6977
|
if (this.drawerTab === 'problems') {
|
|
@@ -6815,6 +7071,10 @@ int main() {
|
|
|
6815
7071
|
const termFontPx = this.configuration
|
|
6816
7072
|
? Math.max(10, Math.min(28, Number(this.configuration.get('terminal.fontSize', 13)) || 13))
|
|
6817
7073
|
: 13;
|
|
7074
|
+
if (this._shouldUseXterm()) {
|
|
7075
|
+
this._renderXtermTerminalBody(bodyEl, termFontPx);
|
|
7076
|
+
return;
|
|
7077
|
+
}
|
|
6818
7078
|
const logsHtml = this.terminalLogs
|
|
6819
7079
|
.map(item => {
|
|
6820
7080
|
const html = ansiToHtml ? ansiToHtml(item.text || '') : escapeHtml(item.text || '');
|
|
@@ -7136,7 +7396,14 @@ int main() {
|
|
|
7136
7396
|
if (chunk === null || chunk === undefined || chunk === '') return;
|
|
7137
7397
|
const rawText = String(chunk);
|
|
7138
7398
|
|
|
7139
|
-
|
|
7399
|
+
const activeXterm = this._getActiveXtermEngine();
|
|
7400
|
+
if (activeXterm && typeof activeXterm.writeStreamChunk === 'function') {
|
|
7401
|
+
try {
|
|
7402
|
+
activeXterm.writeStreamChunk(rawText, type);
|
|
7403
|
+
} catch (err) {
|
|
7404
|
+
this.logger.debug('activeXterm.writeStreamChunk failed.', err);
|
|
7405
|
+
}
|
|
7406
|
+
} else if (this.ptyEngine && this.ptyEngine.container && typeof this.ptyEngine.writeStreamChunk === 'function') {
|
|
7140
7407
|
try {
|
|
7141
7408
|
this.ptyEngine.writeStreamChunk(rawText, type);
|
|
7142
7409
|
} catch (err) {
|
|
@@ -7149,10 +7416,8 @@ int main() {
|
|
|
7149
7416
|
const termSurface = this.container ? this.container.querySelector('#cl-terminal-surface') : null;
|
|
7150
7417
|
const drawerBody = this.container ? this.container.querySelector('.codelab-drawer__body') : null;
|
|
7151
7418
|
|
|
7152
|
-
// The workbench owns live terminal rendering
|
|
7153
|
-
|
|
7154
|
-
// production, so this remains the sole renderer there).
|
|
7155
|
-
const ptyOwnsDom = Boolean(this.ptyEngine && this.ptyEngine.container);
|
|
7419
|
+
// The workbench owns live terminal rendering unless xterm or an attached PTY engine owns the DOM.
|
|
7420
|
+
const ptyOwnsDom = Boolean((activeXterm && activeXterm.container) || (this.ptyEngine && this.ptyEngine.container));
|
|
7156
7421
|
const canPatchDom = Boolean(termLogEl && typeof document !== 'undefined' && !ptyOwnsDom);
|
|
7157
7422
|
|
|
7158
7423
|
// Write a single logical line into the live terminal DOM immediately, so output
|
|
@@ -7178,7 +7443,7 @@ int main() {
|
|
|
7178
7443
|
const maxScrollback = this._getTerminalScrollback();
|
|
7179
7444
|
const commitActiveLine = () => {
|
|
7180
7445
|
const entry = { type: this._activeStreamType || type, text: this._activeStreamLine };
|
|
7181
|
-
this._pushTerminalLog(entry);
|
|
7446
|
+
this._pushTerminalLog(entry, { fromStream: true });
|
|
7182
7447
|
if (Array.isArray(this.outputLogs)) {
|
|
7183
7448
|
this.outputLogs.push(entry);
|
|
7184
7449
|
if (this.outputLogs.length > maxScrollback) {
|
|
@@ -7297,11 +7562,30 @@ int main() {
|
|
|
7297
7562
|
return trimmed;
|
|
7298
7563
|
}
|
|
7299
7564
|
|
|
7300
|
-
_pushTerminalLog(entry) {
|
|
7565
|
+
_pushTerminalLog(entry, opts = null) {
|
|
7301
7566
|
if (!entry) return;
|
|
7567
|
+
const activeXterm = this._getActiveXtermEngine();
|
|
7568
|
+
if (activeXterm && activeXterm.logs === this.terminalLogs) {
|
|
7569
|
+
if (!(opts && opts.fromStream) && typeof activeXterm.writeln === 'function') {
|
|
7570
|
+
try {
|
|
7571
|
+
activeXterm.writeln(String(entry.text ?? ''), entry.type || 'stdout');
|
|
7572
|
+
} catch (_err) {
|
|
7573
|
+
void _err;
|
|
7574
|
+
}
|
|
7575
|
+
}
|
|
7576
|
+
this._trimTerminalLogs();
|
|
7577
|
+
return;
|
|
7578
|
+
}
|
|
7302
7579
|
if (Array.isArray(this.terminalLogs)) {
|
|
7303
7580
|
Array.prototype.push.call(this.terminalLogs, entry);
|
|
7304
7581
|
}
|
|
7582
|
+
if (activeXterm && !(opts && opts.fromStream) && typeof activeXterm.writeln === 'function') {
|
|
7583
|
+
try {
|
|
7584
|
+
activeXterm.writeln(String(entry.text ?? ''), entry.type || 'stdout');
|
|
7585
|
+
} catch (_err) {
|
|
7586
|
+
void _err;
|
|
7587
|
+
}
|
|
7588
|
+
}
|
|
7305
7589
|
this._trimTerminalLogs();
|
|
7306
7590
|
}
|
|
7307
7591
|
|
|
@@ -7318,7 +7602,7 @@ int main() {
|
|
|
7318
7602
|
type: this._activeStreamType || 'stdout',
|
|
7319
7603
|
text: this._activeStreamLine
|
|
7320
7604
|
};
|
|
7321
|
-
this._pushTerminalLog(entry);
|
|
7605
|
+
this._pushTerminalLog(entry, { fromStream: true });
|
|
7322
7606
|
const maxScrollback = this._getTerminalScrollback();
|
|
7323
7607
|
if (this.terminalLogs.length > maxScrollback) {
|
|
7324
7608
|
this.terminalLogs.splice(0, this.terminalLogs.length - maxScrollback);
|
|
@@ -7361,15 +7645,55 @@ int main() {
|
|
|
7361
7645
|
`;
|
|
7362
7646
|
}
|
|
7363
7647
|
|
|
7364
|
-
|
|
7648
|
+
interruptTerminal() {
|
|
7649
|
+
return Boolean(this._handleInterrupt());
|
|
7650
|
+
}
|
|
7651
|
+
|
|
7652
|
+
submitTerminalStdin(line) {
|
|
7653
|
+
const activeXterm = this._getActiveXtermEngine();
|
|
7654
|
+
if (activeXterm && typeof activeXterm.submitLine === 'function') {
|
|
7655
|
+
activeXterm.buffer = String(line ?? '');
|
|
7656
|
+
activeXterm.cursor = activeXterm.buffer.length;
|
|
7657
|
+
activeXterm.submitLine();
|
|
7658
|
+
return true;
|
|
7659
|
+
}
|
|
7660
|
+
if (this.ptyEngine && typeof this.ptyEngine.submitLine === 'function') {
|
|
7661
|
+
this.ptyEngine.buffer = String(line ?? '');
|
|
7662
|
+
this.ptyEngine.cursor = this.ptyEngine.buffer.length;
|
|
7663
|
+
this.ptyEngine.submitLine();
|
|
7664
|
+
return true;
|
|
7665
|
+
}
|
|
7666
|
+
return false;
|
|
7667
|
+
}
|
|
7668
|
+
|
|
7669
|
+
_submitInteractiveTerminalStdin(line) {
|
|
7670
|
+
return this.submitTerminalStdin(line);
|
|
7671
|
+
}
|
|
7672
|
+
|
|
7673
|
+
_handleInterrupt(opts = null) {
|
|
7674
|
+
const fromXterm = Boolean(opts && opts.fromXterm);
|
|
7675
|
+
let didInterrupt = false;
|
|
7365
7676
|
if (this._cloneInFlight || this._activeCloneAbortController) {
|
|
7366
7677
|
this.cancelClone();
|
|
7678
|
+
didInterrupt = true;
|
|
7367
7679
|
}
|
|
7368
|
-
|
|
7680
|
+
let cancelledWorker = false;
|
|
7681
|
+
if (typeof root.CodeLabRuntime?.cancelWorkerExecution === 'function') {
|
|
7682
|
+
try {
|
|
7683
|
+
cancelledWorker = Boolean(
|
|
7684
|
+
root.CodeLabRuntime.cancelWorkerExecution('SIGINT: Interrupted by user (Ctrl+C)', this.instanceId) ||
|
|
7685
|
+
root.CodeLabRuntime.cancelWorkerExecution('SIGINT: Interrupted by user (Ctrl+C)', 'default')
|
|
7686
|
+
);
|
|
7687
|
+
} catch (err) {
|
|
7688
|
+
this.logger.debug('cancelWorkerExecution failed.', err);
|
|
7689
|
+
}
|
|
7690
|
+
}
|
|
7691
|
+
const isCommandRunning = Boolean(this.isRunning || this._activeCommandAbortController || cancelledWorker);
|
|
7369
7692
|
const cwdShort = (this.cwd || '/workspace').replace(/^\/workspace\/?/, '') || '~';
|
|
7370
7693
|
const promptLabel = this.inRepl ? '> ' : `codelab:${cwdShort}$`;
|
|
7371
7694
|
|
|
7372
7695
|
if (isCommandRunning) {
|
|
7696
|
+
didInterrupt = true;
|
|
7373
7697
|
if (this._activeCommandAbortController) {
|
|
7374
7698
|
try {
|
|
7375
7699
|
this._activeCommandAbortController.abort('SIGINT');
|
|
@@ -7379,25 +7703,21 @@ int main() {
|
|
|
7379
7703
|
this._activeCommandAbortController = null;
|
|
7380
7704
|
}
|
|
7381
7705
|
|
|
7382
|
-
if (typeof root.CodeLabRuntime?.cancelWorkerExecution === 'function') {
|
|
7383
|
-
try {
|
|
7384
|
-
root.CodeLabRuntime.cancelWorkerExecution('SIGINT: Interrupted by user (Ctrl+C)', this.instanceId);
|
|
7385
|
-
} catch (err) {
|
|
7386
|
-
this.logger.debug('cancelWorkerExecution failed.', err);
|
|
7387
|
-
}
|
|
7388
|
-
}
|
|
7389
|
-
|
|
7390
7706
|
this.isRunning = false;
|
|
7391
7707
|
this._setRuntimeStatus('idle', 'Ready · Node v22 VFS');
|
|
7392
7708
|
this._updateRunStateUI();
|
|
7393
7709
|
|
|
7394
7710
|
this._flushTerminalStream();
|
|
7395
|
-
|
|
7711
|
+
if (!fromXterm) {
|
|
7712
|
+
this._pushTerminalLog({ type: 'stdout', text: '^C' });
|
|
7713
|
+
}
|
|
7396
7714
|
} else {
|
|
7397
7715
|
if (this.inRepl) {
|
|
7398
7716
|
this.inRepl = false;
|
|
7399
|
-
|
|
7400
|
-
|
|
7717
|
+
if (!fromXterm) {
|
|
7718
|
+
this._pushTerminalLog({ type: 'stdout', text: '^C\nExiting REPL...' });
|
|
7719
|
+
}
|
|
7720
|
+
} else if (!fromXterm) {
|
|
7401
7721
|
const currentInput = (this._ptyInputBeforeCursor || '') + (this._ptyInputAfterCursor || '');
|
|
7402
7722
|
this._pushTerminalLog({ type: 'stdout', text: `${promptLabel} ${currentInput}^C` });
|
|
7403
7723
|
}
|
|
@@ -7408,11 +7728,17 @@ int main() {
|
|
|
7408
7728
|
this.replHistoryIdx = -1;
|
|
7409
7729
|
|
|
7410
7730
|
this._renderDrawerBody();
|
|
7411
|
-
const
|
|
7412
|
-
if (
|
|
7413
|
-
|
|
7414
|
-
|
|
7731
|
+
const activeXterm = this._getActiveXtermEngine();
|
|
7732
|
+
if (activeXterm && typeof activeXterm.focus === 'function') {
|
|
7733
|
+
activeXterm.focus();
|
|
7734
|
+
} else {
|
|
7735
|
+
const nextInput = this.container?.querySelector?.('#cl-repl-input');
|
|
7736
|
+
if (nextInput && typeof nextInput.focus === 'function') {
|
|
7737
|
+
nextInput.value = '';
|
|
7738
|
+
nextInput.focus();
|
|
7739
|
+
}
|
|
7415
7740
|
}
|
|
7741
|
+
return didInterrupt;
|
|
7416
7742
|
}
|
|
7417
7743
|
|
|
7418
7744
|
_updatePtyActiveLine() {
|
|
@@ -8504,6 +8830,269 @@ int main() {
|
|
|
8504
8830
|
return this.dispatchHttpClientRequest();
|
|
8505
8831
|
}
|
|
8506
8832
|
|
|
8833
|
+
get vfs() {
|
|
8834
|
+
return this.shell ? this.shell.vfs : null;
|
|
8835
|
+
}
|
|
8836
|
+
|
|
8837
|
+
_shouldUseXterm() {
|
|
8838
|
+
const mode = (this.options && this.options.terminalEngine) || 'auto';
|
|
8839
|
+
if (mode === 'dom') return false;
|
|
8840
|
+
if (!_wbComponents || typeof _wbComponents.canUseXtermInEnvironment !== 'function' || typeof _wbComponents.XtermTerminalEngine !== 'function') {
|
|
8841
|
+
return false;
|
|
8842
|
+
}
|
|
8843
|
+
return Boolean(_wbComponents.canUseXtermInEnvironment(this.container));
|
|
8844
|
+
}
|
|
8845
|
+
|
|
8846
|
+
_getActiveXtermEngine() {
|
|
8847
|
+
if (!(this._xtermEngines instanceof Map)) return null;
|
|
8848
|
+
const sessions = this._ensureTerminalSessions();
|
|
8849
|
+
const activeId = this._activeTerminalSessionId || (sessions[0] && sessions[0].id) || 'session-1';
|
|
8850
|
+
return this._xtermEngines.get(activeId) || null;
|
|
8851
|
+
}
|
|
8852
|
+
|
|
8853
|
+
_getOrCreateXtermEngineForSession(session, fontPx) {
|
|
8854
|
+
if (!this._shouldUseXterm() || !session) return null;
|
|
8855
|
+
if (!(this._xtermEngines instanceof Map)) {
|
|
8856
|
+
this._xtermEngines = new Map();
|
|
8857
|
+
}
|
|
8858
|
+
let eng = this._xtermEngines.get(session.id);
|
|
8859
|
+
const resolvedTheme = this._resolvedTheme();
|
|
8860
|
+
if (!eng) {
|
|
8861
|
+
eng = new _wbComponents.XtermTerminalEngine(null, {
|
|
8862
|
+
cwd: session.cwd || this.cwd || '/workspace',
|
|
8863
|
+
theme: resolvedTheme,
|
|
8864
|
+
fontSize: fontPx || 13,
|
|
8865
|
+
maxScrollback: this._getTerminalScrollback(),
|
|
8866
|
+
initialLogs: Array.isArray(session.logs) ? session.logs : [],
|
|
8867
|
+
onCommand: (cmd) => {
|
|
8868
|
+
if (this._activeTerminalSessionId !== session.id) {
|
|
8869
|
+
this.switchTerminalSession(session.id);
|
|
8870
|
+
}
|
|
8871
|
+
return this._handleReplCommand(cmd, { skipEcho: true });
|
|
8872
|
+
},
|
|
8873
|
+
onInterrupt: () => {
|
|
8874
|
+
if (this._activeTerminalSessionId !== session.id) {
|
|
8875
|
+
this.switchTerminalSession(session.id);
|
|
8876
|
+
}
|
|
8877
|
+
this._handleInterrupt({ fromXterm: true });
|
|
8878
|
+
},
|
|
8879
|
+
getCompletions: (buf, cur) => {
|
|
8880
|
+
const slice = String(buf || '').slice(0, typeof cur === 'number' ? cur : String(buf || '').length);
|
|
8881
|
+
const lastSpace = slice.lastIndexOf(' ');
|
|
8882
|
+
const tokenStart = lastSpace === -1 ? 0 : lastSpace + 1;
|
|
8883
|
+
const token = slice.slice(tokenStart);
|
|
8884
|
+
const matches = this._getCompletionCandidates(slice);
|
|
8885
|
+
return { tokenStart, token, matches };
|
|
8886
|
+
},
|
|
8887
|
+
onOpenFileLink: (relFile, lineNum, colNum) => {
|
|
8888
|
+
const clean = String(relFile || '').replace(/^\/workspace\//, '').replace(/^\/+/, '');
|
|
8889
|
+
if (clean && this.files && Object.prototype.hasOwnProperty.call(this.files, clean)) {
|
|
8890
|
+
this.openFile(clean);
|
|
8891
|
+
this._revealLineColInActiveEditor(lineNum || 1, colNum || 1);
|
|
8892
|
+
}
|
|
8893
|
+
}
|
|
8894
|
+
});
|
|
8895
|
+
session.logs = eng.logs;
|
|
8896
|
+
if (session.id === this._activeTerminalSessionId) {
|
|
8897
|
+
this.terminalLogs = eng.logs;
|
|
8898
|
+
}
|
|
8899
|
+
this._xtermEngines.set(session.id, eng);
|
|
8900
|
+
} else {
|
|
8901
|
+
if (typeof eng.setTheme === 'function') eng.setTheme(resolvedTheme);
|
|
8902
|
+
if (typeof eng.setFontSize === 'function') eng.setFontSize(fontPx || 13);
|
|
8903
|
+
if (typeof eng.setMaxScrollback === 'function') eng.setMaxScrollback(this._getTerminalScrollback());
|
|
8904
|
+
}
|
|
8905
|
+
return eng;
|
|
8906
|
+
}
|
|
8907
|
+
|
|
8908
|
+
_renderXtermTerminalBody(bodyEl, termFontPx) {
|
|
8909
|
+
if (!bodyEl || typeof document === 'undefined') return;
|
|
8910
|
+
const sessions = this._ensureTerminalSessions();
|
|
8911
|
+
const activeSession = sessions.find(s => s.id === this._activeTerminalSessionId) || sessions[0];
|
|
8912
|
+
if (!activeSession) return;
|
|
8913
|
+
|
|
8914
|
+
let leftSplit = null;
|
|
8915
|
+
let rightSplit = null;
|
|
8916
|
+
if (Array.isArray(this._splitTerminalSessionIds) && this._splitTerminalSessionIds.length >= 2) {
|
|
8917
|
+
const s0 = sessions.find(s => s.id === this._splitTerminalSessionIds[0]) || null;
|
|
8918
|
+
const s1 = sessions.find(s => s.id === this._splitTerminalSessionIds[1]) || null;
|
|
8919
|
+
if (s0 && s1 && s0.id !== s1.id && (activeSession.id === s0.id || activeSession.id === s1.id)) {
|
|
8920
|
+
leftSplit = s0;
|
|
8921
|
+
rightSplit = s1;
|
|
8922
|
+
} else if (!s0 || !s1 || s0.id === s1.id) {
|
|
8923
|
+
this._splitTerminalSessionIds = [];
|
|
8924
|
+
this._splitTerminalSessionId = null;
|
|
8925
|
+
}
|
|
8926
|
+
} else if (this._splitTerminalSessionId && this._splitTerminalSessionId !== activeSession.id) {
|
|
8927
|
+
const s1 = sessions.find(s => s.id === this._splitTerminalSessionId) || null;
|
|
8928
|
+
if (s1) {
|
|
8929
|
+
leftSplit = activeSession;
|
|
8930
|
+
rightSplit = s1;
|
|
8931
|
+
this._splitTerminalSessionIds = [activeSession.id, s1.id];
|
|
8932
|
+
} else {
|
|
8933
|
+
this._splitTerminalSessionId = null;
|
|
8934
|
+
}
|
|
8935
|
+
}
|
|
8936
|
+
|
|
8937
|
+
const isSplit = Boolean(leftSplit && rightSplit);
|
|
8938
|
+
const panes = isSplit ? [leftSplit, rightSplit] : [activeSession];
|
|
8939
|
+
const layoutKey = isSplit ? `${leftSplit.id}|${rightSplit.id}` : activeSession.id;
|
|
8940
|
+
|
|
8941
|
+
if (!this._xtermWrapEl || this._xtermWrapLayoutKey !== layoutKey) {
|
|
8942
|
+
if (this._xtermWrapEl && this._xtermWrapEl.parentNode) {
|
|
8943
|
+
try { this._xtermWrapEl.parentNode.removeChild(this._xtermWrapEl); } catch (_e) { void _e; }
|
|
8944
|
+
}
|
|
8945
|
+
const wrap = document.createElement('div');
|
|
8946
|
+
wrap.className = 'codelab-terminal-split-wrap codelab-terminal-split-grid' + (isSplit ? ' is-split' : '');
|
|
8947
|
+
bodyEl.innerHTML = '';
|
|
8948
|
+
bodyEl.appendChild(wrap);
|
|
8949
|
+
this._xtermWrapEl = wrap;
|
|
8950
|
+
this._xtermWrapLayoutKey = layoutKey;
|
|
8951
|
+
|
|
8952
|
+
for (const sess of panes) {
|
|
8953
|
+
const pane = document.createElement('div');
|
|
8954
|
+
pane.className = 'codelab-terminal-pane codelab-terminal-split-pane' + (sess.id === activeSession.id ? ' is-focused' : '');
|
|
8955
|
+
pane.setAttribute('data-session-id', sess.id);
|
|
8956
|
+
pane.addEventListener('pointerdown', () => {
|
|
8957
|
+
if (this._activeTerminalSessionId !== sess.id) {
|
|
8958
|
+
this._saveActiveTerminalSessionState();
|
|
8959
|
+
this._applyTerminalSessionState(sess);
|
|
8960
|
+
this._renderTerminalSessionsBar();
|
|
8961
|
+
this._renderXtermTerminalBody(bodyEl, termFontPx);
|
|
8962
|
+
}
|
|
8963
|
+
});
|
|
8964
|
+
wrap.appendChild(pane);
|
|
8965
|
+
const eng = this._getOrCreateXtermEngineForSession(sess, termFontPx);
|
|
8966
|
+
if (eng) {
|
|
8967
|
+
eng.mount(pane);
|
|
8968
|
+
}
|
|
8969
|
+
}
|
|
8970
|
+
} else if (this._xtermWrapEl.parentNode !== bodyEl) {
|
|
8971
|
+
bodyEl.innerHTML = '';
|
|
8972
|
+
bodyEl.appendChild(this._xtermWrapEl);
|
|
8973
|
+
}
|
|
8974
|
+
|
|
8975
|
+
if (this._xtermWrapEl) {
|
|
8976
|
+
this._xtermWrapEl.querySelectorAll('.codelab-terminal-pane').forEach(pane => {
|
|
8977
|
+
const sid = pane.getAttribute('data-session-id') || '';
|
|
8978
|
+
const isPaneActive = sid === activeSession.id;
|
|
8979
|
+
pane.classList.toggle('is-focused', isPaneActive);
|
|
8980
|
+
pane.querySelectorAll('[id]').forEach(el => {
|
|
8981
|
+
const baseId = el.getAttribute('data-cl-base-id') || el.id.replace(new RegExp(`-${sid}$`), '');
|
|
8982
|
+
el.setAttribute('data-cl-base-id', baseId);
|
|
8983
|
+
el.id = (!isSplit || isPaneActive) ? baseId : `${baseId}-${sid}`;
|
|
8984
|
+
});
|
|
8985
|
+
});
|
|
8986
|
+
}
|
|
8987
|
+
|
|
8988
|
+
const activeEng = this._getOrCreateXtermEngineForSession(activeSession, termFontPx);
|
|
8989
|
+
if (activeEng) {
|
|
8990
|
+
if (typeof activeEng.syncDomMirrorWithLogs === 'function') {
|
|
8991
|
+
activeEng.syncDomMirrorWithLogs(this.terminalLogs);
|
|
8992
|
+
}
|
|
8993
|
+
this.terminalLogs = activeEng.logs;
|
|
8994
|
+
activeSession.logs = activeEng.logs;
|
|
8995
|
+
if (typeof activeEng.setCwd === 'function') activeEng.setCwd(this.cwd || '/workspace');
|
|
8996
|
+
if (typeof activeEng.setReplMode === 'function') activeEng.setReplMode(Boolean(this.inRepl), this.replLang || 'node');
|
|
8997
|
+
if (typeof activeEng.setBusy === 'function') activeEng.setBusy(Boolean(this.isRunning));
|
|
8998
|
+
if (typeof activeEng.fit === 'function') activeEng.fit();
|
|
8999
|
+
}
|
|
9000
|
+
if (isSplit) {
|
|
9001
|
+
const otherSess = leftSplit.id === activeSession.id ? rightSplit : leftSplit;
|
|
9002
|
+
const otherEng = this._getOrCreateXtermEngineForSession(otherSess, termFontPx);
|
|
9003
|
+
if (otherEng && typeof otherEng.fit === 'function') otherEng.fit();
|
|
9004
|
+
}
|
|
9005
|
+
}
|
|
9006
|
+
|
|
9007
|
+
splitActiveTerminalSession() {
|
|
9008
|
+
const sessions = this._ensureTerminalSessions();
|
|
9009
|
+
if ((Array.isArray(this._splitTerminalSessionIds) && this._splitTerminalSessionIds.length >= 2) || this._splitTerminalSessionId) {
|
|
9010
|
+
this._splitTerminalSessionIds = [];
|
|
9011
|
+
this._splitTerminalSessionId = null;
|
|
9012
|
+
this._xtermWrapLayoutKey = '';
|
|
9013
|
+
this._renderDrawerBody();
|
|
9014
|
+
return null;
|
|
9015
|
+
}
|
|
9016
|
+
const primaryId = this._activeTerminalSessionId || (sessions[0] && sessions[0].id);
|
|
9017
|
+
let second = sessions.find(s => s.id !== primaryId);
|
|
9018
|
+
if (!second) {
|
|
9019
|
+
const newId = this.createTerminalSession();
|
|
9020
|
+
second = this._terminalSessions.find(s => s.id === newId);
|
|
9021
|
+
if (primaryId) {
|
|
9022
|
+
const orig = this._terminalSessions.find(s => s.id === primaryId);
|
|
9023
|
+
if (orig) this._applyTerminalSessionState(orig);
|
|
9024
|
+
}
|
|
9025
|
+
}
|
|
9026
|
+
if (second && primaryId) {
|
|
9027
|
+
this._splitTerminalSessionIds = [primaryId, second.id];
|
|
9028
|
+
this._splitTerminalSessionId = second.id;
|
|
9029
|
+
this._xtermWrapLayoutKey = '';
|
|
9030
|
+
this.switchDrawerTab('terminal', { ensureVisible: true, focus: true });
|
|
9031
|
+
return second.id;
|
|
9032
|
+
}
|
|
9033
|
+
return null;
|
|
9034
|
+
}
|
|
9035
|
+
|
|
9036
|
+
async _requestInteractiveTerminalStdin(promptText = '', signal = null) {
|
|
9037
|
+
if (this.customStdin && String(this.customStdin).length > 0) {
|
|
9038
|
+
const lines = String(this.customStdin).split(/\r?\n/);
|
|
9039
|
+
const first = lines.shift() ?? '';
|
|
9040
|
+
this.customStdin = lines.join('\n');
|
|
9041
|
+
return first;
|
|
9042
|
+
}
|
|
9043
|
+
const activeXterm = this._getActiveXtermEngine();
|
|
9044
|
+
if (activeXterm && typeof activeXterm.readLine === 'function') {
|
|
9045
|
+
if (!this.panelVisible || this.drawerTab !== 'terminal') {
|
|
9046
|
+
this.switchDrawerTab('terminal', { ensureVisible: true, focus: true });
|
|
9047
|
+
} else {
|
|
9048
|
+
activeXterm.focus();
|
|
9049
|
+
}
|
|
9050
|
+
return activeXterm.readLine(String(promptText ?? ''), { signal: signal || undefined });
|
|
9051
|
+
}
|
|
9052
|
+
if (this.ptyEngine && typeof this.ptyEngine.readLine === 'function' && this.ptyEngine.container) {
|
|
9053
|
+
return this.ptyEngine.readLine(String(promptText ?? ''), { signal: signal || undefined });
|
|
9054
|
+
}
|
|
9055
|
+
return null;
|
|
9056
|
+
}
|
|
9057
|
+
|
|
9058
|
+
_renderExplorerOutlineAndTimeline() {
|
|
9059
|
+
if (!this.container || typeof this.container.querySelector !== 'function') return;
|
|
9060
|
+
const outlineBody = this.container.querySelector('#cl-explorer-outline-body');
|
|
9061
|
+
const timelineBody = this.container.querySelector('#cl-explorer-timeline-body');
|
|
9062
|
+
if (outlineBody) {
|
|
9063
|
+
const activeFile = (this.activeTab === '__settings__' || this.activeTab === '__welcome__') ? null : this.activeFile;
|
|
9064
|
+
const code = (activeFile && this.files && typeof this.files[activeFile] === 'string') ? this.files[activeFile] : '';
|
|
9065
|
+
const symbols = (activeFile && code && _wbComponents && typeof _wbComponents.extractDocumentSymbols === 'function')
|
|
9066
|
+
? _wbComponents.extractDocumentSymbols(activeFile, code)
|
|
9067
|
+
: [];
|
|
9068
|
+
if (!symbols || symbols.length === 0) {
|
|
9069
|
+
outlineBody.innerHTML = `<div class="codelab-explorer-section__empty">${activeFile ? 'No symbols found in active editor.' : 'Open a file to inspect symbols.'}</div>`;
|
|
9070
|
+
} else {
|
|
9071
|
+
outlineBody.innerHTML = symbols.slice(0, 80).map(sym => `
|
|
9072
|
+
<button type="button" class="codelab-outline-item" data-cl-action="reveal-symbol" data-symbol-file="${escapeHtml(sym.file || activeFile)}" data-symbol-line="${Number(sym.line || 1)}" data-symbol-col="${Number(sym.column || 1)}" title="${escapeHtml(sym.name)} (Ln ${Number(sym.line || 1)})">
|
|
9073
|
+
<span class="codelab-outline-item__kind codelab-outline-item__kind--${escapeHtml(sym.kind || 'variable')}">${escapeHtml((sym.kind || 'sym').slice(0, 1).toUpperCase())}</span>
|
|
9074
|
+
<span class="codelab-outline-item__name">${escapeHtml(sym.name)}</span>
|
|
9075
|
+
<span class="codelab-outline-item__line">:${Number(sym.line || 1)}</span>
|
|
9076
|
+
</button>
|
|
9077
|
+
`).join('');
|
|
9078
|
+
}
|
|
9079
|
+
}
|
|
9080
|
+
if (timelineBody) {
|
|
9081
|
+
const commits = typeof this.getGitLog === 'function' ? this.getGitLog(15) : [];
|
|
9082
|
+
if (!commits || commits.length === 0) {
|
|
9083
|
+
timelineBody.innerHTML = '<div class="codelab-explorer-section__empty">No Git commits recorded yet.</div>';
|
|
9084
|
+
} else {
|
|
9085
|
+
timelineBody.innerHTML = commits.map(c => `
|
|
9086
|
+
<div class="codelab-timeline-item" title="${escapeHtml(c.hash)} — ${escapeHtml(c.author || '')}">
|
|
9087
|
+
<span class="codelab-timeline-item__dot" aria-hidden="true"></span>
|
|
9088
|
+
<span class="codelab-timeline-item__msg">${escapeHtml(c.message)}</span>
|
|
9089
|
+
<span class="codelab-timeline-item__hash">${escapeHtml(String(c.hash || '').slice(0, 7))}</span>
|
|
9090
|
+
</div>
|
|
9091
|
+
`).join('');
|
|
9092
|
+
}
|
|
9093
|
+
}
|
|
9094
|
+
}
|
|
9095
|
+
|
|
8507
9096
|
switchDrawerTab(tab, opts = {}) {
|
|
8508
9097
|
if (!tab) return;
|
|
8509
9098
|
if (!opts || !opts.fromConfig) {
|
|
@@ -8538,8 +9127,13 @@ int main() {
|
|
|
8538
9127
|
}
|
|
8539
9128
|
this._renderDrawerBody();
|
|
8540
9129
|
if (opts && opts.focus && this.drawerTab === 'terminal' && this.container) {
|
|
8541
|
-
const
|
|
8542
|
-
if (
|
|
9130
|
+
const activeXterm = this._getActiveXtermEngine();
|
|
9131
|
+
if (activeXterm && typeof activeXterm.focus === 'function') {
|
|
9132
|
+
activeXterm.focus();
|
|
9133
|
+
} else {
|
|
9134
|
+
const termInput = this.container.querySelector('#cl-repl-input');
|
|
9135
|
+
if (termInput && typeof termInput.focus === 'function') termInput.focus();
|
|
9136
|
+
}
|
|
8543
9137
|
}
|
|
8544
9138
|
if (!opts || (!opts.fromConfig && !opts.skipSave)) {
|
|
8545
9139
|
this._saveState();
|
|
@@ -8548,6 +9142,11 @@ int main() {
|
|
|
8548
9142
|
|
|
8549
9143
|
setPanelVisible(visible, opts = {}) {
|
|
8550
9144
|
const next = Boolean(visible);
|
|
9145
|
+
if (!next && this.panelHeight >= 100) {
|
|
9146
|
+
this._savedPanelHeight = this.panelHeight;
|
|
9147
|
+
} else if (next && (!this.panelHeight || this.panelHeight < 100)) {
|
|
9148
|
+
this.panelHeight = Math.max(140, this._savedPanelHeight || 220);
|
|
9149
|
+
}
|
|
8551
9150
|
this.panelVisible = next;
|
|
8552
9151
|
this.drawerCollapsed = !next;
|
|
8553
9152
|
if (!next) {
|
|
@@ -8557,7 +9156,11 @@ int main() {
|
|
|
8557
9156
|
const shell = this.container.querySelector('.codelab');
|
|
8558
9157
|
if (shell && shell.classList) {
|
|
8559
9158
|
shell.classList.toggle('panel-collapsed', !next);
|
|
8560
|
-
if (!next)
|
|
9159
|
+
if (!next) {
|
|
9160
|
+
shell.classList.remove('panel-maximized');
|
|
9161
|
+
} else if (this.panelHeight >= 100) {
|
|
9162
|
+
this._setShellCssVar(shell, '--cl-drawer-height', `${this.panelHeight}px`);
|
|
9163
|
+
}
|
|
8561
9164
|
}
|
|
8562
9165
|
const drawer = this.container.querySelector('#cl-drawer');
|
|
8563
9166
|
if (drawer && drawer.classList) {
|
|
@@ -8568,16 +9171,25 @@ int main() {
|
|
|
8568
9171
|
toggleBtn.classList.toggle('active', next);
|
|
8569
9172
|
toggleBtn.setAttribute('aria-pressed', String(next));
|
|
8570
9173
|
}
|
|
9174
|
+
const statusToggleBtn = this.container.querySelector('#cl-status-panel-toggle');
|
|
9175
|
+
if (statusToggleBtn) {
|
|
9176
|
+
statusToggleBtn.classList.toggle('active', next);
|
|
9177
|
+
statusToggleBtn.setAttribute('aria-pressed', String(next));
|
|
9178
|
+
}
|
|
8571
9179
|
}
|
|
8572
9180
|
if (this.editor && typeof this.editor.layout === 'function') {
|
|
8573
9181
|
this.editor.layout();
|
|
8574
9182
|
setTimeout(() => {
|
|
8575
9183
|
if (this.editor && typeof this.editor.layout === 'function') this.editor.layout();
|
|
9184
|
+
if (next) {
|
|
9185
|
+
const activeXterm = this._getActiveXtermEngine();
|
|
9186
|
+
if (activeXterm && typeof activeXterm.fit === 'function') activeXterm.fit();
|
|
9187
|
+
}
|
|
8576
9188
|
}, 50);
|
|
8577
9189
|
}
|
|
8578
9190
|
if (!opts || !opts.skipRender) {
|
|
8579
9191
|
if (next) this._renderDrawerBody();
|
|
8580
|
-
this._saveState();
|
|
9192
|
+
if (!opts || !opts.skipSave) this._saveState();
|
|
8581
9193
|
}
|
|
8582
9194
|
return this.panelVisible;
|
|
8583
9195
|
}
|
|
@@ -8611,6 +9223,8 @@ int main() {
|
|
|
8611
9223
|
this.editor.layout();
|
|
8612
9224
|
setTimeout(() => {
|
|
8613
9225
|
if (this.editor && typeof this.editor.layout === 'function') this.editor.layout();
|
|
9226
|
+
const activeXterm = this._getActiveXtermEngine();
|
|
9227
|
+
if (activeXterm && typeof activeXterm.fit === 'function') activeXterm.fit();
|
|
8614
9228
|
}, 50);
|
|
8615
9229
|
}
|
|
8616
9230
|
this._saveState();
|
|
@@ -8620,7 +9234,7 @@ int main() {
|
|
|
8620
9234
|
toggleTerminal() {
|
|
8621
9235
|
if (this.panelVisible && this.drawerTab === 'terminal') {
|
|
8622
9236
|
this.setPanelVisible(false);
|
|
8623
|
-
if (this.editor && typeof this.editor.focus === 'function' && this.activeTab !== '__settings__') {
|
|
9237
|
+
if (this.editor && typeof this.editor.focus === 'function' && this.activeTab !== '__settings__' && this.activeTab !== '__welcome__') {
|
|
8624
9238
|
this.editor.focus();
|
|
8625
9239
|
}
|
|
8626
9240
|
return false;
|
|
@@ -10033,6 +10647,40 @@ int main() {
|
|
|
10033
10647
|
loadMonaco(this.monacoUrl).then(m => {
|
|
10034
10648
|
if (this._destroyed || !this.container) return;
|
|
10035
10649
|
this.monaco = m;
|
|
10650
|
+
const wsPrefix = '/workspace-' + encodeURIComponent(this.instanceId);
|
|
10651
|
+
if (_wbComponents && typeof _wbComponents.initializeMonacoIntelligence === 'function') {
|
|
10652
|
+
try {
|
|
10653
|
+
_wbComponents.initializeMonacoIntelligence(m, () => this.files || {});
|
|
10654
|
+
} catch (err) {
|
|
10655
|
+
this.logger.debug('initializeMonacoIntelligence skipped.', err);
|
|
10656
|
+
}
|
|
10657
|
+
}
|
|
10658
|
+
if (_wbComponents && typeof _wbComponents.syncTsConfigToMonaco === 'function') {
|
|
10659
|
+
try {
|
|
10660
|
+
_wbComponents.syncTsConfigToMonaco(m, this.files || {}, 'file://' + wsPrefix);
|
|
10661
|
+
} catch (err) {
|
|
10662
|
+
this.logger.debug('syncTsConfigToMonaco skipped.', err);
|
|
10663
|
+
}
|
|
10664
|
+
}
|
|
10665
|
+
if (Array.isArray(this._monacoReadyHooks)) {
|
|
10666
|
+
for (const fn of this._monacoReadyHooks) {
|
|
10667
|
+
if (typeof fn === 'function') {
|
|
10668
|
+
try {
|
|
10669
|
+
fn(m);
|
|
10670
|
+
} catch (err) {
|
|
10671
|
+
this.logger.debug('Extension monacoReadyHook threw.', err);
|
|
10672
|
+
}
|
|
10673
|
+
}
|
|
10674
|
+
}
|
|
10675
|
+
}
|
|
10676
|
+
if (!this._ataController && _wbComponents && typeof _wbComponents.WorkspaceAtaController === 'function') {
|
|
10677
|
+
try {
|
|
10678
|
+
this._ataController = new _wbComponents.WorkspaceAtaController(m);
|
|
10679
|
+
this._ataController.scheduleScan(this.files || {});
|
|
10680
|
+
} catch (err) {
|
|
10681
|
+
this.logger.debug('WorkspaceAtaController init skipped.', err);
|
|
10682
|
+
}
|
|
10683
|
+
}
|
|
10036
10684
|
if (this._diagnosticsStore && typeof this._diagnosticsStore.setFileDiagnostics === 'function' && this.files) {
|
|
10037
10685
|
for (const fn of Object.keys(this.files)) {
|
|
10038
10686
|
if (/\.(?:m?js|cjs|ts)$/i.test(fn)) {
|
|
@@ -10093,11 +10741,13 @@ int main() {
|
|
|
10093
10741
|
}
|
|
10094
10742
|
|
|
10095
10743
|
const resolvedInitTheme = this._resolvedTheme();
|
|
10096
|
-
const initMonacoTheme =
|
|
10097
|
-
?
|
|
10098
|
-
: resolvedInitTheme === '
|
|
10099
|
-
? 'codelab-
|
|
10100
|
-
: '
|
|
10744
|
+
const initMonacoTheme = (_wbComponents && typeof _wbComponents.getMonacoThemeName === 'function')
|
|
10745
|
+
? _wbComponents.getMonacoThemeName(resolvedInitTheme, m)
|
|
10746
|
+
: (resolvedInitTheme === 'light'
|
|
10747
|
+
? 'codelab-light'
|
|
10748
|
+
: resolvedInitTheme === 'high-contrast'
|
|
10749
|
+
? 'codelab-hc-dark'
|
|
10750
|
+
: 'codelab-dark');
|
|
10101
10751
|
|
|
10102
10752
|
// Create models for all code files
|
|
10103
10753
|
this._syncAllModels();
|
|
@@ -10120,9 +10770,25 @@ int main() {
|
|
|
10120
10770
|
smoothScrolling: true,
|
|
10121
10771
|
cursorBlinking: 'smooth',
|
|
10122
10772
|
renderLineHighlight: 'all',
|
|
10123
|
-
bracketPairColorization: { enabled: true }
|
|
10773
|
+
bracketPairColorization: { enabled: true },
|
|
10774
|
+
glyphMargin: false,
|
|
10775
|
+
folding: true
|
|
10124
10776
|
});
|
|
10125
10777
|
|
|
10778
|
+
if (_wbComponents && typeof _wbComponents.registerCrossFileEditorOpener === 'function') {
|
|
10779
|
+
this._editorOpenerDisposable = _wbComponents.registerCrossFileEditorOpener(m, (relFile, ln, col) => {
|
|
10780
|
+
if (this.files && Object.prototype.hasOwnProperty.call(this.files, relFile)) {
|
|
10781
|
+
this.openFile(relFile);
|
|
10782
|
+
this._revealLineColInActiveEditor(ln || 1, col || 1);
|
|
10783
|
+
return true;
|
|
10784
|
+
}
|
|
10785
|
+
return false;
|
|
10786
|
+
}, wsPrefix);
|
|
10787
|
+
}
|
|
10788
|
+
if (_wbComponents && typeof _wbComponents.attachAutoCloseTagBehavior === 'function') {
|
|
10789
|
+
this._autoCloseTagDisposable = _wbComponents.attachAutoCloseTagBehavior(m, this.editor);
|
|
10790
|
+
}
|
|
10791
|
+
|
|
10126
10792
|
this._applyConfigurationChanges(null);
|
|
10127
10793
|
|
|
10128
10794
|
if (typeof this.editor.onDidBlurEditorWidget === 'function') {
|
|
@@ -10206,15 +10872,21 @@ int main() {
|
|
|
10206
10872
|
if (liveFallbackWrap) liveFallbackWrap.style.display = 'none';
|
|
10207
10873
|
this._syncActiveFileToView();
|
|
10208
10874
|
|
|
10209
|
-
// Watch theme changes on <html>
|
|
10210
|
-
|
|
10875
|
+
// Watch theme changes on <html> only when document theme sync is active
|
|
10876
|
+
const observeDocTheme = Boolean(
|
|
10877
|
+
(this.options && (this.options.fullbleed || this.options.syncDocumentTheme)) ||
|
|
10878
|
+
(typeof document !== 'undefined' && document.documentElement && document.documentElement.hasAttribute('data-theme'))
|
|
10879
|
+
);
|
|
10880
|
+
if (typeof MutationObserver !== 'undefined' && observeDocTheme && typeof document !== 'undefined' && document.documentElement) {
|
|
10211
10881
|
this._themeObserver = new MutationObserver(() => {
|
|
10212
10882
|
const rt = this._resolvedTheme();
|
|
10213
|
-
const targetMonacoTheme =
|
|
10214
|
-
?
|
|
10215
|
-
: rt === '
|
|
10216
|
-
? 'codelab-
|
|
10217
|
-
: '
|
|
10883
|
+
const targetMonacoTheme = (_wbComponents && typeof _wbComponents.getMonacoThemeName === 'function')
|
|
10884
|
+
? _wbComponents.getMonacoThemeName(rt, m)
|
|
10885
|
+
: (rt === 'light'
|
|
10886
|
+
? 'codelab-light'
|
|
10887
|
+
: rt === 'high-contrast'
|
|
10888
|
+
? 'codelab-hc-dark'
|
|
10889
|
+
: 'codelab-dark');
|
|
10218
10890
|
m.editor.setTheme(targetMonacoTheme);
|
|
10219
10891
|
});
|
|
10220
10892
|
this._themeObserver.observe(document.documentElement, {
|
|
@@ -10222,7 +10894,8 @@ int main() {
|
|
|
10222
10894
|
attributeFilter: ['data-theme']
|
|
10223
10895
|
});
|
|
10224
10896
|
}
|
|
10225
|
-
}).catch(() => {
|
|
10897
|
+
}).catch((err) => {
|
|
10898
|
+
void err;
|
|
10226
10899
|
if (this._destroyed || !this.container) return;
|
|
10227
10900
|
// Fallback editor remains visible if offline / CDN blocked
|
|
10228
10901
|
const liveFallbackWrap = this.container.querySelector('#cl-fallback-wrap');
|
|
@@ -10257,6 +10930,20 @@ int main() {
|
|
|
10257
10930
|
if (cleanRel.startsWith('.codelab/') && !this._syncingWorkspaceSettingsFile) {
|
|
10258
10931
|
this._syncDotCodelabConfig({ isInitialMount: false });
|
|
10259
10932
|
}
|
|
10933
|
+
if (this.monaco && (cleanRel === 'tsconfig.json' || cleanRel === 'jsconfig.json') && _wbComponents && typeof _wbComponents.syncTsConfigToMonaco === 'function') {
|
|
10934
|
+
try {
|
|
10935
|
+
_wbComponents.syncTsConfigToMonaco(this.monaco, this.files || {}, 'file:///workspace-' + encodeURIComponent(this.instanceId));
|
|
10936
|
+
} catch (err) {
|
|
10937
|
+
this.logger.debug('Live tsconfig sync skipped.', err);
|
|
10938
|
+
}
|
|
10939
|
+
}
|
|
10940
|
+
if (this._ataController && (cleanRel === 'package.json' || /\.(?:m?js|cjs|jsx|ts|tsx)$/i.test(cleanRel))) {
|
|
10941
|
+
try {
|
|
10942
|
+
this._ataController.scheduleScan(this.files || {});
|
|
10943
|
+
} catch (err) {
|
|
10944
|
+
this.logger.debug('ATA scan skipped.', err);
|
|
10945
|
+
}
|
|
10946
|
+
}
|
|
10260
10947
|
if (this._lintDebounceTimer) {
|
|
10261
10948
|
clearTimeout(this._lintDebounceTimer);
|
|
10262
10949
|
}
|
|
@@ -10269,6 +10956,10 @@ int main() {
|
|
|
10269
10956
|
if (this.activeSidebarView === 'scm' && typeof this._renderScmSidebar === 'function') {
|
|
10270
10957
|
this._renderScmSidebar();
|
|
10271
10958
|
}
|
|
10959
|
+
this._updateEditorGitGutter();
|
|
10960
|
+
if (this.activeSidebarView === 'explorer' && typeof this._renderExplorerOutlineAndTimeline === 'function') {
|
|
10961
|
+
this._renderExplorerOutlineAndTimeline();
|
|
10962
|
+
}
|
|
10272
10963
|
const allowPreviewReload = !this.configuration || this.configuration.get('preview.autoReload', true) !== false;
|
|
10273
10964
|
if (allowPreviewReload && (this.drawerTab === 'preview' || (this.previewState && this.previewState.dockMode === 'split')) && this.previewState && this.previewState.port) {
|
|
10274
10965
|
if (this._previewReloadTimer) {
|
|
@@ -10307,7 +10998,8 @@ int main() {
|
|
|
10307
10998
|
if (!this.monaco || !this.monaco.editor || typeof this.monaco.editor.getModelMarkers !== 'function') return;
|
|
10308
10999
|
this._ensureDiagnosticsStore();
|
|
10309
11000
|
if (!this._diagnosticsStore || typeof this._diagnosticsStore.setFileDiagnostics !== 'function') return;
|
|
10310
|
-
const
|
|
11001
|
+
const wsPrefix = '/workspace-' + encodeURIComponent(this.instanceId);
|
|
11002
|
+
const prefix = `file://${wsPrefix}/`;
|
|
10311
11003
|
for (const [filename, model] of this.models.entries()) {
|
|
10312
11004
|
const uri = model && model.uri ? model.uri : null;
|
|
10313
11005
|
let markers = [];
|
|
@@ -10343,31 +11035,41 @@ int main() {
|
|
|
10343
11035
|
|
|
10344
11036
|
_getOrCreateModel(filename) {
|
|
10345
11037
|
if (!filename || !this.monaco || !this.monaco.editor) return null;
|
|
10346
|
-
const
|
|
10347
|
-
|
|
10348
|
-
|
|
10349
|
-
|
|
10350
|
-
|
|
10351
|
-
|
|
10352
|
-
|
|
11038
|
+
const wsPrefix = '/workspace-' + encodeURIComponent(this.instanceId);
|
|
11039
|
+
const cleanRel = String(filename).replace(/^\/+/, '');
|
|
11040
|
+
let uri = null;
|
|
11041
|
+
if (_wbComponents && typeof _wbComponents.toWorkspaceModelUri === 'function') {
|
|
11042
|
+
uri = _wbComponents.toWorkspaceModelUri(this.monaco, cleanRel, wsPrefix);
|
|
11043
|
+
}
|
|
11044
|
+
if (!uri) {
|
|
11045
|
+
const uriParser = (this.monaco.Uri && typeof this.monaco.Uri.parse === 'function')
|
|
11046
|
+
? this.monaco.Uri
|
|
11047
|
+
: (this.monaco.editor.Uri && typeof this.monaco.editor.Uri.parse === 'function')
|
|
11048
|
+
? this.monaco.editor.Uri
|
|
11049
|
+
: null;
|
|
11050
|
+
const rawUri = `file://${wsPrefix}/${cleanRel}`;
|
|
11051
|
+
uri = uriParser ? uriParser.parse(rawUri) : { toString: () => rawUri };
|
|
11052
|
+
}
|
|
10353
11053
|
let model = typeof this.monaco.editor.getModel === 'function' ? this.monaco.editor.getModel(uri) : null;
|
|
10354
|
-
const lang =
|
|
10355
|
-
?
|
|
10356
|
-
: /\.
|
|
10357
|
-
? '
|
|
10358
|
-
: /\.
|
|
10359
|
-
? '
|
|
10360
|
-
:
|
|
10361
|
-
? '
|
|
10362
|
-
:
|
|
10363
|
-
? '
|
|
10364
|
-
: filename.endsWith('.
|
|
10365
|
-
? '
|
|
10366
|
-
: filename.endsWith('.
|
|
10367
|
-
? '
|
|
10368
|
-
: filename.endsWith('.
|
|
10369
|
-
? '
|
|
10370
|
-
: '
|
|
11054
|
+
const lang = (_wbComponents && typeof _wbComponents.getMonacoLanguageForFile === 'function')
|
|
11055
|
+
? _wbComponents.getMonacoLanguageForFile(filename, this.lang)
|
|
11056
|
+
: (/\.(cpp|cc|cxx|hpp|h)$/i.test(filename)
|
|
11057
|
+
? 'cpp'
|
|
11058
|
+
: /\.py$/i.test(filename)
|
|
11059
|
+
? 'python'
|
|
11060
|
+
: /\.sql$/i.test(filename)
|
|
11061
|
+
? 'sql'
|
|
11062
|
+
: /\.(?:ts|tsx|mts|cts)$/i.test(filename)
|
|
11063
|
+
? 'typescript'
|
|
11064
|
+
: filename.endsWith('.json')
|
|
11065
|
+
? 'json'
|
|
11066
|
+
: filename.endsWith('.html')
|
|
11067
|
+
? 'html'
|
|
11068
|
+
: filename.endsWith('.css')
|
|
11069
|
+
? 'css'
|
|
11070
|
+
: filename.endsWith('.md')
|
|
11071
|
+
? 'markdown'
|
|
11072
|
+
: 'javascript');
|
|
10371
11073
|
const configuredTabSize = this.configuration
|
|
10372
11074
|
? Math.max(1, Math.min(8, Number(this.configuration.get('editor.tabSize', 2)) || 2))
|
|
10373
11075
|
: 2;
|
|
@@ -10413,22 +11115,218 @@ int main() {
|
|
|
10413
11115
|
return model;
|
|
10414
11116
|
}
|
|
10415
11117
|
|
|
10416
|
-
_syncAllModels() {
|
|
10417
|
-
if (!this.monaco) return;
|
|
10418
|
-
const activeSet = new Set(Object.keys(this.files || {}));
|
|
10419
|
-
for (const [filename, model] of Array.from(this.models.entries())) {
|
|
10420
|
-
if (!activeSet.has(filename)) {
|
|
10421
|
-
if (model && typeof model.dispose === 'function') {
|
|
10422
|
-
try { model.dispose(); } catch (err) { this.logger.debug('Stale model dispose skipped.', err); }
|
|
11118
|
+
_syncAllModels() {
|
|
11119
|
+
if (!this.monaco) return;
|
|
11120
|
+
const activeSet = new Set(Object.keys(this.files || {}));
|
|
11121
|
+
for (const [filename, model] of Array.from(this.models.entries())) {
|
|
11122
|
+
if (!activeSet.has(filename)) {
|
|
11123
|
+
if (model && typeof model.dispose === 'function') {
|
|
11124
|
+
try { model.dispose(); } catch (err) { this.logger.debug('Stale model dispose skipped.', err); }
|
|
11125
|
+
}
|
|
11126
|
+
this.models.delete(filename);
|
|
11127
|
+
}
|
|
11128
|
+
}
|
|
11129
|
+
for (const filename of activeSet) {
|
|
11130
|
+
const content = String(this.files[filename] || '');
|
|
11131
|
+
if (content.length <= 2 * 1024 * 1024 && !content.includes('\x00')) {
|
|
11132
|
+
this._getOrCreateModel(filename);
|
|
11133
|
+
}
|
|
11134
|
+
}
|
|
11135
|
+
if (this.monaco && _wbComponents && typeof _wbComponents.syncTsConfigToMonaco === 'function') {
|
|
11136
|
+
try {
|
|
11137
|
+
_wbComponents.syncTsConfigToMonaco(this.monaco, this.files || {}, 'file:///workspace-' + encodeURIComponent(this.instanceId));
|
|
11138
|
+
} catch (err) {
|
|
11139
|
+
this.logger.debug('syncTsConfigToMonaco after syncAllModels skipped.', err);
|
|
11140
|
+
}
|
|
11141
|
+
}
|
|
11142
|
+
if (this._ataController && typeof this._ataController.scheduleScan === 'function') {
|
|
11143
|
+
try {
|
|
11144
|
+
this._ataController.scheduleScan(this.files || {});
|
|
11145
|
+
} catch (err) {
|
|
11146
|
+
this.logger.debug('ATA scan after syncAllModels skipped.', err);
|
|
11147
|
+
}
|
|
11148
|
+
}
|
|
11149
|
+
}
|
|
11150
|
+
|
|
11151
|
+
_updateEditorGitGutter() {
|
|
11152
|
+
if (!this.editor || !this.monaco || !this.activeFile || this.activeTab === '__settings__' || this.activeTab === '__welcome__') {
|
|
11153
|
+
return;
|
|
11154
|
+
}
|
|
11155
|
+
const scmMod = root.CodeLabScm;
|
|
11156
|
+
const gs = this._getGitState();
|
|
11157
|
+
if (!scmMod || typeof scmMod.computeGitGutterChanges !== 'function' || !gs || !gs.initialized) {
|
|
11158
|
+
if (this._gitGutterDecorations && typeof this._gitGutterDecorations.clear === 'function') {
|
|
11159
|
+
try { this._gitGutterDecorations.clear(); } catch (_err) { void _err; }
|
|
11160
|
+
}
|
|
11161
|
+
return;
|
|
11162
|
+
}
|
|
11163
|
+
const headMap = gs.headFiles || gs.headSnapshot || {};
|
|
11164
|
+
const hasHead = Object.prototype.hasOwnProperty.call(headMap, this.activeFile);
|
|
11165
|
+
const headText = hasHead ? String(headMap[this.activeFile] ?? '') : '';
|
|
11166
|
+
const curText = String(this.files[this.activeFile] ?? '');
|
|
11167
|
+
const changes = hasHead
|
|
11168
|
+
? scmMod.computeGitGutterChanges(headText, curText)
|
|
11169
|
+
: (curText.length > 0 ? [{ type: 'added', startLine: 1, endLine: Math.max(1, curText.split('\n').length) }] : []);
|
|
11170
|
+
const RangeCtor = this.monaco.Range;
|
|
11171
|
+
if (typeof RangeCtor !== 'function') return;
|
|
11172
|
+
const decorations = (changes || []).map((ch) => {
|
|
11173
|
+
const cls = ch.type === 'added'
|
|
11174
|
+
? 'codelab-git-gutter-added'
|
|
11175
|
+
: ch.type === 'deleted'
|
|
11176
|
+
? 'codelab-git-gutter-deleted'
|
|
11177
|
+
: 'codelab-git-gutter-modified';
|
|
11178
|
+
const sLine = Math.max(1, Number(ch.startLine || 1));
|
|
11179
|
+
const eLine = Math.max(sLine, Number(ch.endLine || sLine));
|
|
11180
|
+
return {
|
|
11181
|
+
range: new RangeCtor(sLine, 1, eLine, 1),
|
|
11182
|
+
options: {
|
|
11183
|
+
isWholeLine: true,
|
|
11184
|
+
linesDecorationsClassName: cls
|
|
11185
|
+
}
|
|
11186
|
+
};
|
|
11187
|
+
});
|
|
11188
|
+
if (typeof this.editor.createDecorationsCollection === 'function') {
|
|
11189
|
+
if (!this._gitGutterDecorations) {
|
|
11190
|
+
this._gitGutterDecorations = this.editor.createDecorationsCollection(decorations);
|
|
11191
|
+
} else {
|
|
11192
|
+
this._gitGutterDecorations.set(decorations);
|
|
11193
|
+
}
|
|
11194
|
+
} else if (typeof this.editor.deltaDecorations === 'function') {
|
|
11195
|
+
this._gitGutterDecorationIds = this.editor.deltaDecorations(this._gitGutterDecorationIds || [], decorations);
|
|
11196
|
+
}
|
|
11197
|
+
}
|
|
11198
|
+
|
|
11199
|
+
openWelcomeTab() {
|
|
11200
|
+
this._activeScmDiffFile = null;
|
|
11201
|
+
this.welcomeTabOpen = true;
|
|
11202
|
+
this.activeTab = '__welcome__';
|
|
11203
|
+
this._syncActiveFileToView();
|
|
11204
|
+
}
|
|
11205
|
+
|
|
11206
|
+
closeWelcomeTab() {
|
|
11207
|
+
if (!this.welcomeTabOpen && this.activeTab !== '__welcome__') return;
|
|
11208
|
+
this.welcomeTabOpen = false;
|
|
11209
|
+
const nextFile = (this.activeFile && Array.isArray(this.openTabs) && this.openTabs.includes(this.activeFile))
|
|
11210
|
+
? this.activeFile
|
|
11211
|
+
: (Array.isArray(this.openTabs) && this.openTabs.length > 0 ? this.openTabs[0] : null);
|
|
11212
|
+
this.activeFile = nextFile;
|
|
11213
|
+
this.activeTab = this.settingsTabOpen ? '__settings__' : nextFile;
|
|
11214
|
+
this._syncActiveFileToView();
|
|
11215
|
+
}
|
|
11216
|
+
|
|
11217
|
+
_renderWelcomeHost(welcomeHost) {
|
|
11218
|
+
if (!welcomeHost) return;
|
|
11219
|
+
const wsMod = this._getWorkspaceStorageMod();
|
|
11220
|
+
const recentList = (wsMod && typeof wsMod.listWorkspaces === 'function') ? wsMod.listWorkspaces().slice(0, 5) : [];
|
|
11221
|
+
const templates = (this.options && Array.isArray(this.options.welcomeTemplates))
|
|
11222
|
+
? this.options.welcomeTemplates
|
|
11223
|
+
: [];
|
|
11224
|
+
const templatesHtml = templates.length > 0
|
|
11225
|
+
? `
|
|
11226
|
+
<div class="codelab-welcome__section">
|
|
11227
|
+
<h3 class="codelab-welcome__heading">Start with a Template</h3>
|
|
11228
|
+
<div class="codelab-welcome__templates">
|
|
11229
|
+
${templates.map((tpl) => `
|
|
11230
|
+
<button type="button" class="codelab-welcome__card" data-cl-action="welcome-load-template" data-demo="${escapeHtml(tpl.id || '')}">
|
|
11231
|
+
<span class="codelab-welcome__card-badge">${escapeHtml(tpl.badge || 'Stack')}</span>
|
|
11232
|
+
<strong class="codelab-welcome__card-title">${escapeHtml(tpl.title || tpl.id || 'Template')}</strong>
|
|
11233
|
+
<span class="codelab-welcome__card-desc">${escapeHtml(tpl.description || '')}</span>
|
|
11234
|
+
</button>
|
|
11235
|
+
`).join('')}
|
|
11236
|
+
</div>
|
|
11237
|
+
</div>
|
|
11238
|
+
`
|
|
11239
|
+
: '';
|
|
11240
|
+
const recentHtml = recentList.length > 0
|
|
11241
|
+
? recentList.map((ws) => `
|
|
11242
|
+
<button type="button" class="codelab-welcome__link" data-cl-action="welcome-open-recent" data-workspace-id="${escapeHtml(ws.labId)}">
|
|
11243
|
+
<span>${escapeHtml(ws.title || ws.labId)}</span>
|
|
11244
|
+
<span class="codelab-welcome__link-meta">${escapeHtml(ws.repo || ws.labId)}</span>
|
|
11245
|
+
</button>
|
|
11246
|
+
`).join('')
|
|
11247
|
+
: '<div class="codelab-welcome__muted">No recent workspaces yet.</div>';
|
|
11248
|
+
|
|
11249
|
+
welcomeHost.innerHTML = `
|
|
11250
|
+
<div class="codelab-welcome__inner">
|
|
11251
|
+
<header class="codelab-welcome__hero">
|
|
11252
|
+
<div class="codelab-welcome__title-row">
|
|
11253
|
+
<span class="codelab-welcome__logo" aria-hidden="true">${CL_ICONS.code || ''}</span>
|
|
11254
|
+
<div>
|
|
11255
|
+
<h2 class="codelab-welcome__title">CodeLab Studio</h2>
|
|
11256
|
+
<p class="codelab-welcome__subtitle">Browser-native IDE — Node.js v22 Worker, TypeScript 5, Python 3.12, C++20 WASI, SQL & Git</p>
|
|
11257
|
+
</div>
|
|
11258
|
+
</div>
|
|
11259
|
+
</header>
|
|
11260
|
+
<div class="codelab-welcome__grid">
|
|
11261
|
+
<div class="codelab-welcome__col">
|
|
11262
|
+
<div class="codelab-welcome__section">
|
|
11263
|
+
<h3 class="codelab-welcome__heading">Start</h3>
|
|
11264
|
+
<div class="codelab-welcome__actions">
|
|
11265
|
+
<button type="button" class="codelab-welcome__action" data-cl-action="welcome-new-file">
|
|
11266
|
+
${CL_ICONS.newFile || ''}<span>New File...</span><kbd>⌘N</kbd>
|
|
11267
|
+
</button>
|
|
11268
|
+
<button type="button" class="codelab-welcome__action" data-cl-action="welcome-clone-repo">
|
|
11269
|
+
${CL_ICONS.gitBranch || ''}<span>Clone Git Repository...</span><kbd>⌘⇧G</kbd>
|
|
11270
|
+
</button>
|
|
11271
|
+
<button type="button" class="codelab-welcome__action" data-cl-action="new-blank-workspace">
|
|
11272
|
+
${CL_ICONS.newFolder || ''}<span>New Blank Workspace...</span>
|
|
11273
|
+
</button>
|
|
11274
|
+
<button type="button" class="codelab-welcome__action" data-cl-action="command-palette">
|
|
11275
|
+
${CL_ICONS.search || ''}<span>Show All Commands...</span><kbd>⌘⇧P</kbd>
|
|
11276
|
+
</button>
|
|
11277
|
+
</div>
|
|
11278
|
+
</div>
|
|
11279
|
+
<div class="codelab-welcome__section">
|
|
11280
|
+
<h3 class="codelab-welcome__heading">Clone GitHub Repository</h3>
|
|
11281
|
+
<form class="codelab-welcome__clone-bar" data-cl-welcome-clone-form>
|
|
11282
|
+
<input data-cl-welcome-repo-input class="codelab-welcome__clone-input" type="text" placeholder="owner/repo or https://github.com/owner/repo" autocomplete="off" spellcheck="false" aria-label="GitHub repository URL or owner/repo" />
|
|
11283
|
+
<button data-cl-welcome-clone-btn type="submit" class="codelab-btn codelab-btn--primary">Clone</button>
|
|
11284
|
+
</form>
|
|
11285
|
+
</div>
|
|
11286
|
+
<div class="codelab-welcome__section">
|
|
11287
|
+
<h3 class="codelab-welcome__heading">Recent</h3>
|
|
11288
|
+
<div class="codelab-welcome__recent">${recentHtml}</div>
|
|
11289
|
+
</div>
|
|
11290
|
+
</div>
|
|
11291
|
+
<div class="codelab-welcome__col">
|
|
11292
|
+
${templatesHtml || `
|
|
11293
|
+
<div class="codelab-welcome__section">
|
|
11294
|
+
<h3 class="codelab-welcome__heading">Walkthroughs</h3>
|
|
11295
|
+
<div class="codelab-welcome__walkthroughs">
|
|
11296
|
+
<div class="codelab-welcome__walkthrough">
|
|
11297
|
+
<strong>Full IntelliSense & Cross-File Navigation</strong>
|
|
11298
|
+
<span>Press <kbd>F12</kbd> on any imported function or class to jump directly across workspace files.</span>
|
|
11299
|
+
</div>
|
|
11300
|
+
<div class="codelab-welcome__walkthrough">
|
|
11301
|
+
<strong>Integrated xterm.js & POSIX Shell</strong>
|
|
11302
|
+
<span>Press <kbd>⌃\`</kbd> or <kbd>⌘J</kbd> to toggle the panel, split terminals, or run <code>node</code>, <code>python3</code>, <code>clang++</code>, and <code>git</code>.</span>
|
|
11303
|
+
</div>
|
|
11304
|
+
<div class="codelab-welcome__walkthrough">
|
|
11305
|
+
<strong>Real Git & Side-by-Side Diffs</strong>
|
|
11306
|
+
<span>Stage hunks, switch branches, stash changes, and inspect side-by-side diffs in Source Control.</span>
|
|
11307
|
+
</div>
|
|
11308
|
+
</div>
|
|
11309
|
+
</div>
|
|
11310
|
+
`}
|
|
11311
|
+
</div>
|
|
11312
|
+
</div>
|
|
11313
|
+
</div>
|
|
11314
|
+
`;
|
|
11315
|
+
const cloneForm = welcomeHost.querySelector('[data-cl-welcome-clone-form]');
|
|
11316
|
+
if (cloneForm) {
|
|
11317
|
+
cloneForm.addEventListener('submit', (ev) => {
|
|
11318
|
+
ev.preventDefault();
|
|
11319
|
+
const inp = welcomeHost.querySelector('[data-cl-welcome-repo-input]');
|
|
11320
|
+
const val = inp ? String(inp.value || '').trim() : '';
|
|
11321
|
+
if (!val) {
|
|
11322
|
+
this.openCloneDialog();
|
|
11323
|
+
return;
|
|
10423
11324
|
}
|
|
10424
|
-
this.
|
|
10425
|
-
|
|
10426
|
-
|
|
10427
|
-
|
|
10428
|
-
|
|
10429
|
-
if (content.length <= 2 * 1024 * 1024 && !content.includes('\x00')) {
|
|
10430
|
-
this._getOrCreateModel(filename);
|
|
10431
|
-
}
|
|
11325
|
+
this.closeWelcomeTab();
|
|
11326
|
+
this.cloneRepo(val, { intoRoot: true, force: true }).catch((err) => {
|
|
11327
|
+
this.logger.warn('Welcome clone failed.', err);
|
|
11328
|
+
});
|
|
11329
|
+
});
|
|
10432
11330
|
}
|
|
10433
11331
|
}
|
|
10434
11332
|
|
|
@@ -10439,9 +11337,42 @@ int main() {
|
|
|
10439
11337
|
const fallbackEl = this.container.querySelector('#cl-fallback-editor');
|
|
10440
11338
|
const mdPreview = this.container.querySelector('#cl-md-preview');
|
|
10441
11339
|
const settingsHost = this.container.querySelector('#cl-settings-host');
|
|
11340
|
+
const welcomeHost = this.container.querySelector('#cl-welcome-host');
|
|
10442
11341
|
const inlineDiffHost = this.container.querySelector('#cl-inline-diff-container');
|
|
10443
11342
|
const emptyEl = this.container.querySelector('#cl-empty-editor');
|
|
10444
11343
|
|
|
11344
|
+
// Non-destructive Welcome Tab
|
|
11345
|
+
if (this.welcomeTabOpen && this.activeTab === '__welcome__') {
|
|
11346
|
+
this._activeScmDiffFile = null;
|
|
11347
|
+
if (monacoHost) monacoHost.style.display = 'none';
|
|
11348
|
+
if (sqlHost) sqlHost.style.display = 'none';
|
|
11349
|
+
if (fallbackWrap) fallbackWrap.style.display = 'none';
|
|
11350
|
+
if (mdPreview) mdPreview.style.display = 'none';
|
|
11351
|
+
if (emptyEl) emptyEl.style.display = 'none';
|
|
11352
|
+
if (settingsHost) {
|
|
11353
|
+
settingsHost.hidden = true;
|
|
11354
|
+
if (settingsHost.style) settingsHost.style.display = 'none';
|
|
11355
|
+
}
|
|
11356
|
+
if (inlineDiffHost) {
|
|
11357
|
+
inlineDiffHost.hidden = true;
|
|
11358
|
+
if (inlineDiffHost.style) inlineDiffHost.style.display = 'none';
|
|
11359
|
+
}
|
|
11360
|
+
if (welcomeHost) {
|
|
11361
|
+
welcomeHost.hidden = false;
|
|
11362
|
+
if (welcomeHost.style) welcomeHost.style.display = 'block';
|
|
11363
|
+
this._renderWelcomeHost(welcomeHost);
|
|
11364
|
+
}
|
|
11365
|
+
this._renderFileLists();
|
|
11366
|
+
this._renderBreadcrumbs();
|
|
11367
|
+
this._updateStatusBar();
|
|
11368
|
+
return;
|
|
11369
|
+
}
|
|
11370
|
+
|
|
11371
|
+
if (welcomeHost) {
|
|
11372
|
+
welcomeHost.hidden = true;
|
|
11373
|
+
if (welcomeHost.style) welcomeHost.style.display = 'none';
|
|
11374
|
+
}
|
|
11375
|
+
|
|
10445
11376
|
// Non-destructive Settings Tab: hide code surfaces via display:none WITHOUT calling editor.setModel(null) or disposing!
|
|
10446
11377
|
if (this.settingsTabOpen && this.activeTab === '__settings__') {
|
|
10447
11378
|
this._activeScmDiffFile = null;
|
|
@@ -10490,7 +11421,7 @@ int main() {
|
|
|
10490
11421
|
actSettingsBtn.setAttribute('aria-pressed', 'false');
|
|
10491
11422
|
}
|
|
10492
11423
|
|
|
10493
|
-
// Non-destructive Source Control
|
|
11424
|
+
// Non-destructive Source Control Diff: side-by-side Monaco DiffEditor when available, with unified fallback!
|
|
10494
11425
|
if (this._activeScmDiffFile && inlineDiffHost) {
|
|
10495
11426
|
if (monacoHost) monacoHost.style.display = 'none';
|
|
10496
11427
|
if (sqlHost) sqlHost.style.display = 'none';
|
|
@@ -10505,6 +11436,9 @@ int main() {
|
|
|
10505
11436
|
this._updateStatusBar();
|
|
10506
11437
|
return;
|
|
10507
11438
|
}
|
|
11439
|
+
if (this._scmDiffManager && typeof this._scmDiffManager.closeInlineDiff === 'function') {
|
|
11440
|
+
try { this._scmDiffManager.closeInlineDiff(); } catch (_err) { void _err; }
|
|
11441
|
+
}
|
|
10508
11442
|
if (inlineDiffHost) {
|
|
10509
11443
|
inlineDiffHost.hidden = true;
|
|
10510
11444
|
if (inlineDiffHost.style) inlineDiffHost.style.display = 'none';
|
|
@@ -10572,7 +11506,7 @@ int main() {
|
|
|
10572
11506
|
sqlHost &&
|
|
10573
11507
|
sqlPack &&
|
|
10574
11508
|
typeof sqlPack.createSqlEditor === 'function' &&
|
|
10575
|
-
(!this.editor || (this.options && this.options.editorEngine
|
|
11509
|
+
(this._isSingleFileSqlMode() || !this.editor || (this.options && this.options.editorEngine === 'sql'))
|
|
10576
11510
|
);
|
|
10577
11511
|
|
|
10578
11512
|
if (isMd && this._mdPreviewOpen) {
|
|
@@ -10655,6 +11589,7 @@ int main() {
|
|
|
10655
11589
|
if (model && this.editor.getModel() !== model) {
|
|
10656
11590
|
this.editor.setModel(model);
|
|
10657
11591
|
}
|
|
11592
|
+
this._updateEditorGitGutter();
|
|
10658
11593
|
const pos = typeof this.editor.getPosition === 'function' ? this.editor.getPosition() : null;
|
|
10659
11594
|
if (pos) {
|
|
10660
11595
|
this.cursorPos = {
|
|
@@ -10834,6 +11769,11 @@ int main() {
|
|
|
10834
11769
|
const keyLower = (e.key || '').toLowerCase();
|
|
10835
11770
|
const mod = Boolean(e.metaKey || e.ctrlKey);
|
|
10836
11771
|
const tgt = e.target;
|
|
11772
|
+
const inTerminal = Boolean(
|
|
11773
|
+
tgt &&
|
|
11774
|
+
typeof tgt.closest === 'function' &&
|
|
11775
|
+
tgt.closest('#cl-terminal-surface, .xterm, .codelab-terminal-pane')
|
|
11776
|
+
);
|
|
10837
11777
|
const inCustomContentEditable = Boolean(
|
|
10838
11778
|
tgt &&
|
|
10839
11779
|
(tgt.isContentEditable || (typeof tgt.closest === 'function' && tgt.closest('[contenteditable="true"]'))) &&
|
|
@@ -10842,6 +11782,15 @@ int main() {
|
|
|
10842
11782
|
if (inCustomContentEditable && mod && !e.shiftKey && !e.altKey && keyLower === 'b') {
|
|
10843
11783
|
return;
|
|
10844
11784
|
}
|
|
11785
|
+
if (inTerminal && e.ctrlKey && !e.metaKey && !e.shiftKey && !e.altKey && keyLower === 'b') {
|
|
11786
|
+
return;
|
|
11787
|
+
}
|
|
11788
|
+
if (inTerminal && mod && !e.shiftKey && !e.altKey && e.key === '\\') {
|
|
11789
|
+
e.preventDefault();
|
|
11790
|
+
e.stopPropagation();
|
|
11791
|
+
this.splitActiveTerminalSession();
|
|
11792
|
+
return;
|
|
11793
|
+
}
|
|
10845
11794
|
if (mod && !e.shiftKey && !e.altKey && keyLower === 's') {
|
|
10846
11795
|
e.preventDefault();
|
|
10847
11796
|
e.stopPropagation();
|
|
@@ -10873,8 +11822,13 @@ int main() {
|
|
|
10873
11822
|
this.setPanelVisible(true, { skipRender: true });
|
|
10874
11823
|
this.createTerminalSession();
|
|
10875
11824
|
this.switchDrawerTab('terminal', { ensureVisible: true });
|
|
10876
|
-
const
|
|
10877
|
-
if (
|
|
11825
|
+
const activeXt = this._getActiveXtermEngine();
|
|
11826
|
+
if (activeXt && typeof activeXt.focus === 'function') {
|
|
11827
|
+
activeXt.focus();
|
|
11828
|
+
} else {
|
|
11829
|
+
const termInp = this.container ? this.container.querySelector('#cl-repl-input') : null;
|
|
11830
|
+
if (termInp && typeof termInp.focus === 'function') termInp.focus();
|
|
11831
|
+
}
|
|
10878
11832
|
} else {
|
|
10879
11833
|
this.toggleTerminal();
|
|
10880
11834
|
}
|
|
@@ -11932,11 +12886,23 @@ int main() {
|
|
|
11932
12886
|
this.closeSettings();
|
|
11933
12887
|
return;
|
|
11934
12888
|
}
|
|
12889
|
+
if (tabKey === '__welcome__') {
|
|
12890
|
+
this.closeWelcomeTab();
|
|
12891
|
+
return;
|
|
12892
|
+
}
|
|
11935
12893
|
const fname = closeBtn.dataset.clCloseFile || closeBtn.dataset.clFile || tabEl.dataset.clFile;
|
|
11936
12894
|
if (fname) this.closeTab(fname);
|
|
11937
12895
|
return;
|
|
11938
12896
|
}
|
|
11939
12897
|
|
|
12898
|
+
const welcomeTabBtn = e.target.closest('[data-cl-tab="__welcome__"]');
|
|
12899
|
+
if (welcomeTabBtn) {
|
|
12900
|
+
this._activeScmDiffFile = null;
|
|
12901
|
+
this.activeTab = '__welcome__';
|
|
12902
|
+
this._syncActiveFileToView();
|
|
12903
|
+
return;
|
|
12904
|
+
}
|
|
12905
|
+
|
|
11940
12906
|
const settingsTabBtn = e.target.closest('[data-cl-tab="__settings__"]');
|
|
11941
12907
|
if (settingsTabBtn) {
|
|
11942
12908
|
this._activeScmDiffFile = null;
|
|
@@ -12281,6 +13247,8 @@ int main() {
|
|
|
12281
13247
|
} else if (action === 'new-terminal-session') {
|
|
12282
13248
|
this.createTerminalSession();
|
|
12283
13249
|
if (this.drawerTab !== 'terminal') this.switchDrawerTab('terminal');
|
|
13250
|
+
} else if (action === 'split-terminal-session') {
|
|
13251
|
+
this.splitActiveTerminalSession();
|
|
12284
13252
|
} else if (action === 'kill-terminal-session') {
|
|
12285
13253
|
this.killActiveTerminalSession();
|
|
12286
13254
|
} else if (action === 'switch-terminal-session') {
|
|
@@ -12290,6 +13258,49 @@ int main() {
|
|
|
12290
13258
|
e.stopPropagation();
|
|
12291
13259
|
const sid = actionBtn.dataset.sessionId;
|
|
12292
13260
|
if (sid) this.closeTerminalSession(sid);
|
|
13261
|
+
} else if (action === 'reveal-symbol') {
|
|
13262
|
+
const symFile = actionBtn.dataset.symbolFile || this.activeFile;
|
|
13263
|
+
const symLine = Math.max(1, Number(actionBtn.dataset.symbolLine || 1));
|
|
13264
|
+
const symCol = Math.max(1, Number(actionBtn.dataset.symbolCol || 1));
|
|
13265
|
+
if (symFile) {
|
|
13266
|
+
this.openFile(symFile);
|
|
13267
|
+
this._revealLineColInActiveEditor(symLine, symCol);
|
|
13268
|
+
}
|
|
13269
|
+
} else if (action === 'open-welcome') {
|
|
13270
|
+
this.openWelcomeTab();
|
|
13271
|
+
} else if (action === 'welcome-new-file') {
|
|
13272
|
+
this.closeWelcomeTab();
|
|
13273
|
+
this.setSidebarView('explorer', { ensureOpen: true, focus: false });
|
|
13274
|
+
this.startInlineCreate('file', this.explorerFolder || '');
|
|
13275
|
+
} else if (action === 'welcome-clone-repo') {
|
|
13276
|
+
this.openCloneDialog();
|
|
13277
|
+
} else if (action === 'welcome-open-recent') {
|
|
13278
|
+
const wid = actionBtn.dataset.workspaceId;
|
|
13279
|
+
if (wid) {
|
|
13280
|
+
this.closeWelcomeTab();
|
|
13281
|
+
this.switchWorkspace(wid);
|
|
13282
|
+
}
|
|
13283
|
+
} else if (action === 'welcome-load-template') {
|
|
13284
|
+
const demoId = actionBtn.dataset.demo || '';
|
|
13285
|
+
if (this.options && typeof this.options.onSelectWelcomeTemplate === 'function') {
|
|
13286
|
+
this.closeWelcomeTab();
|
|
13287
|
+
this.options.onSelectWelcomeTemplate(demoId, this);
|
|
13288
|
+
} else if (this.options && Array.isArray(this.options.welcomeTemplates)) {
|
|
13289
|
+
const tpl = this.options.welcomeTemplates.find((t) => t && t.id === demoId);
|
|
13290
|
+
if (tpl && tpl.files && typeof tpl.files === 'object') {
|
|
13291
|
+
this.closeWelcomeTab();
|
|
13292
|
+
if (tpl.language) this.lang = tpl.language;
|
|
13293
|
+
if (tpl.entry) this.entry = tpl.entry;
|
|
13294
|
+
if (tpl.title) this.title = tpl.title;
|
|
13295
|
+
this.setFiles(tpl.files);
|
|
13296
|
+
this._updateTopbarBrandTitle();
|
|
13297
|
+
const firstFile = tpl.entry && tpl.files[tpl.entry] ? tpl.entry : Object.keys(tpl.files)[0];
|
|
13298
|
+
if (firstFile) this.openFile(firstFile);
|
|
13299
|
+
}
|
|
13300
|
+
}
|
|
13301
|
+
} else if (action === 'scm-toggle-diff-mode') {
|
|
13302
|
+
this._scmForceUnifiedDiff = !this._scmForceUnifiedDiff;
|
|
13303
|
+
this._syncActiveFileToView();
|
|
12293
13304
|
} else if (action === 'scm-init') {
|
|
12294
13305
|
this._initGitRepoInScm();
|
|
12295
13306
|
} else if (action === 'scm-stage-file' || action === 'scm-stage') {
|
|
@@ -12849,6 +13860,15 @@ int main() {
|
|
|
12849
13860
|
return builtin;
|
|
12850
13861
|
}
|
|
12851
13862
|
|
|
13863
|
+
toggleCommandPalette(open, mode = 'commands') {
|
|
13864
|
+
const isOpen = Boolean(this.container && this.container.querySelector('#cl-modal-slot .codelab-palette'));
|
|
13865
|
+
if (open === false || (open === undefined && isOpen)) {
|
|
13866
|
+
this.closeCommandPalette();
|
|
13867
|
+
} else {
|
|
13868
|
+
this.openCommandPalette(mode);
|
|
13869
|
+
}
|
|
13870
|
+
}
|
|
13871
|
+
|
|
12852
13872
|
openCommandPalette(mode = 'commands') {
|
|
12853
13873
|
const slot = this.container.querySelector('#cl-modal-slot');
|
|
12854
13874
|
if (!slot) return;
|
|
@@ -12918,20 +13938,104 @@ int main() {
|
|
|
12918
13938
|
if (!listEl) return;
|
|
12919
13939
|
const trimmed = String(rawValue || '').trim();
|
|
12920
13940
|
const isCommandQuery = trimmed.startsWith('>') || (this.paletteMode === 'commands' && rawValue.startsWith('>'));
|
|
12921
|
-
const
|
|
13941
|
+
const isDocSymbolQuery = !isCommandQuery && trimmed.startsWith('@');
|
|
13942
|
+
const isWsSymbolQuery = !isCommandQuery && trimmed.startsWith('#');
|
|
13943
|
+
const rawQuery = isCommandQuery
|
|
13944
|
+
? trimmed.replace(/^>\s*/, '')
|
|
13945
|
+
: (isDocSymbolQuery || isWsSymbolQuery ? trimmed.slice(1).trim() : trimmed);
|
|
13946
|
+
const query = rawQuery.toLowerCase();
|
|
13947
|
+
const fuzzyScore = (_wbComponents && (typeof _wbComponents.fuzzyScoreText === 'function' || typeof _wbComponents.scoreFuzzyMatch === 'function'))
|
|
13948
|
+
? (_wbComponents.fuzzyScoreText || _wbComponents.scoreFuzzyMatch)
|
|
13949
|
+
: null;
|
|
13950
|
+
const fuzzyHl = (_wbComponents && (typeof _wbComponents.renderHighlightedText === 'function' || typeof _wbComponents.highlightFuzzyMatches === 'function'))
|
|
13951
|
+
? (_wbComponents.renderHighlightedText || _wbComponents.highlightFuzzyMatches)
|
|
13952
|
+
: null;
|
|
12922
13953
|
|
|
12923
13954
|
let items = [];
|
|
12924
13955
|
if (isCommandQuery) {
|
|
12925
13956
|
const cmds = this._getPaletteCommands();
|
|
12926
|
-
|
|
12927
|
-
|
|
12928
|
-
|
|
13957
|
+
if (query && fuzzyScore) {
|
|
13958
|
+
const scored = [];
|
|
13959
|
+
for (const c of cmds) {
|
|
13960
|
+
const mLabel = fuzzyScore(rawQuery, c.label);
|
|
13961
|
+
const mId = fuzzyScore(rawQuery, c.id);
|
|
13962
|
+
const best = mLabel || mId;
|
|
13963
|
+
if (best) {
|
|
13964
|
+
scored.push({
|
|
13965
|
+
score: (mLabel ? mLabel.score : 0) || (mId ? mId.score - 4 : 0),
|
|
13966
|
+
indices: mLabel ? mLabel.indices : [],
|
|
13967
|
+
cmd: c
|
|
13968
|
+
});
|
|
13969
|
+
}
|
|
13970
|
+
}
|
|
13971
|
+
scored.sort((a, b) => b.score - a.score);
|
|
13972
|
+
items = scored.map(({ cmd: c, indices }) => ({
|
|
12929
13973
|
type: 'command',
|
|
12930
13974
|
id: c.id,
|
|
12931
13975
|
label: c.label,
|
|
13976
|
+
labelHtml: fuzzyHl && indices.length > 0 ? fuzzyHl(c.label, indices) : escapeHtml(c.label),
|
|
12932
13977
|
shortcut: c.shortcut || '',
|
|
12933
13978
|
action: c.action
|
|
12934
13979
|
}));
|
|
13980
|
+
} else {
|
|
13981
|
+
items = cmds
|
|
13982
|
+
.filter(c => !query || c.label.toLowerCase().includes(query) || c.id.toLowerCase().includes(query))
|
|
13983
|
+
.map(c => ({
|
|
13984
|
+
type: 'command',
|
|
13985
|
+
id: c.id,
|
|
13986
|
+
label: c.label,
|
|
13987
|
+
labelHtml: escapeHtml(c.label),
|
|
13988
|
+
shortcut: c.shortcut || '',
|
|
13989
|
+
action: c.action
|
|
13990
|
+
}));
|
|
13991
|
+
}
|
|
13992
|
+
} else if (isDocSymbolQuery) {
|
|
13993
|
+
const activeTarget = (this.activeFile && this.activeTab !== '__settings__' && this.activeTab !== '__welcome__')
|
|
13994
|
+
? this.activeFile
|
|
13995
|
+
: this._pickDefaultFile();
|
|
13996
|
+
const symbols = (activeTarget && _wbComponents && typeof _wbComponents.extractDocumentSymbols === 'function')
|
|
13997
|
+
? _wbComponents.extractDocumentSymbols(activeTarget, String(this.files[activeTarget] ?? ''))
|
|
13998
|
+
: [];
|
|
13999
|
+
items = symbols
|
|
14000
|
+
.filter(sym => !query || sym.name.toLowerCase().includes(query))
|
|
14001
|
+
.map(sym => ({
|
|
14002
|
+
type: 'symbol',
|
|
14003
|
+
id: `${activeTarget}:${sym.line}:${sym.name}`,
|
|
14004
|
+
label: `${sym.name} (${sym.kind})`,
|
|
14005
|
+
labelHtml: `${escapeHtml(sym.name)} <span style="opacity:0.6;font-size:11px;">${escapeHtml(sym.kind)} · Ln ${sym.line}</span>`,
|
|
14006
|
+
shortcut: activeTarget || '',
|
|
14007
|
+
action: () => {
|
|
14008
|
+
if (activeTarget) {
|
|
14009
|
+
this.openFile(activeTarget);
|
|
14010
|
+
this._revealLineColInActiveEditor(sym.line || 1, sym.column || 1);
|
|
14011
|
+
}
|
|
14012
|
+
}
|
|
14013
|
+
}));
|
|
14014
|
+
} else if (isWsSymbolQuery) {
|
|
14015
|
+
const allSymbols = [];
|
|
14016
|
+
if (_wbComponents && typeof _wbComponents.extractDocumentSymbols === 'function') {
|
|
14017
|
+
for (const fname of this._orderedFileNames()) {
|
|
14018
|
+
if (this._isPathExcluded(fname)) continue;
|
|
14019
|
+
const syms = _wbComponents.extractDocumentSymbols(fname, String(this.files[fname] ?? ''));
|
|
14020
|
+
for (const sym of syms) {
|
|
14021
|
+
allSymbols.push({ file: fname, sym });
|
|
14022
|
+
}
|
|
14023
|
+
}
|
|
14024
|
+
}
|
|
14025
|
+
items = allSymbols
|
|
14026
|
+
.filter(({ sym, file }) => !query || sym.name.toLowerCase().includes(query) || file.toLowerCase().includes(query))
|
|
14027
|
+
.slice(0, 80)
|
|
14028
|
+
.map(({ sym, file }) => ({
|
|
14029
|
+
type: 'symbol',
|
|
14030
|
+
id: `${file}:${sym.line}:${sym.name}`,
|
|
14031
|
+
label: `${sym.name} — ${file}`,
|
|
14032
|
+
labelHtml: `${escapeHtml(sym.name)} <span style="opacity:0.6;font-size:11px;">${escapeHtml(file)}:${sym.line}</span>`,
|
|
14033
|
+
shortcut: sym.kind,
|
|
14034
|
+
action: () => {
|
|
14035
|
+
this.openFile(file);
|
|
14036
|
+
this._revealLineColInActiveEditor(sym.line || 1, sym.column || 1);
|
|
14037
|
+
}
|
|
14038
|
+
}));
|
|
12935
14039
|
} else {
|
|
12936
14040
|
const files = this._orderedFileNames().filter(f => !this._isPathExcluded(f));
|
|
12937
14041
|
const mod = getModular();
|
|
@@ -12940,17 +14044,35 @@ int main() {
|
|
|
12940
14044
|
...(Array.isArray(searchExcl) ? searchExcl : []),
|
|
12941
14045
|
...this._getExcludePatterns()
|
|
12942
14046
|
];
|
|
12943
|
-
|
|
12944
|
-
|
|
12945
|
-
|
|
12946
|
-
|
|
12947
|
-
|
|
14047
|
+
if (query && fuzzyScore) {
|
|
14048
|
+
const scored = [];
|
|
14049
|
+
for (const f of files) {
|
|
14050
|
+
const m = fuzzyScore(rawQuery, f);
|
|
14051
|
+
if (m) scored.push({ file: f, score: m.score + (f === this.activeFile ? 3 : 0), indices: m.indices });
|
|
14052
|
+
}
|
|
14053
|
+
scored.sort((a, b) => b.score - a.score);
|
|
14054
|
+
items = scored.map(({ file: f, indices }) => ({
|
|
12948
14055
|
type: 'file',
|
|
12949
14056
|
id: f,
|
|
12950
14057
|
label: f,
|
|
14058
|
+
labelHtml: fuzzyHl && indices.length > 0 ? fuzzyHl(f, indices) : escapeHtml(f),
|
|
12951
14059
|
shortcut: f === this.activeFile ? 'Active' : '',
|
|
12952
14060
|
action: () => this.openFile(f)
|
|
12953
14061
|
}));
|
|
14062
|
+
} else {
|
|
14063
|
+
const ranked = (mod && typeof mod.rankWorkspaceFiles === 'function')
|
|
14064
|
+
? mod.rankWorkspaceFiles(files, query, excludePatterns)
|
|
14065
|
+
: files.filter(f => !query || f.toLowerCase().includes(query));
|
|
14066
|
+
items = ranked
|
|
14067
|
+
.map(f => ({
|
|
14068
|
+
type: 'file',
|
|
14069
|
+
id: f,
|
|
14070
|
+
label: f,
|
|
14071
|
+
labelHtml: escapeHtml(f),
|
|
14072
|
+
shortcut: f === this.activeFile ? 'Active' : '',
|
|
14073
|
+
action: () => this.openFile(f)
|
|
14074
|
+
}));
|
|
14075
|
+
}
|
|
12954
14076
|
}
|
|
12955
14077
|
|
|
12956
14078
|
this._currentPaletteItems = items;
|
|
@@ -12959,13 +14081,14 @@ int main() {
|
|
|
12959
14081
|
}
|
|
12960
14082
|
|
|
12961
14083
|
if (items.length === 0) {
|
|
12962
|
-
|
|
14084
|
+
const kindLabel = isCommandQuery ? 'commands' : (isDocSymbolQuery || isWsSymbolQuery ? 'symbols' : 'files');
|
|
14085
|
+
listEl.innerHTML = `<div class="codelab-palette__empty">No matching ${kindLabel} found</div>`;
|
|
12963
14086
|
return;
|
|
12964
14087
|
}
|
|
12965
14088
|
|
|
12966
14089
|
listEl.innerHTML = items.map((item, idx) => `
|
|
12967
14090
|
<button type="button" class="codelab-palette__item ${idx === this.paletteSelectedIndex ? 'is-selected' : ''}" role="option" aria-selected="${idx === this.paletteSelectedIndex}" data-palette-idx="${idx}" data-palette-id="${escapeHtml(item.id)}">
|
|
12968
|
-
<span class="codelab-palette__item-label">${escapeHtml(item.label)}</span>
|
|
14091
|
+
<span class="codelab-palette__item-label">${item.labelHtml || escapeHtml(item.label)}</span>
|
|
12969
14092
|
${item.shortcut ? `<span class="codelab-palette__item-kbd">${escapeHtml(item.shortcut)}</span>` : ''}
|
|
12970
14093
|
</button>
|
|
12971
14094
|
`).join('');
|
|
@@ -13306,12 +14429,25 @@ int main() {
|
|
|
13306
14429
|
const mainEl = this.container.querySelector('.codelab-workbench-main, .codelab-main');
|
|
13307
14430
|
if (!mainEl) return;
|
|
13308
14431
|
const rect = mainEl.getBoundingClientRect();
|
|
13309
|
-
const
|
|
13310
|
-
|
|
13311
|
-
|
|
14432
|
+
const rawH = Math.round(rect.bottom - ev.clientY);
|
|
14433
|
+
if (rawH < 56) {
|
|
14434
|
+
if (this.panelVisible) {
|
|
14435
|
+
this._savedPanelHeight = Math.max(140, this.panelHeight || 220);
|
|
14436
|
+
this.setPanelVisible(false, { skipRender: true, skipSave: true });
|
|
14437
|
+
}
|
|
14438
|
+
return;
|
|
14439
|
+
}
|
|
14440
|
+
if (!this.panelVisible && rawH >= 72) {
|
|
14441
|
+
this.setPanelVisible(true, { skipRender: true, skipSave: true });
|
|
14442
|
+
}
|
|
14443
|
+
const minH = 96;
|
|
14444
|
+
const maxH = Math.max(minH, Math.floor(rect.height * 0.82));
|
|
14445
|
+
const nextH = Math.min(maxH, Math.max(minH, rawH));
|
|
13312
14446
|
this.panelHeight = nextH;
|
|
13313
14447
|
this._setShellCssVar(curShell, '--cl-drawer-height', `${nextH}px`);
|
|
13314
|
-
if (this.editor) this.editor.layout();
|
|
14448
|
+
if (this.editor && typeof this.editor.layout === 'function') this.editor.layout();
|
|
14449
|
+
const xt = this._getActiveXtermEngine();
|
|
14450
|
+
if (xt && typeof xt.fit === 'function') xt.fit();
|
|
13315
14451
|
},
|
|
13316
14452
|
onEnd: () => {
|
|
13317
14453
|
this._saveState();
|
|
@@ -13327,6 +14463,7 @@ int main() {
|
|
|
13327
14463
|
if (fSplitter && !fSplitter._clDblBound) {
|
|
13328
14464
|
fSplitter._clDblBound = true;
|
|
13329
14465
|
fSplitter.addEventListener('dblclick', () => {
|
|
14466
|
+
if (!this.sidebarVisible) this.setSidebarVisible(true);
|
|
13330
14467
|
applyExplorerWidth(260, this.container.querySelector('.codelab'));
|
|
13331
14468
|
this._saveState();
|
|
13332
14469
|
});
|
|
@@ -13337,11 +14474,20 @@ int main() {
|
|
|
13337
14474
|
const bodyEl = this.container.querySelector('.codelab-body');
|
|
13338
14475
|
const sidebarEl = this.container.querySelector('#cl-sidebar, .codelab-sidebar');
|
|
13339
14476
|
const bodyRect = (bodyEl || curShell).getBoundingClientRect();
|
|
13340
|
-
const sbRect = sidebarEl ? sidebarEl.getBoundingClientRect() : bodyRect;
|
|
14477
|
+
const sbRect = sidebarEl && this.sidebarVisible ? sidebarEl.getBoundingClientRect() : bodyRect;
|
|
14478
|
+
const isRight = curShell.classList.contains('sidebar-right');
|
|
14479
|
+
const rawW = isRight ? (bodyRect.right - 48 - ev.clientX) : (ev.clientX - (this.sidebarVisible ? sbRect.left : bodyRect.left + 48));
|
|
14480
|
+
if (rawW < 72) {
|
|
14481
|
+
if (this.sidebarVisible) {
|
|
14482
|
+
this.setSidebarVisible(false);
|
|
14483
|
+
}
|
|
14484
|
+
return;
|
|
14485
|
+
}
|
|
14486
|
+
if (!this.sidebarVisible && rawW >= 96) {
|
|
14487
|
+
this.setSidebarVisible(true);
|
|
14488
|
+
}
|
|
13341
14489
|
const minW = 150;
|
|
13342
14490
|
const maxW = Math.max(minW, Math.floor(bodyRect.width * 0.5));
|
|
13343
|
-
const isRight = curShell.classList.contains('sidebar-right');
|
|
13344
|
-
const rawW = isRight ? (sbRect.right - ev.clientX) : (ev.clientX - sbRect.left);
|
|
13345
14491
|
const nextW = Math.min(maxW, Math.max(minW, Math.round(rawW)));
|
|
13346
14492
|
applyExplorerWidth(nextW, curShell);
|
|
13347
14493
|
},
|
|
@@ -14032,6 +15178,43 @@ int main() {
|
|
|
14032
15178
|
`;
|
|
14033
15179
|
}
|
|
14034
15180
|
|
|
15181
|
+
_openModalDialog(slot) {
|
|
15182
|
+
if (!slot || typeof slot.querySelector !== 'function') return null;
|
|
15183
|
+
const dlg = slot.querySelector('dialog.codelab-dialog');
|
|
15184
|
+
if (!dlg) return null;
|
|
15185
|
+
if (typeof dlg.showModal === 'function') {
|
|
15186
|
+
try {
|
|
15187
|
+
if (!dlg.open) dlg.showModal();
|
|
15188
|
+
} catch (err) {
|
|
15189
|
+
void err;
|
|
15190
|
+
dlg.setAttribute('open', '');
|
|
15191
|
+
}
|
|
15192
|
+
} else {
|
|
15193
|
+
dlg.setAttribute('open', '');
|
|
15194
|
+
}
|
|
15195
|
+
dlg.addEventListener('cancel', (ev) => {
|
|
15196
|
+
ev.preventDefault();
|
|
15197
|
+
this.closeModal();
|
|
15198
|
+
});
|
|
15199
|
+
if (typeof HTMLDialogElement === 'undefined' || !('closedBy' in HTMLDialogElement.prototype)) {
|
|
15200
|
+
dlg.addEventListener('click', (ev) => {
|
|
15201
|
+
if (!ev || typeof dlg.getBoundingClientRect !== 'function') return;
|
|
15202
|
+
const rect = dlg.getBoundingClientRect();
|
|
15203
|
+
if (rect.width <= 0 || rect.height <= 0) return;
|
|
15204
|
+
const clickedInDialog = (
|
|
15205
|
+
rect.top <= ev.clientY &&
|
|
15206
|
+
ev.clientY <= rect.top + rect.height &&
|
|
15207
|
+
rect.left <= ev.clientX &&
|
|
15208
|
+
ev.clientX <= rect.left + rect.width
|
|
15209
|
+
);
|
|
15210
|
+
if (!clickedInDialog) {
|
|
15211
|
+
this.closeModal();
|
|
15212
|
+
}
|
|
15213
|
+
});
|
|
15214
|
+
}
|
|
15215
|
+
return dlg;
|
|
15216
|
+
}
|
|
15217
|
+
|
|
14035
15218
|
closeModal(opts = {}) {
|
|
14036
15219
|
this._lastBackdropPointerDownTarget = null;
|
|
14037
15220
|
const slot = this.container ? this.container.querySelector('#cl-modal-slot') : null;
|
|
@@ -14040,7 +15223,13 @@ int main() {
|
|
|
14040
15223
|
this._modalReturnFocusEl = null;
|
|
14041
15224
|
const onCloseCb = this._onModalClosedCallback || null;
|
|
14042
15225
|
this._onModalClosedCallback = null;
|
|
14043
|
-
if (slot)
|
|
15226
|
+
if (slot) {
|
|
15227
|
+
const openDlg = typeof slot.querySelector === 'function' ? slot.querySelector('dialog.codelab-dialog[open]') : null;
|
|
15228
|
+
if (openDlg && typeof openDlg.close === 'function') {
|
|
15229
|
+
try { openDlg.close(); } catch (_err) { void _err; }
|
|
15230
|
+
}
|
|
15231
|
+
slot.innerHTML = '';
|
|
15232
|
+
}
|
|
14044
15233
|
if (typeof onCloseCb === 'function') {
|
|
14045
15234
|
try { onCloseCb(); } catch (_err) { void _err; }
|
|
14046
15235
|
}
|
|
@@ -14078,6 +15267,7 @@ int main() {
|
|
|
14078
15267
|
const configuredTimeoutMs = this.configuration
|
|
14079
15268
|
? Math.max(500, Math.min(120000, Number(this.configuration.get('runtime.timeoutMs', 8000)) || 8000))
|
|
14080
15269
|
: 8000;
|
|
15270
|
+
const activeSignal = execOptions.signal || this._activeCommandAbortController?.signal;
|
|
14081
15271
|
const payload = {
|
|
14082
15272
|
...execOptions,
|
|
14083
15273
|
timeoutMs: execOptions && execOptions.timeoutMs !== undefined ? execOptions.timeoutMs : configuredTimeoutMs,
|
|
@@ -14086,7 +15276,8 @@ int main() {
|
|
|
14086
15276
|
cppCompiler: execOptions.cppCompiler || this.cppCompiler,
|
|
14087
15277
|
onStdout: execOptions.onStdout || ((chunk) => this._appendTerminalStream('stdout', chunk)),
|
|
14088
15278
|
onStderr: execOptions.onStderr || ((chunk) => this._appendTerminalStream('stderr', chunk)),
|
|
14089
|
-
|
|
15279
|
+
onRequestStdin: execOptions.onRequestStdin || ((promptText) => this._requestInteractiveTerminalStdin(promptText, activeSignal)),
|
|
15280
|
+
signal: activeSignal
|
|
14090
15281
|
};
|
|
14091
15282
|
try {
|
|
14092
15283
|
const isCppEntry = Boolean(payload && typeof payload.entry === 'string' && /\.(cpp|cc|cxx|wasm)$/i.test(payload.entry));
|
|
@@ -16023,6 +17214,13 @@ int main() {
|
|
|
16023
17214
|
if (outSurface && outSurface.style) {
|
|
16024
17215
|
outSurface.style.fontSize = `${termFontSize}px`;
|
|
16025
17216
|
}
|
|
17217
|
+
if (this._xtermEngines instanceof Map) {
|
|
17218
|
+
const maxSbCfg = this._getTerminalScrollback();
|
|
17219
|
+
for (const eng of this._xtermEngines.values()) {
|
|
17220
|
+
if (eng && typeof eng.setFontSize === 'function') eng.setFontSize(termFontSize);
|
|
17221
|
+
if (eng && typeof eng.setMaxScrollback === 'function') eng.setMaxScrollback(maxSbCfg);
|
|
17222
|
+
}
|
|
17223
|
+
}
|
|
16026
17224
|
const trimmedLogs = this._trimTerminalLogs();
|
|
16027
17225
|
if (trimmedLogs && (this.drawerTab === 'terminal' || this.drawerTab === 'output')) {
|
|
16028
17226
|
this._renderDrawerBody();
|
|
@@ -16297,7 +17495,7 @@ int main() {
|
|
|
16297
17495
|
return abs.replace(/^\/+/, '');
|
|
16298
17496
|
}
|
|
16299
17497
|
|
|
16300
|
-
async _handleReplCommand(cmd) {
|
|
17498
|
+
async _handleReplCommand(cmd, opts = null) {
|
|
16301
17499
|
if (this.isRunning) return;
|
|
16302
17500
|
const trimmed = (cmd || '').trim();
|
|
16303
17501
|
if (!trimmed) return;
|
|
@@ -16305,21 +17503,24 @@ int main() {
|
|
|
16305
17503
|
this.replHistory.push(trimmed);
|
|
16306
17504
|
}
|
|
16307
17505
|
this.replHistoryIdx = -1;
|
|
16308
|
-
const
|
|
16309
|
-
|
|
16310
|
-
|
|
16311
|
-
|
|
16312
|
-
|
|
16313
|
-
|
|
16314
|
-
this.
|
|
16315
|
-
|
|
16316
|
-
|
|
16317
|
-
|
|
16318
|
-
|
|
16319
|
-
const
|
|
16320
|
-
|
|
16321
|
-
|
|
16322
|
-
|
|
17506
|
+
const skipEcho = Boolean(opts && opts.skipEcho);
|
|
17507
|
+
if (!skipEcho) {
|
|
17508
|
+
const cwdShort = (this.cwd || '/workspace').replace(/^\/workspace\/?/, '') || '~';
|
|
17509
|
+
const promptPrefix = this.inRepl ? '> ' : `codelab:${cwdShort}$ `;
|
|
17510
|
+
const echoLine = `${promptPrefix}${trimmed}`;
|
|
17511
|
+
this._pushTerminalLog({ type: 'system', text: echoLine });
|
|
17512
|
+
const maxSbEcho = this._getTerminalScrollback();
|
|
17513
|
+
if (this.terminalLogs.length > maxSbEcho) {
|
|
17514
|
+
this.terminalLogs.splice(0, this.terminalLogs.length - maxSbEcho);
|
|
17515
|
+
}
|
|
17516
|
+
const termLogEl = this.container ? this.container.querySelector('#cl-terminal-log') : null;
|
|
17517
|
+
const ptyOwnsDom = Boolean((this.ptyEngine && this.ptyEngine.container) || this._getActiveXtermEngine());
|
|
17518
|
+
if (termLogEl && typeof document !== 'undefined' && !ptyOwnsDom) {
|
|
17519
|
+
const echoEl = document.createElement('div');
|
|
17520
|
+
echoEl.className = 'codelab-log-line system';
|
|
17521
|
+
echoEl.innerHTML = ansiToHtml ? ansiToHtml(echoLine) : escapeHtml(echoLine);
|
|
17522
|
+
termLogEl.appendChild(echoEl);
|
|
17523
|
+
}
|
|
16323
17524
|
}
|
|
16324
17525
|
|
|
16325
17526
|
if (this.inRepl) {
|
|
@@ -16353,6 +17554,7 @@ int main() {
|
|
|
16353
17554
|
files: { ...this.files },
|
|
16354
17555
|
mode: 'repl',
|
|
16355
17556
|
replCode: trimmed,
|
|
17557
|
+
replSessionId: this._activeTerminalSessionId || 'default',
|
|
16356
17558
|
signal: abortCtrl.signal,
|
|
16357
17559
|
onStdout: (c) => { streamedStdout = true; this._appendTerminalStream('stdout', c); },
|
|
16358
17560
|
onStderr: (c) => { streamedStderr = true; this._appendTerminalStream('stderr', c); }
|
|
@@ -16393,21 +17595,27 @@ int main() {
|
|
|
16393
17595
|
this._renderDrawerBody();
|
|
16394
17596
|
return;
|
|
16395
17597
|
}
|
|
16396
|
-
|
|
17598
|
+
const hasPkgJson = Boolean(this.files && this.files['package.json']);
|
|
17599
|
+
if (trimmed === 'run' || ((this.hasGuidedLab || !hasPkgJson) && (trimmed === 'npm start' || trimmed === 'npm run demo'))) {
|
|
16397
17600
|
await this.runDemo();
|
|
16398
17601
|
return;
|
|
16399
17602
|
}
|
|
16400
|
-
if (trimmed === 'test' || trimmed === 'npm test' || trimmed === 'npm t') {
|
|
17603
|
+
if (trimmed === 'test' || ((this.hasGuidedLab || !hasPkgJson) && (trimmed === 'npm test' || trimmed === 'npm t'))) {
|
|
16401
17604
|
await this.runTests();
|
|
16402
17605
|
return;
|
|
16403
17606
|
}
|
|
16404
17607
|
|
|
16405
17608
|
const firstWord = (trimmed.split(/\s+/)[0] || '').replace(/^.*\//, '');
|
|
17609
|
+
const isEnvVarAssignment = /^[A-Za-z_][A-Za-z0-9_]*=/.test(trimmed);
|
|
16406
17610
|
const shellKnowsCommand = Boolean(
|
|
16407
|
-
|
|
17611
|
+
isEnvVarAssignment ||
|
|
17612
|
+
trimmed.startsWith('./') ||
|
|
17613
|
+
trimmed.startsWith('../') ||
|
|
17614
|
+
trimmed.startsWith('/') ||
|
|
17615
|
+
(firstWord &&
|
|
16408
17616
|
this.shell &&
|
|
16409
17617
|
typeof this.shell.hasCommand === 'function' &&
|
|
16410
|
-
this.shell.hasCommand(firstWord)
|
|
17618
|
+
this.shell.hasCommand(firstWord))
|
|
16411
17619
|
);
|
|
16412
17620
|
const looksLikeJsExpr = !shellKnowsCommand && (
|
|
16413
17621
|
/^(const|let|var|function|class|await|return|typeof|instanceof|new\s+|Math\.|JSON\.|Object\.|Array\.|Promise\.|console\.|process\.|Buffer\.|require\s*\(|import\s*\(|[0-9]+\s*[\+\-\*\/\%]|['"`\[{])/.test(trimmed)
|
|
@@ -16421,7 +17629,6 @@ int main() {
|
|
|
16421
17629
|
this._updateRunStateUI();
|
|
16422
17630
|
let streamedStdout = false;
|
|
16423
17631
|
let streamedStderr = false;
|
|
16424
|
-
const logsCountBefore = this.terminalLogs.length;
|
|
16425
17632
|
|
|
16426
17633
|
try {
|
|
16427
17634
|
this._syncFilesToShellVfs();
|
|
@@ -16435,6 +17642,7 @@ int main() {
|
|
|
16435
17642
|
streamedStderr = true;
|
|
16436
17643
|
this._appendTerminalStream('stderr', c);
|
|
16437
17644
|
},
|
|
17645
|
+
onRequestStdin: (promptText) => this._requestInteractiveTerminalStdin(promptText, abortCtrl.signal),
|
|
16438
17646
|
signal: abortCtrl.signal
|
|
16439
17647
|
});
|
|
16440
17648
|
this._flushTerminalStream();
|
|
@@ -16443,6 +17651,8 @@ int main() {
|
|
|
16443
17651
|
this._syncVfsSnapshot(null, true);
|
|
16444
17652
|
if (/^\s*git\b/.test(trimmed) || (this.shell && this.shell.gitState && this.shell.gitState.initialized)) {
|
|
16445
17653
|
this._saveState();
|
|
17654
|
+
this._updateEditorGitGutter();
|
|
17655
|
+
this._renderFileLists();
|
|
16446
17656
|
}
|
|
16447
17657
|
if (this.activeSidebarView === 'scm' && typeof this._renderScmSidebar === 'function') {
|
|
16448
17658
|
this._renderScmSidebar();
|
|
@@ -17009,8 +18219,8 @@ int main() {
|
|
|
17009
18219
|
: `Are you sure you want to discard all working-tree changes in "${cleanRel}" and restore HEAD?`;
|
|
17010
18220
|
|
|
17011
18221
|
slot.innerHTML = `
|
|
17012
|
-
<
|
|
17013
|
-
<div class="codelab-modal" role="
|
|
18222
|
+
<dialog class="codelab-dialog" closedby="any" aria-labelledby="cl-discard-modal-title" aria-describedby="cl-discard-modal-desc" style="max-width:420px;">
|
|
18223
|
+
<div class="codelab-modal" role="document">
|
|
17014
18224
|
<div class="codelab-modal__header">
|
|
17015
18225
|
<span id="cl-discard-modal-title">Discard Changes</span>
|
|
17016
18226
|
<button type="button" class="codelab-btn codelab-btn--icon" data-cl-action="close-modal" title="Close" aria-label="Close">×</button>
|
|
@@ -17023,8 +18233,9 @@ int main() {
|
|
|
17023
18233
|
</div>
|
|
17024
18234
|
</div>
|
|
17025
18235
|
</div>
|
|
17026
|
-
</
|
|
18236
|
+
</dialog>
|
|
17027
18237
|
`;
|
|
18238
|
+
this._openModalDialog(slot);
|
|
17028
18239
|
const cancelBtn = slot.querySelector('#cl-discard-cancel-btn');
|
|
17029
18240
|
const confirmBtn = slot.querySelector('#cl-discard-confirm-btn');
|
|
17030
18241
|
if (cancelBtn && typeof cancelBtn.focus === 'function') {
|
|
@@ -17109,6 +18320,11 @@ int main() {
|
|
|
17109
18320
|
} catch (_err) {
|
|
17110
18321
|
void _err;
|
|
17111
18322
|
}
|
|
18323
|
+
if (scmMod && typeof scmMod.syncToIsoGitRepo === 'function') {
|
|
18324
|
+
Promise.resolve(scmMod.syncToIsoGitRepo(this.shell.vfs, gs, '/workspace')).catch((_e) => {
|
|
18325
|
+
void _e;
|
|
18326
|
+
});
|
|
18327
|
+
}
|
|
17112
18328
|
}
|
|
17113
18329
|
if (this._activeScmDiffFile) {
|
|
17114
18330
|
const remaining = this.getGitStatus();
|
|
@@ -17119,6 +18335,8 @@ int main() {
|
|
|
17119
18335
|
this._syncActiveFileToView();
|
|
17120
18336
|
}
|
|
17121
18337
|
}
|
|
18338
|
+
this._updateEditorGitGutter();
|
|
18339
|
+
this._renderFileLists();
|
|
17122
18340
|
this._syncFilesToShellVfs({ keepGitDir: true });
|
|
17123
18341
|
this._saveState();
|
|
17124
18342
|
}
|
|
@@ -17144,6 +18362,7 @@ int main() {
|
|
|
17144
18362
|
if (!cleanName || cleanName.startsWith('-') || cleanName.includes('..')) return false;
|
|
17145
18363
|
const gs = this._getGitState();
|
|
17146
18364
|
if (!gs) return false;
|
|
18365
|
+
const scmMod = root.CodeLabScm;
|
|
17147
18366
|
if (!(gs.branches instanceof Set)) {
|
|
17148
18367
|
gs.branches = new Set(Array.isArray(gs.branches) ? gs.branches : [gs.branch || 'main']);
|
|
17149
18368
|
}
|
|
@@ -17173,6 +18392,11 @@ int main() {
|
|
|
17173
18392
|
} catch (_err) {
|
|
17174
18393
|
void _err;
|
|
17175
18394
|
}
|
|
18395
|
+
if (scmMod && typeof scmMod.syncToIsoGitRepo === 'function') {
|
|
18396
|
+
Promise.resolve(scmMod.syncToIsoGitRepo(this.shell.vfs, gs, '/workspace')).catch((_e) => {
|
|
18397
|
+
void _e;
|
|
18398
|
+
});
|
|
18399
|
+
}
|
|
17176
18400
|
}
|
|
17177
18401
|
if (checkout) {
|
|
17178
18402
|
return this.checkoutGitBranch(cleanName);
|
|
@@ -17188,26 +18412,42 @@ int main() {
|
|
|
17188
18412
|
if (!cleanName) return false;
|
|
17189
18413
|
const gs = this._getGitState();
|
|
17190
18414
|
if (!gs) return false;
|
|
18415
|
+
const scmMod = root.CodeLabScm;
|
|
17191
18416
|
if (!(gs.branches instanceof Set)) {
|
|
17192
18417
|
gs.branches = new Set(Array.isArray(gs.branches) ? gs.branches : [gs.branch || 'main']);
|
|
17193
18418
|
}
|
|
17194
18419
|
if (!gs.branches.has(cleanName)) return false;
|
|
17195
|
-
|
|
17196
|
-
|
|
17197
|
-
if (
|
|
17198
|
-
|
|
17199
|
-
|
|
17200
|
-
|
|
17201
|
-
|
|
17202
|
-
|
|
17203
|
-
|
|
17204
|
-
if (targetInfo && typeof targetInfo === 'object') {
|
|
17205
|
-
gs.headCommit = targetInfo.headCommit || '';
|
|
17206
|
-
this._syncGitHeadState(gs, targetInfo.headSnapshot || {});
|
|
17207
|
-
gs.commits = Array.isArray(targetInfo.commits) ? targetInfo.commits.slice() : [];
|
|
18420
|
+
|
|
18421
|
+
let switchedViaScm = false;
|
|
18422
|
+
if (scmMod && typeof scmMod.checkoutBranch === 'function') {
|
|
18423
|
+
const res = scmMod.checkoutBranch(this.shell || { gitState: gs, cwd: '/workspace' }, cleanName, this.files);
|
|
18424
|
+
if (res && res.ok) {
|
|
18425
|
+
switchedViaScm = true;
|
|
18426
|
+
} else if (res && !res.ok && res.error) {
|
|
18427
|
+
this._showToast(res.error, 'error');
|
|
18428
|
+
return false;
|
|
17208
18429
|
}
|
|
17209
18430
|
}
|
|
17210
|
-
|
|
18431
|
+
|
|
18432
|
+
if (!switchedViaScm) {
|
|
18433
|
+
if (!gs.branchHeads || typeof gs.branchHeads !== 'object') gs.branchHeads = {};
|
|
18434
|
+
const prevBranch = gs.branch || 'main';
|
|
18435
|
+
if (prevBranch !== cleanName) {
|
|
18436
|
+
gs.branchHeads[prevBranch] = {
|
|
18437
|
+
headCommit: gs.headCommit || '',
|
|
18438
|
+
headSnapshot: { ...(gs.headSnapshot || gs.headFiles || {}) },
|
|
18439
|
+
commits: Array.isArray(gs.commits) ? gs.commits.slice() : []
|
|
18440
|
+
};
|
|
18441
|
+
const targetInfo = gs.branchHeads[cleanName];
|
|
18442
|
+
if (targetInfo && typeof targetInfo === 'object') {
|
|
18443
|
+
gs.headCommit = targetInfo.headCommit || '';
|
|
18444
|
+
this._syncGitHeadState(gs, targetInfo.headSnapshot || {});
|
|
18445
|
+
gs.commits = Array.isArray(targetInfo.commits) ? targetInfo.commits.slice() : [];
|
|
18446
|
+
}
|
|
18447
|
+
}
|
|
18448
|
+
gs.branch = cleanName;
|
|
18449
|
+
}
|
|
18450
|
+
|
|
17211
18451
|
if (this.shell && this.shell.vfs && typeof this.shell.vfs.writeFileSync === 'function') {
|
|
17212
18452
|
try {
|
|
17213
18453
|
if (typeof this.shell.vfs.mkdirSync === 'function') {
|
|
@@ -17217,14 +18457,29 @@ int main() {
|
|
|
17217
18457
|
} catch (_err) {
|
|
17218
18458
|
void _err;
|
|
17219
18459
|
}
|
|
18460
|
+
if (scmMod && typeof scmMod.syncToIsoGitRepo === 'function') {
|
|
18461
|
+
Promise.resolve(scmMod.syncToIsoGitRepo(this.shell.vfs, gs, '/workspace')).catch((_e) => {
|
|
18462
|
+
void _e;
|
|
18463
|
+
});
|
|
18464
|
+
}
|
|
18465
|
+
}
|
|
18466
|
+
if (Array.isArray(this.openTabs)) {
|
|
18467
|
+
this.openTabs = this.openTabs.filter((t) => Object.prototype.hasOwnProperty.call(this.files, t));
|
|
18468
|
+
}
|
|
18469
|
+
if (this.activeFile && !Object.prototype.hasOwnProperty.call(this.files, this.activeFile)) {
|
|
18470
|
+
this.activeFile = this.openTabs[0] || this._pickDefaultFile() || null;
|
|
18471
|
+
if (this.activeTab !== '__settings__' && this.activeTab !== '__welcome__') {
|
|
18472
|
+
this.activeTab = this.activeFile;
|
|
18473
|
+
}
|
|
17220
18474
|
}
|
|
18475
|
+
this._syncFilesToShellVfs({ pruneExtraneous: true, keepGitDir: true });
|
|
18476
|
+
this._syncAllModels();
|
|
17221
18477
|
this._saveState();
|
|
17222
18478
|
if (this.activeSidebarView === 'scm') {
|
|
17223
18479
|
this._renderScmSidebar();
|
|
17224
18480
|
}
|
|
17225
|
-
|
|
17226
|
-
|
|
17227
|
-
}
|
|
18481
|
+
this._syncActiveFileToView();
|
|
18482
|
+
this._updateEditorGitGutter();
|
|
17228
18483
|
this._updateStatusBar();
|
|
17229
18484
|
return true;
|
|
17230
18485
|
}
|
|
@@ -17245,7 +18500,7 @@ int main() {
|
|
|
17245
18500
|
openScmDiff(relPath, opts = {}) {
|
|
17246
18501
|
const cleanRel = String(relPath || '').trim().replace(/^\/+/, '');
|
|
17247
18502
|
if (!cleanRel) return false;
|
|
17248
|
-
if (this.activeTab === '__settings__') {
|
|
18503
|
+
if (this.activeTab === '__settings__' || this.activeTab === '__welcome__') {
|
|
17249
18504
|
this.activeTab = this.activeFile || null;
|
|
17250
18505
|
}
|
|
17251
18506
|
this._activeScmDiffFile = cleanRel;
|
|
@@ -17258,6 +18513,9 @@ int main() {
|
|
|
17258
18513
|
if (!this._activeScmDiffFile) return false;
|
|
17259
18514
|
this._activeScmDiffFile = null;
|
|
17260
18515
|
this._activeScmDiffStaged = false;
|
|
18516
|
+
if (this._scmDiffManager && typeof this._scmDiffManager.closeInlineDiff === 'function') {
|
|
18517
|
+
try { this._scmDiffManager.closeInlineDiff(); } catch (_err) { void _err; }
|
|
18518
|
+
}
|
|
17261
18519
|
this._syncActiveFileToView();
|
|
17262
18520
|
return true;
|
|
17263
18521
|
}
|
|
@@ -17285,6 +18543,58 @@ int main() {
|
|
|
17285
18543
|
const rightLabel = isStaged ? `Index (Staged): ${relPath}` : `Working Tree: ${relPath}`;
|
|
17286
18544
|
const diff = this._computeLineDiff(leftText, rightText);
|
|
17287
18545
|
const hasFileInWorktree = Object.prototype.hasOwnProperty.call(this.files, relPath);
|
|
18546
|
+
const canUseMonacoDiff = Boolean(
|
|
18547
|
+
!this._scmForceUnifiedDiff &&
|
|
18548
|
+
this.monaco &&
|
|
18549
|
+
this.monaco.editor &&
|
|
18550
|
+
typeof this.monaco.editor.createDiffEditor === 'function' &&
|
|
18551
|
+
_wbComponents &&
|
|
18552
|
+
typeof _wbComponents.CodeLabDiffEditorManager === 'function'
|
|
18553
|
+
);
|
|
18554
|
+
|
|
18555
|
+
if (this._scmDiffManager && typeof this._scmDiffManager.closeInlineDiff === 'function') {
|
|
18556
|
+
try { this._scmDiffManager.closeInlineDiff(); } catch (_err) { void _err; }
|
|
18557
|
+
}
|
|
18558
|
+
|
|
18559
|
+
const headerHtml = `
|
|
18560
|
+
<div class="codelab-scm-diff-header">
|
|
18561
|
+
<div class="codelab-scm-diff-header__title">
|
|
18562
|
+
<strong>${escapeHtml(relPath)}</strong>
|
|
18563
|
+
<span class="codelab-scm-diff-header__meta">${escapeHtml(leftLabel)} → ${escapeHtml(rightLabel)}</span>
|
|
18564
|
+
<span class="codelab-scm-diff-stats">
|
|
18565
|
+
<span class="codelab-scm-diff-stats__add">+${diff.added}</span>
|
|
18566
|
+
<span class="codelab-scm-diff-stats__del">−${diff.removed}</span>
|
|
18567
|
+
</span>
|
|
18568
|
+
</div>
|
|
18569
|
+
<div class="codelab-scm-diff-header__actions">
|
|
18570
|
+
${this.monaco && this.monaco.editor && typeof this.monaco.editor.createDiffEditor === 'function'
|
|
18571
|
+
? `<button type="button" class="codelab-btn" data-cl-action="scm-toggle-diff-mode" title="Toggle Side-by-Side / Inline Diff">${this._scmForceUnifiedDiff ? 'Side-by-Side' : 'Inline'}</button>`
|
|
18572
|
+
: ''}
|
|
18573
|
+
${hasFileInWorktree ? `<button type="button" class="codelab-btn" data-cl-action="scm-diff-open-editor" data-scm-path="${escapeHtml(relPath)}" title="Open File in Editor">Open File</button>` : ''}
|
|
18574
|
+
<button type="button" class="codelab-btn" data-cl-action="scm-close-diff" title="Close Diff View" aria-label="Close Diff">Close Diff</button>
|
|
18575
|
+
</div>
|
|
18576
|
+
</div>
|
|
18577
|
+
`;
|
|
18578
|
+
|
|
18579
|
+
if (canUseMonacoDiff) {
|
|
18580
|
+
hostEl.innerHTML = `${headerHtml}<div class="codelab-scm-monaco-diff" style="flex:1;min-height:0;position:relative;"></div>`;
|
|
18581
|
+
const monacoDiffSlot = hostEl.querySelector('.codelab-scm-monaco-diff');
|
|
18582
|
+
if (monacoDiffSlot) {
|
|
18583
|
+
if (!this._scmDiffManager) {
|
|
18584
|
+
this._scmDiffManager = new _wbComponents.CodeLabDiffEditorManager(this);
|
|
18585
|
+
}
|
|
18586
|
+
const mounted = typeof this._scmDiffManager.mountMonacoDiffIntoSlot === 'function'
|
|
18587
|
+
? this._scmDiffManager.mountMonacoDiffIntoSlot(monacoDiffSlot, {
|
|
18588
|
+
relPath,
|
|
18589
|
+
originalContent: leftText,
|
|
18590
|
+
modifiedContent: rightText,
|
|
18591
|
+
sideBySide: true,
|
|
18592
|
+
readOnly: true
|
|
18593
|
+
})
|
|
18594
|
+
: false;
|
|
18595
|
+
if (mounted) return;
|
|
18596
|
+
}
|
|
18597
|
+
}
|
|
17288
18598
|
|
|
17289
18599
|
const linesHtml = diff.hunks.map((h) => {
|
|
17290
18600
|
const cls = h.type === 'add'
|
|
@@ -17302,20 +18612,7 @@ int main() {
|
|
|
17302
18612
|
}).join('');
|
|
17303
18613
|
|
|
17304
18614
|
hostEl.innerHTML = `
|
|
17305
|
-
|
|
17306
|
-
<div class="codelab-scm-diff-header__title">
|
|
17307
|
-
<strong>${escapeHtml(relPath)}</strong>
|
|
17308
|
-
<span class="codelab-scm-diff-header__meta">${escapeHtml(leftLabel)} → ${escapeHtml(rightLabel)}</span>
|
|
17309
|
-
<span class="codelab-scm-diff-stats">
|
|
17310
|
-
<span class="codelab-scm-diff-stats__add">+${diff.added}</span>
|
|
17311
|
-
<span class="codelab-scm-diff-stats__del">−${diff.removed}</span>
|
|
17312
|
-
</span>
|
|
17313
|
-
</div>
|
|
17314
|
-
<div class="codelab-scm-diff-header__actions">
|
|
17315
|
-
${hasFileInWorktree ? `<button type="button" class="codelab-btn" data-cl-action="scm-diff-open-editor" data-scm-path="${escapeHtml(relPath)}" title="Open File in Editor">Open File</button>` : ''}
|
|
17316
|
-
<button type="button" class="codelab-btn" data-cl-action="scm-close-diff" title="Close Diff View" aria-label="Close Diff">Close Diff</button>
|
|
17317
|
-
</div>
|
|
17318
|
-
</div>
|
|
18615
|
+
${headerHtml}
|
|
17319
18616
|
<div class="codelab-scm-diff-body codelab-diff-unified">
|
|
17320
18617
|
${linesHtml || '<div class="codelab-sidebar-empty">No line differences.</div>'}
|
|
17321
18618
|
</div>
|
|
@@ -18366,8 +19663,10 @@ int main() {
|
|
|
18366
19663
|
this._renderDrawerBody();
|
|
18367
19664
|
} else if (cmd === 'terminal:kill') {
|
|
18368
19665
|
this.killActiveTerminalSession();
|
|
19666
|
+
} else if (cmd === 'terminal:split') {
|
|
19667
|
+
this.splitActiveTerminalSession();
|
|
18369
19668
|
} else if (cmd === 'help:welcome') {
|
|
18370
|
-
this.
|
|
19669
|
+
this.openWelcomeTab();
|
|
18371
19670
|
} else if (cmd === 'help:shortcuts') {
|
|
18372
19671
|
this.showKeyboardShortcutsReference();
|
|
18373
19672
|
} else if (cmd === 'help:about') {
|
|
@@ -18948,19 +20247,20 @@ int main() {
|
|
|
18948
20247
|
if (!slot) return;
|
|
18949
20248
|
this._captureModalReturnFocus();
|
|
18950
20249
|
slot.innerHTML = `
|
|
18951
|
-
<
|
|
18952
|
-
<div class="codelab-modal" role="
|
|
20250
|
+
<dialog class="codelab-dialog" closedby="any" aria-label="About CodeLab" style="max-width:420px;">
|
|
20251
|
+
<div class="codelab-modal" role="document">
|
|
18953
20252
|
<div class="codelab-modal__header">
|
|
18954
20253
|
<span>About CodeLab</span>
|
|
18955
20254
|
<button type="button" class="codelab-btn" data-cl-action="close-modal">Close (Esc)</button>
|
|
18956
20255
|
</div>
|
|
18957
20256
|
<div class="codelab-modal__body" style="font-size:13px;line-height:1.5;">
|
|
18958
20257
|
<p style="margin:0 0 8px;"><strong>@innovatorved/code-lab</strong> — Full-featured in-browser IDE & runtime workbench.</p>
|
|
18959
|
-
<p style="margin:0;color:var(--cl-fg-muted);font-size:12px;">Node.js v22 Worker · TypeScript 5.x · C++20 WASI · Python 3.12 WASI · SQLite / PostgreSQL</p>
|
|
20258
|
+
<p style="margin:0;color:var(--cl-fg-muted);font-size:12px;">Node.js v22 Worker · TypeScript 5.x · C++20 WASI · Python 3.12 WASI · SQLite / PostgreSQL · Git</p>
|
|
18960
20259
|
</div>
|
|
18961
20260
|
</div>
|
|
18962
|
-
</
|
|
20261
|
+
</dialog>
|
|
18963
20262
|
`;
|
|
20263
|
+
this._openModalDialog(slot);
|
|
18964
20264
|
const closeBtn = slot.querySelector('[data-cl-action="close-modal"]');
|
|
18965
20265
|
if (closeBtn && typeof closeBtn.focus === 'function') closeBtn.focus();
|
|
18966
20266
|
}
|
|
@@ -18974,6 +20274,10 @@ int main() {
|
|
|
18974
20274
|
active.logs = fresh;
|
|
18975
20275
|
}
|
|
18976
20276
|
}
|
|
20277
|
+
const activeXt = this._getActiveXtermEngine();
|
|
20278
|
+
if (activeXt && typeof activeXt.clear === 'function') {
|
|
20279
|
+
try { activeXt.clear(); } catch (_err) { void _err; }
|
|
20280
|
+
}
|
|
18977
20281
|
}
|
|
18978
20282
|
|
|
18979
20283
|
_renderTerminalSessionsBar() {
|
|
@@ -19114,6 +20418,16 @@ int main() {
|
|
|
19114
20418
|
try { this._activeCommandAbortController.abort(); } catch (_err) { void _err; }
|
|
19115
20419
|
this._activeCommandAbortController = null;
|
|
19116
20420
|
}
|
|
20421
|
+
if (this._xtermEngines instanceof Map) {
|
|
20422
|
+
const oldEng = this._xtermEngines.get(sessions[0].id);
|
|
20423
|
+
if (oldEng && typeof oldEng.destroy === 'function') {
|
|
20424
|
+
try { oldEng.destroy(); } catch (_err) { void _err; }
|
|
20425
|
+
}
|
|
20426
|
+
this._xtermEngines.delete(sessions[0].id);
|
|
20427
|
+
}
|
|
20428
|
+
this._splitTerminalSessionIds = [];
|
|
20429
|
+
this._splitTerminalSessionId = null;
|
|
20430
|
+
this._xtermWrapLayoutKey = '';
|
|
19117
20431
|
this.isRunning = false;
|
|
19118
20432
|
const freshSession = {
|
|
19119
20433
|
id: 'session-1',
|
|
@@ -19138,6 +20452,23 @@ int main() {
|
|
|
19138
20452
|
|
|
19139
20453
|
this._saveActiveTerminalSessionState();
|
|
19140
20454
|
const removed = sessions.splice(idx, 1)[0];
|
|
20455
|
+
if (this._xtermEngines instanceof Map && removed) {
|
|
20456
|
+
const oldEng = this._xtermEngines.get(removed.id);
|
|
20457
|
+
if (oldEng && typeof oldEng.destroy === 'function') {
|
|
20458
|
+
try { oldEng.destroy(); } catch (_err) { void _err; }
|
|
20459
|
+
}
|
|
20460
|
+
this._xtermEngines.delete(removed.id);
|
|
20461
|
+
}
|
|
20462
|
+
if (removed && this._splitTerminalSessionId === removed.id) {
|
|
20463
|
+
this._splitTerminalSessionId = null;
|
|
20464
|
+
}
|
|
20465
|
+
this._xtermWrapLayoutKey = '';
|
|
20466
|
+
if (Array.isArray(this._splitTerminalSessionIds) && removed) {
|
|
20467
|
+
this._splitTerminalSessionIds = this._splitTerminalSessionIds.filter((sid) => sid !== removed.id);
|
|
20468
|
+
if (this._splitTerminalSessionIds.length < 2) {
|
|
20469
|
+
this._splitTerminalSessionIds = [];
|
|
20470
|
+
}
|
|
20471
|
+
}
|
|
19141
20472
|
if (this._activeTerminalSessionId === removed.id) {
|
|
19142
20473
|
if (this._activeCommandAbortController) {
|
|
19143
20474
|
try { this._activeCommandAbortController.abort(); } catch (_err) { void _err; }
|
|
@@ -19845,6 +21176,11 @@ int main() {
|
|
|
19845
21176
|
else gs.staged = new Map();
|
|
19846
21177
|
if (gs.stagedFiles && typeof gs.stagedFiles.clear === 'function') gs.stagedFiles.clear();
|
|
19847
21178
|
gs.commits = Array.isArray(result.commits) ? result.commits : [];
|
|
21179
|
+
if (root.CodeLabScm && typeof root.CodeLabScm.syncToIsoGitRepo === 'function' && this.shell && this.shell.vfs) {
|
|
21180
|
+
Promise.resolve(root.CodeLabScm.syncToIsoGitRepo(this.shell.vfs, gs, targetDir)).catch((_e) => {
|
|
21181
|
+
void _e;
|
|
21182
|
+
});
|
|
21183
|
+
}
|
|
19848
21184
|
}
|
|
19849
21185
|
|
|
19850
21186
|
this._updateTopbarBrandTitle();
|
|
@@ -20099,6 +21435,34 @@ int main() {
|
|
|
20099
21435
|
this._editorResizeObserver.disconnect();
|
|
20100
21436
|
this._editorResizeObserver = null;
|
|
20101
21437
|
}
|
|
21438
|
+
if (typeof this._systemSchemeCleanup === 'function') {
|
|
21439
|
+
try { this._systemSchemeCleanup(); } catch (_err) { void _err; }
|
|
21440
|
+
this._systemSchemeCleanup = null;
|
|
21441
|
+
}
|
|
21442
|
+
if (this._ataController && typeof this._ataController.dispose === 'function') {
|
|
21443
|
+
try { this._ataController.dispose(); } catch (_err) { void _err; }
|
|
21444
|
+
this._ataController = null;
|
|
21445
|
+
}
|
|
21446
|
+
if (this._editorOpenerDisposable && typeof this._editorOpenerDisposable.dispose === 'function') {
|
|
21447
|
+
try { this._editorOpenerDisposable.dispose(); } catch (_err) { void _err; }
|
|
21448
|
+
this._editorOpenerDisposable = null;
|
|
21449
|
+
}
|
|
21450
|
+
if (this._autoCloseTagDisposable && typeof this._autoCloseTagDisposable.dispose === 'function') {
|
|
21451
|
+
try { this._autoCloseTagDisposable.dispose(); } catch (_err) { void _err; }
|
|
21452
|
+
this._autoCloseTagDisposable = null;
|
|
21453
|
+
}
|
|
21454
|
+
if (this._xtermEngines instanceof Map) {
|
|
21455
|
+
for (const eng of this._xtermEngines.values()) {
|
|
21456
|
+
if (eng && typeof eng.destroy === 'function') {
|
|
21457
|
+
try { eng.destroy(); } catch (_err) { void _err; }
|
|
21458
|
+
}
|
|
21459
|
+
}
|
|
21460
|
+
this._xtermEngines.clear();
|
|
21461
|
+
}
|
|
21462
|
+
if (this._scmDiffManager && typeof this._scmDiffManager.closeInlineDiff === 'function') {
|
|
21463
|
+
try { this._scmDiffManager.closeInlineDiff(); } catch (_err) { void _err; }
|
|
21464
|
+
this._scmDiffManager = null;
|
|
21465
|
+
}
|
|
20102
21466
|
if (this._diffManager && typeof this._diffManager.closeInlineDiff === 'function') {
|
|
20103
21467
|
try {
|
|
20104
21468
|
this._diffManager.closeInlineDiff();
|
|
@@ -20238,6 +21602,8 @@ int main() {
|
|
|
20238
21602
|
});
|
|
20239
21603
|
}
|
|
20240
21604
|
|
|
21605
|
+
get vfs() { return this._instance ? this._instance.vfs : null; }
|
|
21606
|
+
get shell() { return this._instance ? this._instance.shell : null; }
|
|
20241
21607
|
getFiles() { return this._instance ? this._instance.getFiles() : {}; }
|
|
20242
21608
|
setFiles(filesMap, opts) { return this._instance ? this._instance.setFiles(filesMap, opts) : undefined; }
|
|
20243
21609
|
getFile(path) { return this._instance ? this._instance.getFile(path) : null; }
|
|
@@ -20323,6 +21689,7 @@ int main() {
|
|
|
20323
21689
|
toggleTerminal() { if (this._instance) this._instance.toggleTerminal(); }
|
|
20324
21690
|
listTerminalSessions() { return this._instance ? this._instance.listTerminalSessions() : []; }
|
|
20325
21691
|
createTerminalSession(name) { return this._instance ? this._instance.createTerminalSession(name) : null; }
|
|
21692
|
+
splitActiveTerminalSession() { return this._instance ? this._instance.splitActiveTerminalSession() : null; }
|
|
20326
21693
|
switchTerminalSession(id) { return this._instance ? this._instance.switchTerminalSession(id) : false; }
|
|
20327
21694
|
closeTerminalSession(id) { return this._instance ? this._instance.closeTerminalSession(id) : false; }
|
|
20328
21695
|
killActiveTerminalSession() { return this._instance ? this._instance.killActiveTerminalSession() : false; }
|
|
@@ -20333,6 +21700,8 @@ int main() {
|
|
|
20333
21700
|
openBlankWorkspace(opts) { return this._instance ? this._instance.openBlankWorkspace(opts) : Promise.resolve(null); }
|
|
20334
21701
|
newBlankWorkspace(title) { return this._instance ? this._instance.newBlankWorkspace(title) : null; }
|
|
20335
21702
|
switchWorkspace(id, opts) { return this._instance ? this._instance.switchWorkspace(id, opts) : Promise.resolve(false); }
|
|
21703
|
+
openWelcomeTab() { if (this._instance) this._instance.openWelcomeTab(); }
|
|
21704
|
+
closeWelcomeTab() { if (this._instance) this._instance.closeWelcomeTab(); }
|
|
20336
21705
|
openSettings(opts) { if (this._instance) this._instance.openSettings(opts); }
|
|
20337
21706
|
closeSettings() { if (this._instance) this._instance.closeSettings(); }
|
|
20338
21707
|
openWorkspaceSettingsJson() { if (this._instance) this._instance.openWorkspaceSettingsJson(); }
|