@innovatorved/code-lab 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ARCHITECTURE.md +11 -6
- package/CHANGELOG.md +27 -0
- package/README.md +18 -8
- package/dist/code-lab.css +198 -0
- package/dist/code-lab.d.ts +27 -9
- package/dist/code-lab.esm.js +8248 -83
- package/dist/code-lab.js +8246 -81
- package/dist/extensions/cpp.d.ts +32 -6
- package/dist/extensions/cpp.esm.js +745 -6
- package/dist/extensions/cpp.js +745 -6
- package/dist/extensions/guided-lab.esm.js +39 -1
- package/dist/extensions/guided-lab.js +39 -1
- package/dist/extensions/python.d.ts +92 -0
- package/dist/extensions/python.esm.js +5476 -0
- package/dist/extensions/python.js +5495 -0
- package/dist/index.d.ts +7 -4
- package/dist/preview-sw.js +1 -1
- package/dist/runtime/index.d.ts +4 -0
- package/dist/runtime/module-loader.d.ts +11 -0
- package/dist/runtime/test-harness.d.ts +24 -0
- package/dist/runtime/vfs.d.ts +31 -0
- package/dist/runtime/wasi-host.d.ts +33 -0
- package/dist/runtime.esm.js +36 -4
- package/dist/runtime.js +36 -4
- package/dist/schemas.d.ts +134 -21
- package/dist/schemas.esm.js +43 -1
- package/dist/schemas.js +43 -1
- package/dist/shell/coreutils/compilers-cli.d.ts +24 -0
- package/dist/shell/index.d.ts +4 -0
- package/dist/shell/lexer-parser.d.ts +26 -0
- package/dist/shell.esm.js +113 -1
- package/dist/shell.js +113 -1
- package/dist/terminal.esm.js +1 -1
- package/dist/terminal.js +1 -1
- package/dist/workbench/command-palette.d.ts +10 -0
- package/dist/workbench/diff-editor.d.ts +26 -0
- package/dist/workbench/drawer.d.ts +18 -0
- package/dist/workbench/editor.d.ts +11 -0
- package/dist/workbench/file-tree.d.ts +11 -0
- package/dist/workbench/guided-pane.d.ts +11 -0
- package/dist/workbench/icons.d.ts +5 -0
- package/dist/workbench/index.d.ts +39 -0
- package/dist/workbench/share.d.ts +21 -0
- package/dist/workbench/styles.d.ts +4 -0
- package/dist/workbench/toolbar.d.ts +17 -0
- package/dist/workbench.d.ts +6 -1
- package/package.json +8 -2
- package/src/code-lab.css +198 -0
- package/src/extensions/cpp.ts +710 -5
- package/src/extensions/python.ts +1293 -0
- package/src/index.ts +35 -3
- package/src/runtime/index.ts +5 -0
- package/src/runtime/test-harness.ts +57 -0
- package/src/runtime.ts +35 -3
- package/src/schemas.ts +46 -1
- package/src/shell/coreutils/compilers-cli.ts +103 -0
- package/src/shell/index.ts +5 -0
- package/src/shell.ts +112 -0
- package/src/workbench/command-palette.ts +140 -0
- package/src/workbench/diff-editor.ts +216 -0
- package/src/workbench/drawer.ts +148 -0
- package/src/workbench/editor.ts +49 -0
- package/src/workbench/file-tree.ts +51 -0
- package/src/workbench/guided-pane.ts +33 -0
- package/src/workbench/icons.ts +48 -0
- package/src/workbench/index.ts +38 -0
- package/src/workbench/share.ts +99 -0
- package/src/workbench/styles.ts +200 -0
- package/src/workbench/toolbar.ts +171 -0
- package/src/workbench.ts +755 -70
package/src/workbench.ts
CHANGED
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
|
|
58
58
|
// The bundler rewrites this literal from package.json at build time. Keeping
|
|
59
59
|
// the fallback in sync lets tests require src/workbench.js directly.
|
|
60
|
-
const CODELAB_VERSION = '0.
|
|
60
|
+
const CODELAB_VERSION = '0.3.0';
|
|
61
61
|
|
|
62
62
|
// Ambient TypeScript declarations for Node.js built-ins inside Monaco
|
|
63
63
|
const NODE_AMBIENT_DTS = `
|
|
@@ -1135,8 +1135,8 @@ int main() {
|
|
|
1135
1135
|
`
|
|
1136
1136
|
};
|
|
1137
1137
|
|
|
1138
|
-
// Helper to convert JS file set to TS or
|
|
1139
|
-
function mapFilesToLanguage(filesObj, lang, explicitTsFiles, explicitCppFiles) {
|
|
1138
|
+
// Helper to convert JS file set to TS, C++, or Python file set if explicit language files aren't provided
|
|
1139
|
+
function mapFilesToLanguage(filesObj, lang, explicitTsFiles, explicitCppFiles, explicitPyFiles) {
|
|
1140
1140
|
if (lang === 'ts' && explicitTsFiles && Object.keys(explicitTsFiles).length > 0) {
|
|
1141
1141
|
return { ...explicitTsFiles };
|
|
1142
1142
|
}
|
|
@@ -1159,6 +1159,25 @@ int main() {
|
|
|
1159
1159
|
}
|
|
1160
1160
|
return outCpp;
|
|
1161
1161
|
}
|
|
1162
|
+
if (lang === 'py') {
|
|
1163
|
+
if (explicitPyFiles && Object.keys(explicitPyFiles).length > 0) {
|
|
1164
|
+
return { ...explicitPyFiles };
|
|
1165
|
+
}
|
|
1166
|
+
const existingPy = {};
|
|
1167
|
+
for (const [name, content] of Object.entries(filesObj || {})) {
|
|
1168
|
+
if (/\.(py|md)$/i.test(name)) {
|
|
1169
|
+
existingPy[name] = content;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
if (Object.keys(existingPy).some(f => /\.py$/i.test(f))) {
|
|
1173
|
+
return existingPy;
|
|
1174
|
+
}
|
|
1175
|
+
const outPy = { ...DEFAULT_STANDALONE_PYTHON_FILES };
|
|
1176
|
+
if (filesObj && filesObj['README.md']) {
|
|
1177
|
+
outPy['README.md'] = filesObj['README.md'];
|
|
1178
|
+
}
|
|
1179
|
+
return outPy;
|
|
1180
|
+
}
|
|
1162
1181
|
const out = {};
|
|
1163
1182
|
for (const [name, content] of Object.entries(filesObj || {})) {
|
|
1164
1183
|
if (lang === 'ts' && name.endsWith('.js')) {
|
|
@@ -1173,6 +1192,11 @@ int main() {
|
|
|
1173
1192
|
return out;
|
|
1174
1193
|
}
|
|
1175
1194
|
|
|
1195
|
+
const DEFAULT_STANDALONE_PYTHON_FILES = {
|
|
1196
|
+
'main.py': `"""\\nStandalone Python 3.12 Sandbox with CPython WebAssembly.\\n"""\\nfrom codelab_test import describe, it, assert_equal\\n\\ndef solve(x):\\n return x\\n\\nif __name__ == '__main__':\\n print("Hello from Python 3.12 in CodeLab!")\\n print("Output:", solve({"status": "ok"}))\\n`,
|
|
1197
|
+
'test.py': `from codelab_test import describe, it, assert_equal\\nfrom main import solve\\n\\nwith describe("Python Sandbox Test Suite"):\\n with it("returns input value"):\\n assert_equal(solve(42), 42)\\n`
|
|
1198
|
+
};
|
|
1199
|
+
|
|
1176
1200
|
const DEFAULT_STANDALONE_FILES = {
|
|
1177
1201
|
'index.js': `'use strict';\n\nfunction solve(input) {\n return input;\n}\n\nmodule.exports = { solve };\n`,
|
|
1178
1202
|
'demo.js': `'use strict';\nconst { solve } = require('./index.js');\n\nconsole.log('Demo output:', solve({ status: 'ok', timestamp: Date.now() }));\n`,
|
|
@@ -1215,7 +1239,12 @@ int main() {
|
|
|
1215
1239
|
tablet: '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="2" width="16" height="20" rx="2"/><line x1="12" y1="18" x2="12.01" y2="18"/></svg>',
|
|
1216
1240
|
smartphone: '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="7" y="2" width="10" height="20" rx="2"/><line x1="12" y1="18" x2="12.01" y2="18"/></svg>',
|
|
1217
1241
|
externalLink: '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',
|
|
1218
|
-
x: '<svg width="12" height="12" 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>'
|
|
1242
|
+
x: '<svg width="12" height="12" 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>',
|
|
1243
|
+
warning: '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',
|
|
1244
|
+
clock: '<svg width="12" height="12" 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"/><polyline points="12 6 12 12 16 14"/></svg>',
|
|
1245
|
+
memory: '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 19v2"/><path d="M10 19v2"/><path d="M14 19v2"/><path d="M18 19v2"/><path d="M6 3v2"/><path d="M10 3v2"/><path d="M14 3v2"/><path d="M18 3v2"/><rect x="2" y="5" width="20" height="14" rx="2"/></svg>',
|
|
1246
|
+
keyboard: '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="4" width="20" height="16" rx="2"/><path d="M6 8h.01"/><path d="M10 8h.01"/><path d="M14 8h.01"/><path d="M18 8h.01"/><path d="M6 12h.01"/><path d="M10 12h.01"/><path d="M14 12h.01"/><path d="M18 12h.01"/><path d="M7 16h10"/></svg>',
|
|
1247
|
+
share: '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><line x1="8.59" y1="13.51" x2="15.42" y2="17.49"/><line x1="15.41" y1="6.51" x2="8.59" y2="10.49"/></svg>'
|
|
1219
1248
|
};
|
|
1220
1249
|
|
|
1221
1250
|
let _workbenchInstanceCounter = 0;
|
|
@@ -1392,7 +1421,9 @@ int main() {
|
|
|
1392
1421
|
...(options.tsStarterFiles ? { tsStarterFiles: options.tsStarterFiles } : {}),
|
|
1393
1422
|
...((options.tsSolutionFiles || options.tsFiles) ? { tsSolutionFiles: options.tsSolutionFiles || options.tsFiles } : {}),
|
|
1394
1423
|
...(options.cppStarterFiles ? { cppStarterFiles: options.cppStarterFiles } : {}),
|
|
1395
|
-
...((options.cppSolutionFiles || options.cppFiles) ? { cppSolutionFiles: options.cppSolutionFiles || options.cppFiles } : {})
|
|
1424
|
+
...((options.cppSolutionFiles || options.cppFiles) ? { cppSolutionFiles: options.cppSolutionFiles || options.cppFiles } : {}),
|
|
1425
|
+
...(options.pyStarterFiles ? { pyStarterFiles: options.pyStarterFiles } : {}),
|
|
1426
|
+
...((options.pySolutionFiles || options.pyFiles) ? { pySolutionFiles: options.pySolutionFiles || options.pyFiles } : {})
|
|
1396
1427
|
};
|
|
1397
1428
|
this.steps = options.steps || this.guidedConfig?.steps || [];
|
|
1398
1429
|
this.hasGuidedLab = Boolean(
|
|
@@ -1403,7 +1434,7 @@ int main() {
|
|
|
1403
1434
|
this.enabledLanguages = new Set(['js']);
|
|
1404
1435
|
if (Array.isArray(options.languages)) {
|
|
1405
1436
|
for (const l of options.languages) {
|
|
1406
|
-
if (l === 'js' || l === 'ts' || l === 'cpp') this.enabledLanguages.add(l);
|
|
1437
|
+
if (l === 'js' || l === 'ts' || l === 'cpp' || l === 'py') this.enabledLanguages.add(l);
|
|
1407
1438
|
}
|
|
1408
1439
|
}
|
|
1409
1440
|
if (
|
|
@@ -1425,6 +1456,15 @@ int main() {
|
|
|
1425
1456
|
) {
|
|
1426
1457
|
this.enabledLanguages.add('cpp');
|
|
1427
1458
|
}
|
|
1459
|
+
if (
|
|
1460
|
+
this.guidedConfig.pyStarterFiles ||
|
|
1461
|
+
this.guidedConfig.pySolutionFiles ||
|
|
1462
|
+
this.guidedConfig.pyFiles ||
|
|
1463
|
+
options.lang === 'py' ||
|
|
1464
|
+
options.language === 'py'
|
|
1465
|
+
) {
|
|
1466
|
+
this.enabledLanguages.add('py');
|
|
1467
|
+
}
|
|
1428
1468
|
this.hasMultipleLanguages = Boolean(
|
|
1429
1469
|
options.hasMultipleLanguages ||
|
|
1430
1470
|
options.languages ||
|
|
@@ -1435,8 +1475,13 @@ int main() {
|
|
|
1435
1475
|
this.guidedConfig.cppStarterFiles ||
|
|
1436
1476
|
this.guidedConfig.cppSolutionFiles ||
|
|
1437
1477
|
this.guidedConfig.cppFiles ||
|
|
1478
|
+
this.guidedConfig.pyStarterFiles ||
|
|
1479
|
+
this.guidedConfig.pySolutionFiles ||
|
|
1480
|
+
this.guidedConfig.pyFiles ||
|
|
1438
1481
|
(this.hasGuidedLab && (options.lang || options.language))
|
|
1439
1482
|
);
|
|
1483
|
+
this.showWebPreviewOption = Boolean(options.showWebPreview);
|
|
1484
|
+
this._diffManager = null;
|
|
1440
1485
|
|
|
1441
1486
|
// Load saved user state from localStorage (with in-memory fallback)
|
|
1442
1487
|
this.savedState = this._loadState();
|
|
@@ -1463,7 +1508,12 @@ int main() {
|
|
|
1463
1508
|
this.renamingItem = null;
|
|
1464
1509
|
this._draggedFile = null;
|
|
1465
1510
|
this.guideTab = 'steps'; // 'steps' | 'readme'
|
|
1466
|
-
this.drawerTab =
|
|
1511
|
+
this.drawerTab = (this.hasGuidedLab && this.mode === 'guided') ? 'tests' : 'terminal';
|
|
1512
|
+
this.testSuiteVisible = Boolean(this.hasGuidedLab && this.mode === 'guided');
|
|
1513
|
+
this.lastDurationMs = null;
|
|
1514
|
+
this.lastPeakMemoryBytes = null;
|
|
1515
|
+
this.customStdin = (options && options.stdin) || '';
|
|
1516
|
+
this._eventsBound = false;
|
|
1467
1517
|
// ── Web Preview (M3) state ──
|
|
1468
1518
|
this.previewState = {
|
|
1469
1519
|
port: null,
|
|
@@ -1601,6 +1651,7 @@ int main() {
|
|
|
1601
1651
|
this._renderShell();
|
|
1602
1652
|
this._bindEvents();
|
|
1603
1653
|
this._initEditor();
|
|
1654
|
+
this._checkUrlSnapshot();
|
|
1604
1655
|
|
|
1605
1656
|
const initialPlugins = [
|
|
1606
1657
|
...(Array.isArray(options.extensions) ? options.extensions : []),
|
|
@@ -2032,9 +2083,12 @@ int main() {
|
|
|
2032
2083
|
}
|
|
2033
2084
|
}
|
|
2034
2085
|
if (durEl) {
|
|
2035
|
-
|
|
2086
|
+
const ms = (typeof this.lastDurationMs === 'number' && !Number.isNaN(this.lastDurationMs))
|
|
2087
|
+
? this.lastDurationMs
|
|
2088
|
+
: this.lastRunDurationMs;
|
|
2089
|
+
if (typeof ms === 'number' && !Number.isNaN(ms)) {
|
|
2036
2090
|
durEl.style.display = 'inline-flex';
|
|
2037
|
-
durEl.textContent = `⚡ ${
|
|
2091
|
+
durEl.textContent = `⚡ ${ms.toFixed(1)}ms`;
|
|
2038
2092
|
} else {
|
|
2039
2093
|
durEl.style.display = 'none';
|
|
2040
2094
|
}
|
|
@@ -2045,10 +2099,13 @@ int main() {
|
|
|
2045
2099
|
if (langEl) {
|
|
2046
2100
|
langEl.textContent = this.lang === 'cpp'
|
|
2047
2101
|
? 'C++20 (Clang/WASI)'
|
|
2048
|
-
: this.lang === '
|
|
2049
|
-
? '
|
|
2050
|
-
:
|
|
2102
|
+
: this.lang === 'py'
|
|
2103
|
+
? 'Python 3.12 (CPython WASI)'
|
|
2104
|
+
: this.lang === 'ts'
|
|
2105
|
+
? 'TypeScript 5.x'
|
|
2106
|
+
: 'JavaScript (CJS/ESM)';
|
|
2051
2107
|
}
|
|
2108
|
+
this._updateTelemetryHud();
|
|
2052
2109
|
}
|
|
2053
2110
|
|
|
2054
2111
|
_getBaseFilesForModeAndLang(mode, lang) {
|
|
@@ -2057,19 +2114,21 @@ int main() {
|
|
|
2057
2114
|
...this.referenceFiles,
|
|
2058
2115
|
...(this.guidedConfig?.starterFiles || {})
|
|
2059
2116
|
};
|
|
2060
|
-
if (mode === 'guided' && (this.guidedConfig?.starterFiles || this.guidedConfig?.tsStarterFiles || this.guidedConfig?.cppStarterFiles)) {
|
|
2117
|
+
if (mode === 'guided' && (this.guidedConfig?.starterFiles || this.guidedConfig?.tsStarterFiles || this.guidedConfig?.cppStarterFiles || this.guidedConfig?.pyStarterFiles)) {
|
|
2061
2118
|
return mapFilesToLanguage(
|
|
2062
2119
|
baseJsStarter,
|
|
2063
2120
|
lang,
|
|
2064
2121
|
this.guidedConfig?.tsStarterFiles,
|
|
2065
|
-
this.guidedConfig?.cppStarterFiles
|
|
2122
|
+
this.guidedConfig?.cppStarterFiles,
|
|
2123
|
+
this.guidedConfig?.pyStarterFiles
|
|
2066
2124
|
);
|
|
2067
2125
|
}
|
|
2068
2126
|
return mapFilesToLanguage(
|
|
2069
2127
|
baseJsSolution,
|
|
2070
2128
|
lang,
|
|
2071
2129
|
this.guidedConfig?.tsSolutionFiles,
|
|
2072
|
-
this.guidedConfig?.cppSolutionFiles
|
|
2130
|
+
this.guidedConfig?.cppSolutionFiles,
|
|
2131
|
+
this.guidedConfig?.pySolutionFiles
|
|
2073
2132
|
);
|
|
2074
2133
|
}
|
|
2075
2134
|
|
|
@@ -2093,6 +2152,20 @@ int main() {
|
|
|
2093
2152
|
|
|
2094
2153
|
_pickDefaultFile() {
|
|
2095
2154
|
const names = Object.keys(this.files);
|
|
2155
|
+
if (this.lang === 'py') {
|
|
2156
|
+
if (this.guidedConfig?.mainFile) {
|
|
2157
|
+
const pyMain = this.guidedConfig.mainFile.replace(/\.(js|ts|cpp)$/, '.py');
|
|
2158
|
+
if (this.files[pyMain]) return pyMain;
|
|
2159
|
+
}
|
|
2160
|
+
if (this.files['main.py']) return 'main.py';
|
|
2161
|
+
if (this.files['solution.py']) return 'solution.py';
|
|
2162
|
+
if (this.files['app.py']) return 'app.py';
|
|
2163
|
+
const pyImpl = names.find(f =>
|
|
2164
|
+
/\.py$/i.test(f) &&
|
|
2165
|
+
!/(^|\/)(demo|test.*|.*_test)\.py$/i.test(f)
|
|
2166
|
+
);
|
|
2167
|
+
return pyImpl || names.find(f => !f.endsWith('.md')) || names[0] || '';
|
|
2168
|
+
}
|
|
2096
2169
|
if (this.lang === 'cpp') {
|
|
2097
2170
|
if (this.guidedConfig?.mainFile) {
|
|
2098
2171
|
const cppMain = this.guidedConfig.mainFile.replace(/\.(js|ts)$/, '.hpp');
|
|
@@ -2124,6 +2197,29 @@ int main() {
|
|
|
2124
2197
|
|
|
2125
2198
|
_findEntryFile(kind) {
|
|
2126
2199
|
const names = Object.keys(this.files);
|
|
2200
|
+
if (this.lang === 'py') {
|
|
2201
|
+
if (kind === 'test') {
|
|
2202
|
+
if (this.explicitTestEntry) {
|
|
2203
|
+
const pyTest = this.explicitTestEntry.replace(/\.(js|ts|cpp)$/, '.py');
|
|
2204
|
+
if (this.files[pyTest]) return pyTest;
|
|
2205
|
+
if (this.files[this.explicitTestEntry]) return this.explicitTestEntry;
|
|
2206
|
+
}
|
|
2207
|
+
if (this.files['test.py']) return 'test.py';
|
|
2208
|
+
if (this.files['test_main.py']) return 'test_main.py';
|
|
2209
|
+
return names.find(f => /(^|\/)(test.*|.*_test)\.py$/i.test(f)) || null;
|
|
2210
|
+
}
|
|
2211
|
+
if (this.explicitEntry) {
|
|
2212
|
+
const pyEntry = this.explicitEntry.replace(/\.(js|ts|cpp)$/, '.py');
|
|
2213
|
+
if (this.files[pyEntry]) return pyEntry;
|
|
2214
|
+
if (this.files[this.explicitEntry]) return this.explicitEntry;
|
|
2215
|
+
}
|
|
2216
|
+
if (this.files['main.py']) return 'main.py';
|
|
2217
|
+
if (this.files['demo.py']) return 'demo.py';
|
|
2218
|
+
if (this.files['app.py']) return 'app.py';
|
|
2219
|
+
return names.find(f => /(^|\/)(main|demo|app)\.py$/i.test(f)) ||
|
|
2220
|
+
names.find(f => /\.py$/i.test(f) && !/(^|\/)(test.*|.*_test)\.py$/i.test(f)) ||
|
|
2221
|
+
null;
|
|
2222
|
+
}
|
|
2127
2223
|
if (this.lang === 'cpp') {
|
|
2128
2224
|
if (kind === 'test') {
|
|
2129
2225
|
if (this.explicitTestEntry) {
|
|
@@ -2155,16 +2251,16 @@ int main() {
|
|
|
2155
2251
|
if (this.files[candidate]) return candidate;
|
|
2156
2252
|
if (this.files[this.explicitEntry]) return this.explicitEntry;
|
|
2157
2253
|
}
|
|
2158
|
-
const pattern = kind === 'test' ? /(^|\/)test\.(js|ts|cpp|cc|cxx)$/i : /(^|\/)(demo|main)\.(js|ts|cpp|cc|cxx)$/i;
|
|
2254
|
+
const pattern = kind === 'test' ? /(^|\/)test\.(js|ts|cpp|cc|cxx|py)$/i : /(^|\/)(demo|main)\.(js|ts|cpp|cc|cxx|py)$/i;
|
|
2159
2255
|
const found = names.find(f => pattern.test(f));
|
|
2160
2256
|
if (found) return found;
|
|
2161
2257
|
if (kind === 'demo') {
|
|
2162
|
-
const isConfigOrTest = f => /(^|\/)(test|.*\.(?:test|spec|config|d))\.(js|ts|mjs|cjs|cpp|cc|cxx)$/i.test(f) || /(^|\/)\.[^/]+$/i.test(f);
|
|
2258
|
+
const isConfigOrTest = f => /(^|\/)(test|.*\.(?:test|spec|config|d))\.(js|ts|mjs|cjs|cpp|cc|cxx|py)$/i.test(f) || /(^|\/)\.[^/]+$/i.test(f);
|
|
2163
2259
|
const hasHtmlEntry = Boolean(this.files['index.html'] || this.files['public/index.html']);
|
|
2164
2260
|
if (hasHtmlEntry) {
|
|
2165
2261
|
return names.find(f => /(^|\/)(server|app|demo)\.(js|ts)$/i.test(f) && !/^src\//i.test(f)) || null;
|
|
2166
2262
|
}
|
|
2167
|
-
return names.find(f => /\.(js|ts|cpp|cc|cxx)$/i.test(f) && !isConfigOrTest(f)) || null;
|
|
2263
|
+
return names.find(f => /\.(js|ts|cpp|cc|cxx|py)$/i.test(f) && !isConfigOrTest(f)) || null;
|
|
2168
2264
|
}
|
|
2169
2265
|
return null;
|
|
2170
2266
|
}
|
|
@@ -2186,11 +2282,19 @@ int main() {
|
|
|
2186
2282
|
? 'Send Ctrl+C — interrupt the running command'
|
|
2187
2283
|
: 'Send Ctrl+C (clears the current input line)';
|
|
2188
2284
|
}
|
|
2189
|
-
this.container.querySelectorAll('[data-cl-action="run-demo"], [data-cl-action="run-tests"], [data-cl-action="verify-step"]').forEach(btn => {
|
|
2285
|
+
this.container.querySelectorAll('[data-cl-action="run-code"], [data-cl-action="run-entry"], [data-cl-action="run-active-file"], [data-cl-action="run-demo"], [data-cl-action="run-tests"], [data-cl-action="verify-step"]').forEach(btn => {
|
|
2190
2286
|
btn.disabled = this.isRunning;
|
|
2191
2287
|
});
|
|
2192
2288
|
}
|
|
2193
2289
|
|
|
2290
|
+
_hasWebContent() {
|
|
2291
|
+
if (this.showWebPreviewOption === true) return true;
|
|
2292
|
+
if (!this.files) return false;
|
|
2293
|
+
if (this.files['index.html'] || this.files['src/index.html'] || this.files['public/index.html']) return true;
|
|
2294
|
+
if (this.portTable && typeof this.portTable.listServers === 'function' && this.portTable.listServers().length > 0) return true;
|
|
2295
|
+
return false;
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2194
2298
|
_renderLanguageSwitcherHtml() {
|
|
2195
2299
|
const hasMulti = Boolean(
|
|
2196
2300
|
this.hasMultipleLanguages ||
|
|
@@ -2203,11 +2307,13 @@ int main() {
|
|
|
2203
2307
|
!this.enabledLanguages.has('cpp')
|
|
2204
2308
|
);
|
|
2205
2309
|
const showCpp = Boolean(this.enabledLanguages && this.enabledLanguages.has('cpp'));
|
|
2310
|
+
const showPy = Boolean(this.enabledLanguages && this.enabledLanguages.has('py'));
|
|
2206
2311
|
return `
|
|
2207
2312
|
<div class="codelab-lang-switch" role="group" aria-label="Language Selector">
|
|
2208
2313
|
<button type="button" class="codelab-lang-btn ${this.lang === 'js' ? 'active' : ''}" data-cl-lang="js" data-lang="js" aria-pressed="${this.lang === 'js'}">JS</button>
|
|
2209
2314
|
${showTs ? `<button type="button" class="codelab-lang-btn ${this.lang === 'ts' ? 'active' : ''}" data-cl-lang="ts" data-lang="ts" aria-pressed="${this.lang === 'ts'}">TS</button>` : ''}
|
|
2210
2315
|
${showCpp ? `<button type="button" class="codelab-lang-btn ${this.lang === 'cpp' ? 'active' : ''}" data-cl-lang="cpp" data-lang="cpp" aria-pressed="${this.lang === 'cpp'}">C++</button>` : ''}
|
|
2316
|
+
${showPy ? `<button type="button" class="codelab-lang-btn ${this.lang === 'py' ? 'active' : ''}" data-cl-lang="py" data-lang="py" aria-pressed="${this.lang === 'py'}">PY</button>` : ''}
|
|
2211
2317
|
</div>
|
|
2212
2318
|
`;
|
|
2213
2319
|
}
|
|
@@ -2229,6 +2335,83 @@ int main() {
|
|
|
2229
2335
|
}
|
|
2230
2336
|
}
|
|
2231
2337
|
|
|
2338
|
+
_refreshToolbarAndTabs() {
|
|
2339
|
+
if (!this.container) return;
|
|
2340
|
+
this._refreshLanguageSwitcher();
|
|
2341
|
+
const topbar = this.container.querySelector('.codelab-topbar');
|
|
2342
|
+
if (topbar) {
|
|
2343
|
+
const previewBtn = topbar.querySelector('#cl-preview-app-btn');
|
|
2344
|
+
const hasWeb = this._hasWebContent();
|
|
2345
|
+
if (hasWeb) {
|
|
2346
|
+
if (!previewBtn) {
|
|
2347
|
+
const stopBtn = topbar.querySelector('#cl-stop-btn');
|
|
2348
|
+
if (stopBtn && stopBtn.parentElement) {
|
|
2349
|
+
const globeHtml = `<button type="button" class="codelab-btn codelab-btn--icon" id="cl-preview-app-btn" data-cl-action="preview-app" title="Run & Preview in Browser" aria-label="Run and Preview in Browser">${CL_ICONS.globe}</button>`;
|
|
2350
|
+
stopBtn.insertAdjacentHTML('afterend', globeHtml);
|
|
2351
|
+
}
|
|
2352
|
+
} else {
|
|
2353
|
+
previewBtn.style.display = 'inline-flex';
|
|
2354
|
+
}
|
|
2355
|
+
} else if (previewBtn) {
|
|
2356
|
+
previewBtn.style.display = 'none';
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
this._refreshDrawerTabs();
|
|
2360
|
+
}
|
|
2361
|
+
|
|
2362
|
+
_refreshDrawerTabs() {
|
|
2363
|
+
if (!this.container) return;
|
|
2364
|
+
const drawerTabs = this.container.querySelector('.codelab-drawer__tabs');
|
|
2365
|
+
if (!drawerTabs) return;
|
|
2366
|
+
|
|
2367
|
+
const isGuided = Boolean(this.hasGuidedLab && this.mode === 'guided');
|
|
2368
|
+
const showTests = isGuided || this.testSuiteVisible || this.drawerTab === 'tests';
|
|
2369
|
+
const hasWeb = this._hasWebContent();
|
|
2370
|
+
const problemsCount = this._diagnosticsStore && typeof this._diagnosticsStore.getAll === 'function'
|
|
2371
|
+
? this._diagnosticsStore.getAll().length
|
|
2372
|
+
: 0;
|
|
2373
|
+
|
|
2374
|
+
let probTab = drawerTabs.querySelector('[data-cl-drawertab="problems"]');
|
|
2375
|
+
if (!probTab) {
|
|
2376
|
+
const termTab = drawerTabs.querySelector('[data-cl-drawertab="terminal"]');
|
|
2377
|
+
if (termTab) {
|
|
2378
|
+
termTab.insertAdjacentHTML('afterend', `
|
|
2379
|
+
<button type="button" role="tab" aria-selected="${this.drawerTab === 'problems'}" class="codelab-drawer__tab ${this.drawerTab === 'problems' ? 'active' : ''}" data-cl-drawertab="problems" title="Compiler & Runtime Problems">
|
|
2380
|
+
${CL_ICONS.warning}
|
|
2381
|
+
<span>Problems</span>
|
|
2382
|
+
<span class="codelab-badge ${problemsCount > 0 ? 'codelab-badge--warn' : ''}" id="cl-problems-count" style="margin-left:4px;font-size:10px;padding:1px 5px;border-radius:10px;background:${problemsCount > 0 ? '#cca700' : 'rgba(255,255,255,0.1)'};color:#fff;">${problemsCount}</span>
|
|
2383
|
+
</button>
|
|
2384
|
+
`);
|
|
2385
|
+
}
|
|
2386
|
+
} else {
|
|
2387
|
+
const countSpan = probTab.querySelector('#cl-problems-count');
|
|
2388
|
+
if (countSpan) countSpan.textContent = String(problemsCount);
|
|
2389
|
+
}
|
|
2390
|
+
|
|
2391
|
+
let testTab = drawerTabs.querySelector('[data-cl-drawertab="tests"]');
|
|
2392
|
+
if (testTab) {
|
|
2393
|
+
testTab.style.display = showTests ? 'inline-flex' : 'none';
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
let stdinTab = drawerTabs.querySelector('[data-cl-drawertab="stdin"]');
|
|
2397
|
+
if (!stdinTab) {
|
|
2398
|
+
const afterTab = testTab || drawerTabs.querySelector('[data-cl-drawertab="problems"]') || drawerTabs.querySelector('[data-cl-drawertab="terminal"]');
|
|
2399
|
+
if (afterTab) {
|
|
2400
|
+
afterTab.insertAdjacentHTML('afterend', `
|
|
2401
|
+
<button type="button" role="tab" aria-selected="${this.drawerTab === 'stdin'}" class="codelab-drawer__tab ${this.drawerTab === 'stdin' ? 'active' : ''}" data-cl-drawertab="stdin" title="Standard Input">
|
|
2402
|
+
${CL_ICONS.keyboard}
|
|
2403
|
+
<span>Stdin</span>
|
|
2404
|
+
</button>
|
|
2405
|
+
`);
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
|
|
2409
|
+
let previewTab = drawerTabs.querySelector('[data-cl-drawertab="preview"]');
|
|
2410
|
+
if (previewTab) {
|
|
2411
|
+
previewTab.style.display = hasWeb ? 'inline-flex' : 'none';
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
|
|
2232
2415
|
// ── Render Workbench DOM ───────────────────────────────────────────────
|
|
2233
2416
|
_renderShell() {
|
|
2234
2417
|
if (this.themeOption !== 'auto') {
|
|
@@ -2270,6 +2453,12 @@ int main() {
|
|
|
2270
2453
|
</div>
|
|
2271
2454
|
` : ''}
|
|
2272
2455
|
${this._renderLanguageSwitcherHtml()}
|
|
2456
|
+
<span class="codelab-toolbar__sep" aria-hidden="true"></span>
|
|
2457
|
+
<button type="button" class="codelab-cmd-trigger" data-cl-action="command-palette" title="Open Command Palette (⌘K / ⇧⌘P)">
|
|
2458
|
+
${CL_ICONS.search}
|
|
2459
|
+
<span>Command Palette</span>
|
|
2460
|
+
<kbd style="opacity:0.7">⇧⌘P</kbd>
|
|
2461
|
+
</button>
|
|
2273
2462
|
</div>
|
|
2274
2463
|
|
|
2275
2464
|
<div class="codelab-topbar__right">
|
|
@@ -2277,18 +2466,50 @@ int main() {
|
|
|
2277
2466
|
${CL_ICONS.stop}
|
|
2278
2467
|
<span>Stop</span>
|
|
2279
2468
|
</button>
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2469
|
+
${(this.hasGuidedLab && this.mode === 'guided') ? `
|
|
2470
|
+
<button type="button" class="codelab-btn codelab-btn--run" data-cl-action="run-demo" title="Run demo.js (⌘+Shift+Enter)">
|
|
2471
|
+
${CL_ICONS.play}
|
|
2472
|
+
<span>Run Demo</span>
|
|
2473
|
+
<span class="codelab-btn__kbd">⇧⌘↵</span>
|
|
2474
|
+
</button>
|
|
2475
|
+
<button type="button" class="codelab-btn codelab-btn--test" id="cl-primary-exec-btn" data-cl-action="verify-step" title="Verify Current Step (⌘+Enter)">
|
|
2476
|
+
${CL_ICONS.check}
|
|
2477
|
+
<span>Verify Step</span>
|
|
2478
|
+
<span class="codelab-btn__kbd">⌘↵</span>
|
|
2479
|
+
</button>
|
|
2480
|
+
` : `
|
|
2481
|
+
<div class="codelab-btn-split">
|
|
2482
|
+
<button type="button" class="codelab-btn codelab-btn--run codelab-btn-split__main" id="cl-primary-exec-btn" data-cl-action="run-code" title="Run Code (⌘↵)">
|
|
2483
|
+
${CL_ICONS.play}
|
|
2484
|
+
<span>Run Code</span>
|
|
2485
|
+
<span class="codelab-btn__kbd">⌘↵</span>
|
|
2486
|
+
</button>
|
|
2487
|
+
<button type="button" class="codelab-btn codelab-btn--run codelab-btn-split__trigger" id="cl-split-run-trigger" title="More Execution Options" aria-haspopup="true">
|
|
2488
|
+
${CL_ICONS.chevronDown}
|
|
2489
|
+
</button>
|
|
2490
|
+
<div class="codelab-split-menu" id="cl-split-run-menu">
|
|
2491
|
+
<button type="button" class="codelab-split-menu__item" data-cl-action="run-demo">
|
|
2492
|
+
<span>▶ Run Entry / Demo</span> <kbd style="opacity:0.6">⌘↵</kbd>
|
|
2493
|
+
</button>
|
|
2494
|
+
<button type="button" class="codelab-split-menu__item" data-cl-action="run-active-file">
|
|
2495
|
+
<span>▶ Run Active File (${escapeHtml(this.activeFile || 'active')})</span> <kbd style="opacity:0.6">⇧⌘↵</kbd>
|
|
2496
|
+
</button>
|
|
2497
|
+
${this._findEntryFile('test') ? `
|
|
2498
|
+
<button type="button" class="codelab-split-menu__item" data-cl-action="run-tests">
|
|
2499
|
+
<span>✓ Run Test Suite</span>
|
|
2500
|
+
</button>
|
|
2501
|
+
` : ''}
|
|
2502
|
+
<button type="button" class="codelab-split-menu__item" data-cl-action="open-stdin">
|
|
2503
|
+
<span>⌨ Configure Stdin / Input...</span>
|
|
2504
|
+
</button>
|
|
2505
|
+
</div>
|
|
2506
|
+
</div>
|
|
2507
|
+
`}
|
|
2508
|
+
<button type="button" class="codelab-btn codelab-btn--icon" id="cl-preview-app-btn" data-cl-action="preview-app" title="Run & Preview in Browser" aria-label="Run and Preview in Browser" style="display: ${this._hasWebContent() ? 'inline-flex' : 'none'}">
|
|
2509
|
+
${CL_ICONS.globe}
|
|
2289
2510
|
</button>
|
|
2290
|
-
<button type="button" class="codelab-btn codelab-btn--icon"
|
|
2291
|
-
|
|
2511
|
+
<button type="button" class="codelab-btn codelab-btn--icon" data-cl-action="share-snapshot" title="Share Snapshot Link (#codelab=...)" aria-label="Share Snapshot Link">
|
|
2512
|
+
${CL_ICONS.share}
|
|
2292
2513
|
</button>
|
|
2293
2514
|
<span class="codelab-toolbar__sep" aria-hidden="true"></span>
|
|
2294
2515
|
${this.hasGuidedLab ? `
|
|
@@ -2386,22 +2607,33 @@ int main() {
|
|
|
2386
2607
|
<div class="codelab-drawer codelab-bottom" id="cl-drawer">
|
|
2387
2608
|
<div class="codelab-drawer__bar">
|
|
2388
2609
|
<div class="codelab-drawer__tabs" role="tablist" aria-label="Execution Output Panels">
|
|
2610
|
+
<button type="button" role="tab" aria-selected="${this.drawerTab === 'terminal'}" class="codelab-drawer__tab ${this.drawerTab === 'terminal' ? 'active' : ''}" data-cl-drawertab="terminal">
|
|
2611
|
+
${CL_ICONS.terminal}
|
|
2612
|
+
<span>Terminal & REPL</span>
|
|
2613
|
+
</button>
|
|
2614
|
+
<button type="button" role="tab" aria-selected="${this.drawerTab === 'problems'}" class="codelab-drawer__tab ${this.drawerTab === 'problems' ? 'active' : ''}" data-cl-drawertab="problems" title="Compiler & Runtime Problems">
|
|
2615
|
+
${CL_ICONS.warning}
|
|
2616
|
+
<span>Problems</span>
|
|
2617
|
+
<span class="codelab-badge" id="cl-problems-count" style="margin-left:4px;font-size:10px;padding:1px 5px;border-radius:10px;background:rgba(255,255,255,0.1);color:#fff;">${this._diagnosticsStore ? this._diagnosticsStore.getAll().length : 0}</span>
|
|
2618
|
+
</button>
|
|
2619
|
+
${((this.hasGuidedLab && this.mode === 'guided') || this.testSuiteVisible || this.drawerTab === 'tests') ? `
|
|
2389
2620
|
<button type="button" role="tab" aria-selected="${this.drawerTab === 'tests'}" class="codelab-drawer__tab ${this.drawerTab === 'tests' ? 'active' : ''}" data-cl-drawertab="tests">
|
|
2390
2621
|
${CL_ICONS.check}
|
|
2391
2622
|
<span>Test Suite</span>
|
|
2392
2623
|
<span class="codelab-drawer__pill" id="cl-test-pill">Ready</span>
|
|
2393
2624
|
</button>
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2625
|
+
` : ''}
|
|
2626
|
+
<button type="button" role="tab" aria-selected="${this.drawerTab === 'stdin'}" class="codelab-drawer__tab ${this.drawerTab === 'stdin' ? 'active' : ''}" data-cl-drawertab="stdin" title="Standard Input">
|
|
2627
|
+
${CL_ICONS.keyboard}
|
|
2628
|
+
<span>Stdin</span>
|
|
2397
2629
|
</button>
|
|
2398
2630
|
<button type="button" role="tab" aria-selected="${this.drawerTab === 'ports'}" class="codelab-drawer__tab ${this.drawerTab === 'ports' ? 'active' : ''}" data-cl-drawertab="ports">
|
|
2399
2631
|
${CL_ICONS.radio}
|
|
2400
2632
|
<span>Ports</span>
|
|
2401
2633
|
<span class="codelab-drawer__pill" id="cl-ports-pill">${this.portTable && typeof this.portTable.listServers === 'function' ? this.portTable.listServers().length : 0} open</span>
|
|
2402
2634
|
</button>
|
|
2403
|
-
<button type="button" role="tab" aria-selected="${this.drawerTab === 'preview'}" class="codelab-drawer__tab ${this.drawerTab === 'preview' ? 'active' : ''}" data-cl-drawertab="preview" title="In-browser Web Preview">
|
|
2404
|
-
${CL_ICONS.
|
|
2635
|
+
<button type="button" role="tab" aria-selected="${this.drawerTab === 'preview'}" class="codelab-drawer__tab ${this.drawerTab === 'preview' ? 'active' : ''}" data-cl-drawertab="preview" title="In-browser Web Preview" style="display: ${this._hasWebContent() ? 'inline-flex' : 'none'}">
|
|
2636
|
+
${CL_ICONS.globe}
|
|
2405
2637
|
<span>Web Preview</span>
|
|
2406
2638
|
</button>
|
|
2407
2639
|
<button type="button" role="tab" aria-selected="${this.drawerTab === 'network'}" class="codelab-drawer__tab ${this.drawerTab === 'network' ? 'active' : ''}" data-cl-drawertab="network">
|
|
@@ -2415,6 +2647,7 @@ int main() {
|
|
|
2415
2647
|
<span class="codelab-drawer__pill" id="cl-vfs-pill">0 files</span>
|
|
2416
2648
|
</button>
|
|
2417
2649
|
</div>
|
|
2650
|
+
<div class="codelab-hud-pill" id="cl-telemetry-hud" style="display:none;" title="Last Execution Telemetry"></div>
|
|
2418
2651
|
<div style="display:flex;align-items:center;gap:6px;">
|
|
2419
2652
|
<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" style="padding:2px 8px;font-size:11px;font-family:var(--cl-font-mono);">Ctrl+C</button>
|
|
2420
2653
|
<button type="button" class="codelab-btn codelab-btn--icon" data-cl-action="clear-terminal" title="Clear Output" style="padding:2px 6px;font-size:11px;">Clear</button>
|
|
@@ -2443,7 +2676,7 @@ int main() {
|
|
|
2443
2676
|
<span class="codelab-statusbar__sep">·</span>
|
|
2444
2677
|
<span class="codelab-statusbar__item">UTF-8</span>
|
|
2445
2678
|
<span class="codelab-statusbar__sep">·</span>
|
|
2446
|
-
<span class="codelab-statusbar__item" id="cl-status-lang">${this.lang === 'cpp' ? 'C++20 (Clang/WASI)' : this.lang === 'ts' ? 'TypeScript 5.x' : 'JavaScript (CJS/ESM)'}</span>
|
|
2679
|
+
<span class="codelab-statusbar__item" id="cl-status-lang">${this.lang === 'cpp' ? 'C++20 (Clang/WASI)' : this.lang === 'py' ? 'Python 3.12 (CPython WASI)' : this.lang === 'ts' ? 'TypeScript 5.x' : 'JavaScript (CJS/ESM)'}</span>
|
|
2447
2680
|
</div>
|
|
2448
2681
|
</footer>
|
|
2449
2682
|
|
|
@@ -3452,6 +3685,15 @@ int main() {
|
|
|
3452
3685
|
});
|
|
3453
3686
|
|
|
3454
3687
|
// Update pills
|
|
3688
|
+
const problemsCountEl = this.container.querySelector('#cl-problems-count');
|
|
3689
|
+
if (problemsCountEl) {
|
|
3690
|
+
const count = this._diagnosticsStore && typeof this._diagnosticsStore.getAll === 'function'
|
|
3691
|
+
? this._diagnosticsStore.getAll().length
|
|
3692
|
+
: 0;
|
|
3693
|
+
problemsCountEl.textContent = String(count);
|
|
3694
|
+
}
|
|
3695
|
+
this._updateTelemetryHud();
|
|
3696
|
+
|
|
3455
3697
|
if (testPill) {
|
|
3456
3698
|
if (!this.lastTestResults.length) {
|
|
3457
3699
|
testPill.textContent = 'Ready';
|
|
@@ -3479,6 +3721,61 @@ int main() {
|
|
|
3479
3721
|
vfsPill.textContent = httpCount > 0 ? `${diskCount} files · ${httpCount} reqs` : `${diskCount} files`;
|
|
3480
3722
|
}
|
|
3481
3723
|
|
|
3724
|
+
if (this.drawerTab === 'problems') {
|
|
3725
|
+
const store = this._diagnosticsStore;
|
|
3726
|
+
const problems = store && typeof store.getAll === 'function' ? store.getAll() : [];
|
|
3727
|
+
if (!problems.length) {
|
|
3728
|
+
bodyEl.innerHTML = `
|
|
3729
|
+
<div style="color:var(--cl-fg-muted);padding:16px;text-align:center;">
|
|
3730
|
+
${CL_ICONS.check} No problems detected in workspace.
|
|
3731
|
+
</div>
|
|
3732
|
+
`;
|
|
3733
|
+
return;
|
|
3734
|
+
}
|
|
3735
|
+
bodyEl.innerHTML = `
|
|
3736
|
+
<div class="codelab-problems-list">
|
|
3737
|
+
${problems.map(p => {
|
|
3738
|
+
const icon = p.severity === 'error' ? '✖' : (p.severity === 'warning' ? '⚠' : 'ℹ');
|
|
3739
|
+
const cls = p.severity === 'error' ? 'codelab-problem-item--error' : (p.severity === 'warning' ? 'codelab-problem-item--warning' : 'codelab-problem-item--info');
|
|
3740
|
+
return `
|
|
3741
|
+
<div class="codelab-problem-item ${cls}" data-cl-problem-file="${escapeHtml(p.file || '')}" data-cl-problem-line="${p.line || 1}" data-cl-problem-col="${p.col || 1}" role="button" tabindex="0">
|
|
3742
|
+
<span class="codelab-problem-item__icon">${icon}</span>
|
|
3743
|
+
<span class="codelab-problem-item__msg">${escapeHtml(p.message || '')}</span>
|
|
3744
|
+
<span class="codelab-problem-item__loc">${escapeHtml(p.file || '')}:${p.line || 1}:${p.col || 1}</span>
|
|
3745
|
+
</div>
|
|
3746
|
+
`;
|
|
3747
|
+
}).join('')}
|
|
3748
|
+
</div>
|
|
3749
|
+
`;
|
|
3750
|
+
return;
|
|
3751
|
+
}
|
|
3752
|
+
|
|
3753
|
+
if (this.drawerTab === 'stdin') {
|
|
3754
|
+
bodyEl.innerHTML = `
|
|
3755
|
+
<div class="codelab-stdin-panel" style="padding:10px;height:100%;display:flex;flex-direction:column;box-sizing:border-box;">
|
|
3756
|
+
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:6px;font-size:12px;color:var(--cl-fg-muted);">
|
|
3757
|
+
<span>Standard Input (std::cin / sys.stdin / process.stdin)</span>
|
|
3758
|
+
<button type="button" class="codelab-btn codelab-btn--sm" id="cl-stdin-clear-btn" style="padding:2px 8px;font-size:11px;">Clear</button>
|
|
3759
|
+
</div>
|
|
3760
|
+
<textarea id="cl-stdin-textarea" class="codelab-stdin-textarea" style="flex:1;width:100%;background:var(--cl-bg-input, #1e1e1e);color:var(--cl-fg, #d4d4d4);border:1px solid var(--cl-border, #333);border-radius:4px;padding:8px;font-family:var(--cl-font-mono, monospace);font-size:12px;resize:none;outline:none;box-sizing:border-box;" placeholder="Enter or paste custom stdin here (used by std::cin, sys.stdin, fs.readFileSync(0))...">${escapeHtml(this.customStdin || '')}</textarea>
|
|
3761
|
+
</div>
|
|
3762
|
+
`;
|
|
3763
|
+
const ta = bodyEl.querySelector('#cl-stdin-textarea');
|
|
3764
|
+
if (ta) {
|
|
3765
|
+
ta.addEventListener('input', () => {
|
|
3766
|
+
this.customStdin = ta.value;
|
|
3767
|
+
});
|
|
3768
|
+
}
|
|
3769
|
+
const clearBtn = bodyEl.querySelector('#cl-stdin-clear-btn');
|
|
3770
|
+
if (clearBtn && ta) {
|
|
3771
|
+
clearBtn.addEventListener('click', () => {
|
|
3772
|
+
this.customStdin = '';
|
|
3773
|
+
ta.value = '';
|
|
3774
|
+
});
|
|
3775
|
+
}
|
|
3776
|
+
return;
|
|
3777
|
+
}
|
|
3778
|
+
|
|
3482
3779
|
if (this.drawerTab === 'tests') {
|
|
3483
3780
|
if (!this.lastTestResults.length) {
|
|
3484
3781
|
bodyEl.innerHTML = `
|
|
@@ -3837,6 +4134,33 @@ int main() {
|
|
|
3837
4134
|
}
|
|
3838
4135
|
}
|
|
3839
4136
|
|
|
4137
|
+
_updateTelemetryHud() {
|
|
4138
|
+
const hud = this.container ? this.container.querySelector('#cl-telemetry-hud') : null;
|
|
4139
|
+
if (!hud) return;
|
|
4140
|
+
if (this.lastDurationMs === null && this.lastPeakMemoryBytes === null) {
|
|
4141
|
+
hud.style.display = 'none';
|
|
4142
|
+
return;
|
|
4143
|
+
}
|
|
4144
|
+
hud.style.display = 'inline-flex';
|
|
4145
|
+
let timeStr = '';
|
|
4146
|
+
if (this.lastDurationMs !== null) {
|
|
4147
|
+
timeStr = this.lastDurationMs < 1000
|
|
4148
|
+
? `${this.lastDurationMs.toFixed(1)} ms`
|
|
4149
|
+
: `${(this.lastDurationMs / 1000).toFixed(2)} s`;
|
|
4150
|
+
}
|
|
4151
|
+
let memStr = '';
|
|
4152
|
+
if (this.lastPeakMemoryBytes !== null && this.lastPeakMemoryBytes > 0) {
|
|
4153
|
+
const mb = this.lastPeakMemoryBytes / (1024 * 1024);
|
|
4154
|
+
const suffix = this.lang === 'cpp' ? 'Wasm' : this.lang === 'py' ? 'Heap' : 'Mem';
|
|
4155
|
+
memStr = `${mb < 0.1 ? (this.lastPeakMemoryBytes / 1024).toFixed(1) + ' KB' : mb.toFixed(1) + ' MB'} ${suffix}`;
|
|
4156
|
+
}
|
|
4157
|
+
hud.innerHTML = `
|
|
4158
|
+
${timeStr ? `<span class="codelab-hud-pill__metric">${CL_ICONS.clock} <span>${timeStr}</span></span>` : ''}
|
|
4159
|
+
${timeStr && memStr ? `<span style="opacity:0.4;">·</span>` : ''}
|
|
4160
|
+
${memStr ? `<span class="codelab-hud-pill__metric">${CL_ICONS.memory} <span>${memStr}</span></span>` : ''}
|
|
4161
|
+
`;
|
|
4162
|
+
}
|
|
4163
|
+
|
|
3840
4164
|
_handleInterrupt() {
|
|
3841
4165
|
const isCommandRunning = Boolean(this.isRunning || this._activeCommandAbortController);
|
|
3842
4166
|
const cwdShort = (this.cwd || '/workspace').replace(/^\/workspace\/?/, '') || '~';
|
|
@@ -5932,13 +6256,19 @@ int main() {
|
|
|
5932
6256
|
let model = typeof this.monaco.editor.getModel === 'function' ? this.monaco.editor.getModel(uri) : null;
|
|
5933
6257
|
const lang = /\.(cpp|cc|cxx|hpp|h)$/i.test(filename)
|
|
5934
6258
|
? 'cpp'
|
|
5935
|
-
:
|
|
5936
|
-
? '
|
|
5937
|
-
: filename.endsWith('.
|
|
5938
|
-
? '
|
|
5939
|
-
: filename.endsWith('.
|
|
5940
|
-
? '
|
|
5941
|
-
: '
|
|
6259
|
+
: /\.py$/i.test(filename)
|
|
6260
|
+
? 'python'
|
|
6261
|
+
: filename.endsWith('.ts')
|
|
6262
|
+
? 'typescript'
|
|
6263
|
+
: filename.endsWith('.json')
|
|
6264
|
+
? 'json'
|
|
6265
|
+
: filename.endsWith('.html')
|
|
6266
|
+
? 'html'
|
|
6267
|
+
: filename.endsWith('.css')
|
|
6268
|
+
? 'css'
|
|
6269
|
+
: filename.endsWith('.md')
|
|
6270
|
+
? 'markdown'
|
|
6271
|
+
: 'javascript';
|
|
5942
6272
|
if (!model) {
|
|
5943
6273
|
model = this.monaco.editor.createModel(this.files[filename] || '', lang, uri);
|
|
5944
6274
|
if (model && typeof model.onDidChangeContent === 'function') {
|
|
@@ -5947,6 +6277,12 @@ int main() {
|
|
|
5947
6277
|
this.files[filename] = val;
|
|
5948
6278
|
this._saveState();
|
|
5949
6279
|
this._notifyCodeChange(filename, val);
|
|
6280
|
+
if (this.lang === 'py' && typeof this._pyLintHandler === 'function') {
|
|
6281
|
+
this._pyLintHandler(filename, val);
|
|
6282
|
+
}
|
|
6283
|
+
if (this.lang === 'cpp' && typeof this._cppLintHandler === 'function') {
|
|
6284
|
+
this._cppLintHandler(filename, val);
|
|
6285
|
+
}
|
|
5950
6286
|
});
|
|
5951
6287
|
}
|
|
5952
6288
|
} else if (model.getValue() !== (this.files[filename] || '')) {
|
|
@@ -6049,6 +6385,9 @@ int main() {
|
|
|
6049
6385
|
|
|
6050
6386
|
// ── Event Delegation & Interactive Splitters ───────────────────────────
|
|
6051
6387
|
_bindEvents() {
|
|
6388
|
+
if (this._eventsBound) return;
|
|
6389
|
+
this._eventsBound = true;
|
|
6390
|
+
|
|
6052
6391
|
this._bindSplitters();
|
|
6053
6392
|
|
|
6054
6393
|
this._escHandler = e => {
|
|
@@ -6117,6 +6456,16 @@ int main() {
|
|
|
6117
6456
|
this.openCommandPalette('commands');
|
|
6118
6457
|
return;
|
|
6119
6458
|
}
|
|
6459
|
+
if ((e.metaKey || e.ctrlKey) && keyLower === 'k') {
|
|
6460
|
+
e.preventDefault();
|
|
6461
|
+
this.openCommandPalette('commands');
|
|
6462
|
+
return;
|
|
6463
|
+
}
|
|
6464
|
+
if (e.altKey && e.shiftKey && keyLower === 'f') {
|
|
6465
|
+
e.preventDefault();
|
|
6466
|
+
this.formatActiveDocument();
|
|
6467
|
+
return;
|
|
6468
|
+
}
|
|
6120
6469
|
if ((e.metaKey || e.ctrlKey) && !e.shiftKey && keyLower === 'p') {
|
|
6121
6470
|
e.preventDefault();
|
|
6122
6471
|
this.openCommandPalette('files');
|
|
@@ -6133,11 +6482,15 @@ int main() {
|
|
|
6133
6482
|
if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') {
|
|
6134
6483
|
e.preventDefault();
|
|
6135
6484
|
if (e.shiftKey) {
|
|
6136
|
-
this.
|
|
6485
|
+
if (this.mode === 'guided') {
|
|
6486
|
+
this.runDemo();
|
|
6487
|
+
} else {
|
|
6488
|
+
this.runActiveFile();
|
|
6489
|
+
}
|
|
6137
6490
|
} else if (this.mode === 'guided') {
|
|
6138
6491
|
this.verifyCurrentStep();
|
|
6139
6492
|
} else {
|
|
6140
|
-
this.
|
|
6493
|
+
this.runCode();
|
|
6141
6494
|
}
|
|
6142
6495
|
}
|
|
6143
6496
|
});
|
|
@@ -6414,6 +6767,36 @@ int main() {
|
|
|
6414
6767
|
return;
|
|
6415
6768
|
}
|
|
6416
6769
|
|
|
6770
|
+
const splitTrigger = e.target.closest('#cl-split-run-trigger');
|
|
6771
|
+
if (splitTrigger) {
|
|
6772
|
+
e.stopPropagation();
|
|
6773
|
+
const menu = this.container.querySelector('#cl-split-run-menu');
|
|
6774
|
+
if (menu) menu.classList.toggle('active');
|
|
6775
|
+
return;
|
|
6776
|
+
}
|
|
6777
|
+
|
|
6778
|
+
const splitMenu = this.container.querySelector('#cl-split-run-menu');
|
|
6779
|
+
if (splitMenu && splitMenu.classList.contains('active') && !e.target.closest('.codelab-btn-split')) {
|
|
6780
|
+
splitMenu.classList.remove('active');
|
|
6781
|
+
}
|
|
6782
|
+
|
|
6783
|
+
const problemItem = e.target.closest('[data-cl-problem-file]');
|
|
6784
|
+
if (problemItem) {
|
|
6785
|
+
e.stopPropagation();
|
|
6786
|
+
const pFile = problemItem.dataset.clProblemFile;
|
|
6787
|
+
const pLine = Number(problemItem.dataset.clProblemLine || 1);
|
|
6788
|
+
const pCol = Number(problemItem.dataset.clProblemCol || 1);
|
|
6789
|
+
if (pFile) {
|
|
6790
|
+
this.openFile(pFile);
|
|
6791
|
+
if (this.editor && typeof this.editor.revealLineInCenter === 'function') {
|
|
6792
|
+
this.editor.revealLineInCenter(pLine);
|
|
6793
|
+
this.editor.setPosition({ lineNumber: pLine, column: pCol });
|
|
6794
|
+
this.editor.focus();
|
|
6795
|
+
}
|
|
6796
|
+
}
|
|
6797
|
+
return;
|
|
6798
|
+
}
|
|
6799
|
+
|
|
6417
6800
|
const drawerTabBtn = e.target.closest('[data-cl-drawertab]');
|
|
6418
6801
|
if (drawerTabBtn) {
|
|
6419
6802
|
this.switchDrawerTab(drawerTabBtn.dataset.clDrawertab);
|
|
@@ -6422,8 +6805,16 @@ int main() {
|
|
|
6422
6805
|
|
|
6423
6806
|
const actionBtn = e.target.closest('[data-cl-action], [data-action]');
|
|
6424
6807
|
if (actionBtn) {
|
|
6808
|
+
if (splitMenu && splitMenu.classList.contains('active')) {
|
|
6809
|
+
splitMenu.classList.remove('active');
|
|
6810
|
+
}
|
|
6425
6811
|
const action = actionBtn.dataset.clAction || actionBtn.dataset.action;
|
|
6426
|
-
if (action === 'run-
|
|
6812
|
+
if (action === 'run-code') this.runCode();
|
|
6813
|
+
else if (action === 'run-entry') this.runEntry();
|
|
6814
|
+
else if (action === 'run-active-file') this.runActiveFile();
|
|
6815
|
+
else if (action === 'open-stdin') this.switchDrawerTab('stdin');
|
|
6816
|
+
else if (action === 'share-snapshot') this.shareSnapshot();
|
|
6817
|
+
else if (action === 'run-demo') this.runDemo();
|
|
6427
6818
|
else if (action === 'run-tests') this.runTests();
|
|
6428
6819
|
else if (action === 'stop-run') this.stopExecution();
|
|
6429
6820
|
else if (action === 'interrupt') this._handleInterrupt();
|
|
@@ -6711,9 +7102,15 @@ int main() {
|
|
|
6711
7102
|
// ── VS Code Command Palette & Quick Open ────────────────────────────────
|
|
6712
7103
|
_getPaletteCommands() {
|
|
6713
7104
|
return [
|
|
7105
|
+
{ id: 'run-code', label: 'CodeLab: Run Code (Entry or Active File)', shortcut: '⌘↵', action: () => this.runCode() },
|
|
7106
|
+
{ id: 'run-active', label: 'CodeLab: Run Active File', shortcut: '⇧⌘↵', action: () => this.runActiveFile() },
|
|
6714
7107
|
{ id: 'run-demo', label: 'CodeLab: Run Demo Script', shortcut: '⇧⌘↵', action: () => this.runDemo() },
|
|
6715
7108
|
{ id: 'run-tests', label: 'CodeLab: Run Unit Tests', shortcut: '⌘↵', action: () => this.runTests() },
|
|
6716
7109
|
{ id: 'verify-step', label: 'CodeLab: Verify Current Guided Step', shortcut: '⌘↵', action: () => this.verifyCurrentStep() },
|
|
7110
|
+
{ id: 'format-document', label: 'Editor: Format Document', shortcut: '⇧⌥F', action: () => this.formatActiveDocument() },
|
|
7111
|
+
{ id: 'share-snapshot', label: 'CodeLab: Share Snapshot Link (#codelab=...)', action: () => this.shareSnapshot() },
|
|
7112
|
+
{ id: 'open-stdin', label: 'View: Open Stdin / Custom Input Panel', action: () => this.switchDrawerTab('stdin') },
|
|
7113
|
+
{ id: 'view-problems-tab', label: 'View: Focus Problems Drawer Tab', action: () => this.switchDrawerTab('problems') },
|
|
6717
7114
|
{ id: 'compare-solution', label: 'CodeLab: Compare Active File with Reference Solution (Diff)', action: () => this.showDiffModal(this.activeFile || this._pickDefaultFile(), 'solution') },
|
|
6718
7115
|
{ id: 'compare-starter', label: 'CodeLab: Compare Active File with Starter Template (Diff)', action: () => this.showDiffModal(this.activeFile || this._pickDefaultFile(), 'starter') },
|
|
6719
7116
|
{ id: 'apply-solution', label: 'CodeLab: Apply Reference Solution to Active File', action: () => this.applyReferenceSolution() },
|
|
@@ -6724,9 +7121,10 @@ int main() {
|
|
|
6724
7121
|
{ id: 'export-workspace', label: 'Workspace: Export Workspace as JSON', action: () => this.exportWorkspace({ download: true }) },
|
|
6725
7122
|
{ id: 'export-workspace-zip', label: 'Workspace: Export Project as ZIP Archive', action: () => this.exportProjectZip({ download: true }) },
|
|
6726
7123
|
{ id: 'reset-workspace', label: 'Workspace: Reset Workspace to Clean State', action: () => this.resetLab() },
|
|
6727
|
-
{ id: 'switch-lang', label: 'Language: Switch JavaScript / TypeScript / C++', action: () => {
|
|
7124
|
+
{ id: 'switch-lang', label: 'Language: Switch JavaScript / TypeScript / C++ / Python', action: () => {
|
|
6728
7125
|
const order = ['js', 'ts'];
|
|
6729
7126
|
if (this.enabledLanguages && this.enabledLanguages.has('cpp')) order.push('cpp');
|
|
7127
|
+
if (this.enabledLanguages && this.enabledLanguages.has('py')) order.push('py');
|
|
6730
7128
|
const next = order[(order.indexOf(this.lang) + 1) % order.length] || 'js';
|
|
6731
7129
|
this.setLanguage(next);
|
|
6732
7130
|
} },
|
|
@@ -6922,6 +7320,31 @@ int main() {
|
|
|
6922
7320
|
}
|
|
6923
7321
|
|
|
6924
7322
|
showDiffModal(targetFile = null, compareTarget = 'solution') {
|
|
7323
|
+
const file = targetFile || this.activeFile || this._pickDefaultFile();
|
|
7324
|
+
if (!this._diffManager) {
|
|
7325
|
+
let DiffManagerCls = (root && root.CodeLabWorkbenchComponents && root.CodeLabWorkbenchComponents.CodeLabDiffEditorManager) ||
|
|
7326
|
+
(typeof globalThis !== 'undefined' && globalThis.CodeLabWorkbenchComponents && globalThis.CodeLabWorkbenchComponents.CodeLabDiffEditorManager) ||
|
|
7327
|
+
null;
|
|
7328
|
+
if (!DiffManagerCls && typeof require === 'function') {
|
|
7329
|
+
try {
|
|
7330
|
+
const mod = require('./workbench/diff-editor');
|
|
7331
|
+
DiffManagerCls = mod.CodeLabDiffEditorManager;
|
|
7332
|
+
} catch (err) {
|
|
7333
|
+
void err;
|
|
7334
|
+
}
|
|
7335
|
+
}
|
|
7336
|
+
if (DiffManagerCls) {
|
|
7337
|
+
this._diffManager = new DiffManagerCls(this);
|
|
7338
|
+
}
|
|
7339
|
+
}
|
|
7340
|
+
if (this._diffManager && typeof window !== 'undefined' && window.monaco && window.monaco.editor && typeof window.monaco.editor.createDiffEditor === 'function') {
|
|
7341
|
+
const ok = this._diffManager.openInlineDiff(file, compareTarget);
|
|
7342
|
+
if (ok) return;
|
|
7343
|
+
}
|
|
7344
|
+
this.showDiffModalFallback(file, compareTarget);
|
|
7345
|
+
}
|
|
7346
|
+
|
|
7347
|
+
showDiffModalFallback(targetFile = null, compareTarget = 'solution') {
|
|
6925
7348
|
const slot = this.container.querySelector('#cl-modal-slot');
|
|
6926
7349
|
if (!slot) return;
|
|
6927
7350
|
|
|
@@ -7307,7 +7730,7 @@ int main() {
|
|
|
7307
7730
|
}
|
|
7308
7731
|
|
|
7309
7732
|
setLanguage(newLang) {
|
|
7310
|
-
if (newLang !== 'js' && newLang !== 'ts' && newLang !== 'cpp') return;
|
|
7733
|
+
if (newLang !== 'js' && newLang !== 'ts' && newLang !== 'cpp' && newLang !== 'py') return;
|
|
7311
7734
|
if (this.lang === newLang) return;
|
|
7312
7735
|
this.lang = newLang;
|
|
7313
7736
|
if (this.enabledLanguages instanceof Set) {
|
|
@@ -7318,7 +7741,11 @@ int main() {
|
|
|
7318
7741
|
this.activeFile = this._pickDefaultFile();
|
|
7319
7742
|
this._saveState();
|
|
7320
7743
|
|
|
7321
|
-
this.
|
|
7744
|
+
if (typeof this._refreshToolbarAndTabs === 'function') {
|
|
7745
|
+
this._refreshToolbarAndTabs();
|
|
7746
|
+
} else {
|
|
7747
|
+
this._refreshLanguageSwitcher();
|
|
7748
|
+
}
|
|
7322
7749
|
this.container.querySelectorAll('[data-cl-lang]').forEach(btn => {
|
|
7323
7750
|
const isActive = btn.dataset.clLang === this.lang;
|
|
7324
7751
|
btn.classList.toggle('active', isActive);
|
|
@@ -7328,6 +7755,7 @@ int main() {
|
|
|
7328
7755
|
this._syncAllModels();
|
|
7329
7756
|
this._syncActiveFileToView();
|
|
7330
7757
|
this._renderGuidePane();
|
|
7758
|
+
this._updateStatusBar();
|
|
7331
7759
|
}
|
|
7332
7760
|
|
|
7333
7761
|
switchLang(newLang) {
|
|
@@ -7357,7 +7785,7 @@ int main() {
|
|
|
7357
7785
|
if (mode === 'guided' || mode === 'sandbox') {
|
|
7358
7786
|
this.setMode(mode);
|
|
7359
7787
|
}
|
|
7360
|
-
if (lang === 'js' || lang === 'ts' || lang === 'cpp') {
|
|
7788
|
+
if (lang === 'js' || lang === 'ts' || lang === 'cpp' || lang === 'py') {
|
|
7361
7789
|
this.setLanguage(lang);
|
|
7362
7790
|
}
|
|
7363
7791
|
if (typeof stepIndex === 'number' && !Number.isNaN(stepIndex)) {
|
|
@@ -7612,6 +8040,7 @@ int main() {
|
|
|
7612
8040
|
const payload = {
|
|
7613
8041
|
...execOptions,
|
|
7614
8042
|
instanceId: this.instanceId,
|
|
8043
|
+
stdin: execOptions.stdin !== undefined ? execOptions.stdin : (this.customStdin || ''),
|
|
7615
8044
|
cppCompiler: execOptions.cppCompiler || this.cppCompiler,
|
|
7616
8045
|
onStdout: execOptions.onStdout || ((chunk) => this._appendTerminalStream('stdout', chunk)),
|
|
7617
8046
|
onStderr: execOptions.onStderr || ((chunk) => this._appendTerminalStream('stderr', chunk)),
|
|
@@ -7619,7 +8048,8 @@ int main() {
|
|
|
7619
8048
|
};
|
|
7620
8049
|
try {
|
|
7621
8050
|
const isCppEntry = Boolean(payload && typeof payload.entry === 'string' && /\.(cpp|cc|cxx|wasm)$/i.test(payload.entry));
|
|
7622
|
-
|
|
8051
|
+
const isPyEntry = Boolean(payload && typeof payload.entry === 'string' && /\.py$/i.test(payload.entry));
|
|
8052
|
+
if (!isCppEntry && !isPyEntry && typeof root.CodeLabRuntime?.preloadNpmPackages === 'function' && payload && payload.files) {
|
|
7623
8053
|
const rawDetected = this._detectPackages();
|
|
7624
8054
|
const detectedList = Array.isArray(rawDetected)
|
|
7625
8055
|
? rawDetected
|
|
@@ -7636,9 +8066,22 @@ int main() {
|
|
|
7636
8066
|
payload.packages = Object.assign({}, preloaded, payload.packages || {});
|
|
7637
8067
|
}
|
|
7638
8068
|
}
|
|
7639
|
-
this._setRuntimeStatus('running', isCppEntry ? `Compiling & Running ${payload.entry}...` : `Running ${payload.entry || payload.mode || 'script'}...`);
|
|
8069
|
+
this._setRuntimeStatus('running', isCppEntry ? `Compiling & Running ${payload.entry}...` : isPyEntry ? `Running Python 3.12: ${payload.entry}...` : `Running ${payload.entry || payload.mode || 'script'}...`);
|
|
7640
8070
|
let res;
|
|
7641
|
-
|
|
8071
|
+
const pyRunner = this.pythonCompiler || (typeof globalThis !== 'undefined' && globalThis.__codelabPythonCompiler) || (typeof root !== 'undefined' && root.__codelabPythonCompiler);
|
|
8072
|
+
if ((isPyEntry || this.lang === 'py') && pyRunner) {
|
|
8073
|
+
res = await pyRunner(payload);
|
|
8074
|
+
} else if (isPyEntry || this.lang === 'py') {
|
|
8075
|
+
this._setRuntimeStatus('error', 'Python 3.12 extension not loaded');
|
|
8076
|
+
return {
|
|
8077
|
+
ok: false,
|
|
8078
|
+
exitCode: 1,
|
|
8079
|
+
stdout: '',
|
|
8080
|
+
stderr: 'Python WebAssembly toolchain is not registered. Enable pythonExtension from "@innovatorved/code-lab/extensions/python" to run Python files.\n',
|
|
8081
|
+
durationMs: 0,
|
|
8082
|
+
peakMemoryBytes: 0
|
|
8083
|
+
};
|
|
8084
|
+
} else if (isCppEntry && typeof root.CodeLabRuntime?.executeInVirtualRuntime === 'function') {
|
|
7642
8085
|
res = await root.CodeLabRuntime.executeInVirtualRuntime(payload);
|
|
7643
8086
|
} else if (typeof root.CodeLabRuntime?.executeInWorker === 'function') {
|
|
7644
8087
|
res = await root.CodeLabRuntime.executeInWorker(payload);
|
|
@@ -7649,6 +8092,9 @@ int main() {
|
|
|
7649
8092
|
}
|
|
7650
8093
|
const elapsed = Math.round((typeof performance !== 'undefined' ? performance.now() : Date.now()) - t0);
|
|
7651
8094
|
this.lastRunDurationMs = res && typeof res.durationMs === 'number' ? res.durationMs : elapsed;
|
|
8095
|
+
this.lastDurationMs = this.lastRunDurationMs;
|
|
8096
|
+
this.lastPeakMemoryBytes = res && typeof res.peakMemoryBytes === 'number' ? res.peakMemoryBytes : null;
|
|
8097
|
+
this._updateTelemetryHud();
|
|
7652
8098
|
this._setRuntimeStatus('idle', 'Ready · Node v22 VFS');
|
|
7653
8099
|
return res;
|
|
7654
8100
|
} catch (err) {
|
|
@@ -7661,14 +8107,36 @@ int main() {
|
|
|
7661
8107
|
}
|
|
7662
8108
|
}
|
|
7663
8109
|
|
|
7664
|
-
async
|
|
7665
|
-
|
|
7666
|
-
const entry = this._findEntryFile('demo');
|
|
8110
|
+
async runCode() {
|
|
8111
|
+
const entry = this._findEntryFile('demo') || this.activeFile || this._pickDefaultFile();
|
|
7667
8112
|
if (!entry) {
|
|
7668
|
-
|
|
7669
|
-
|
|
7670
|
-
|
|
7671
|
-
|
|
8113
|
+
this.terminalLogs.push({ type: 'stderr', text: 'No entry file or active file to run.' });
|
|
8114
|
+
this.drawerTab = 'terminal';
|
|
8115
|
+
this._renderDrawerBody();
|
|
8116
|
+
return;
|
|
8117
|
+
}
|
|
8118
|
+
return this._executeEntryFile(entry);
|
|
8119
|
+
}
|
|
8120
|
+
|
|
8121
|
+
async runEntry() {
|
|
8122
|
+
return this.runCode();
|
|
8123
|
+
}
|
|
8124
|
+
|
|
8125
|
+
async runActiveFile() {
|
|
8126
|
+
const file = this.activeFile || this._pickDefaultFile();
|
|
8127
|
+
if (!file) {
|
|
8128
|
+
this.terminalLogs.push({ type: 'stderr', text: 'No active file to run.' });
|
|
8129
|
+
this.drawerTab = 'terminal';
|
|
8130
|
+
this._renderDrawerBody();
|
|
8131
|
+
return;
|
|
8132
|
+
}
|
|
8133
|
+
return this._executeEntryFile(file);
|
|
8134
|
+
}
|
|
8135
|
+
|
|
8136
|
+
async _executeEntryFile(entry) {
|
|
8137
|
+
if (this.isRunning) return;
|
|
8138
|
+
if (!entry || this.files[entry] === undefined) {
|
|
8139
|
+
this.terminalLogs.push({ type: 'stderr', text: `File not found: ${entry || 'entry'}` });
|
|
7672
8140
|
this.drawerTab = 'terminal';
|
|
7673
8141
|
this._renderDrawerBody();
|
|
7674
8142
|
return;
|
|
@@ -7677,11 +8145,14 @@ int main() {
|
|
|
7677
8145
|
this.isRunning = true;
|
|
7678
8146
|
this._updateRunStateUI();
|
|
7679
8147
|
this.drawerTab = 'terminal';
|
|
7680
|
-
const
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
8148
|
+
const isCpp = /\.(cpp|cc|cxx)$/i.test(entry);
|
|
8149
|
+
const isPy = /\.py$/i.test(entry);
|
|
8150
|
+
const cmdText = isCpp
|
|
8151
|
+
? `\n$ g++ -std=c++20 ${entry} -o a.out && ./a.out`
|
|
8152
|
+
: isPy
|
|
8153
|
+
? `\n$ python3 ${entry}`
|
|
8154
|
+
: `\n$ node ${entry}`;
|
|
8155
|
+
this.terminalLogs.push({ type: 'system', text: cmdText });
|
|
7685
8156
|
this._renderDrawerBody();
|
|
7686
8157
|
|
|
7687
8158
|
let abortCtrl = new AbortController();
|
|
@@ -7695,6 +8166,7 @@ int main() {
|
|
|
7695
8166
|
files: { ...this.files },
|
|
7696
8167
|
entry,
|
|
7697
8168
|
mode: 'run',
|
|
8169
|
+
stdin: this.customStdin || '',
|
|
7698
8170
|
signal: abortCtrl.signal,
|
|
7699
8171
|
onStdout: (c) => {
|
|
7700
8172
|
streamedStdout = true;
|
|
@@ -7721,6 +8193,9 @@ int main() {
|
|
|
7721
8193
|
if (!aborted) {
|
|
7722
8194
|
this.lastFsSnapshot = res.fsSnapshot || [];
|
|
7723
8195
|
this.lastHttpTrace = res.httpTrace || [];
|
|
8196
|
+
if (res.durationMs !== undefined) this.lastDurationMs = res.durationMs;
|
|
8197
|
+
if (res.peakMemoryBytes !== undefined) this.lastPeakMemoryBytes = res.peakMemoryBytes;
|
|
8198
|
+
this._updateTelemetryHud();
|
|
7724
8199
|
}
|
|
7725
8200
|
|
|
7726
8201
|
if (this.onRun) {
|
|
@@ -7744,23 +8219,199 @@ int main() {
|
|
|
7744
8219
|
return lastRes;
|
|
7745
8220
|
}
|
|
7746
8221
|
|
|
8222
|
+
async runDemo() {
|
|
8223
|
+
if (this.isRunning) return;
|
|
8224
|
+
const entry = this._findEntryFile('demo') || this._findEntryFile('entry') || this.activeFile;
|
|
8225
|
+
if (!entry) {
|
|
8226
|
+
if ((this.files['index.html'] || this.files['public/index.html']) && typeof this.previewApp === 'function') {
|
|
8227
|
+
return this.previewApp();
|
|
8228
|
+
}
|
|
8229
|
+
this.terminalLogs.push({ type: 'stderr', text: 'No entry or demo file found in this workspace.' });
|
|
8230
|
+
this.drawerTab = 'terminal';
|
|
8231
|
+
this._renderDrawerBody();
|
|
8232
|
+
return;
|
|
8233
|
+
}
|
|
8234
|
+
return this._executeEntryFile(entry);
|
|
8235
|
+
}
|
|
8236
|
+
|
|
8237
|
+
async formatActiveDocument() {
|
|
8238
|
+
if (!this.activeFile) return;
|
|
8239
|
+
const file = this.activeFile;
|
|
8240
|
+
const code = this.files[file] || '';
|
|
8241
|
+
if (!code) return;
|
|
8242
|
+
|
|
8243
|
+
if (file.endsWith('.js') || file.endsWith('.ts') || file.endsWith('.jsx') || file.endsWith('.tsx')) {
|
|
8244
|
+
if (this.editor && typeof this.editor.getAction === 'function') {
|
|
8245
|
+
const action = this.editor.getAction('editor.action.formatDocument');
|
|
8246
|
+
if (action && typeof action.run === 'function') {
|
|
8247
|
+
await action.run();
|
|
8248
|
+
const newCode = this.editor.getValue();
|
|
8249
|
+
this.files[file] = newCode;
|
|
8250
|
+
this._saveState();
|
|
8251
|
+
this._notifyCodeChange(file, newCode);
|
|
8252
|
+
return;
|
|
8253
|
+
}
|
|
8254
|
+
}
|
|
8255
|
+
} else if (file.endsWith('.cpp') || file.endsWith('.hpp') || file.endsWith('.cc') || file.endsWith('.h')) {
|
|
8256
|
+
let formatter = (root && root.CodeLabWorkbenchComponents && root.CodeLabWorkbenchComponents.formatCppSource) ||
|
|
8257
|
+
(typeof globalThis !== 'undefined' && globalThis.CodeLabWorkbenchComponents && globalThis.CodeLabWorkbenchComponents.formatCppSource) ||
|
|
8258
|
+
null;
|
|
8259
|
+
if (!formatter && typeof require === 'function') {
|
|
8260
|
+
try {
|
|
8261
|
+
const mod = require('./workbench/editor');
|
|
8262
|
+
formatter = mod.formatCppSource;
|
|
8263
|
+
} catch (err) {
|
|
8264
|
+
void err;
|
|
8265
|
+
}
|
|
8266
|
+
}
|
|
8267
|
+
if (formatter) {
|
|
8268
|
+
const formatted = formatter(code);
|
|
8269
|
+
if (formatted !== code) {
|
|
8270
|
+
this.files[file] = formatted;
|
|
8271
|
+
if (this.editor && this.editor.getModel()) {
|
|
8272
|
+
this.editor.setValue(formatted);
|
|
8273
|
+
}
|
|
8274
|
+
this._saveState();
|
|
8275
|
+
this._notifyCodeChange(file, formatted);
|
|
8276
|
+
}
|
|
8277
|
+
}
|
|
8278
|
+
} else if (file.endsWith('.py')) {
|
|
8279
|
+
let formatter = (root && root.CodeLabPython && root.CodeLabPython.formatPythonSource) ||
|
|
8280
|
+
(typeof globalThis !== 'undefined' && globalThis.CodeLabPython && globalThis.CodeLabPython.formatPythonSource) ||
|
|
8281
|
+
null;
|
|
8282
|
+
if (!formatter && typeof require === 'function') {
|
|
8283
|
+
try {
|
|
8284
|
+
const mod = require('./extensions/python');
|
|
8285
|
+
formatter = mod.formatPythonSource;
|
|
8286
|
+
} catch (err) {
|
|
8287
|
+
void err;
|
|
8288
|
+
}
|
|
8289
|
+
}
|
|
8290
|
+
if (formatter) {
|
|
8291
|
+
const formatted = formatter(code);
|
|
8292
|
+
if (formatted !== code) {
|
|
8293
|
+
this.files[file] = formatted;
|
|
8294
|
+
if (this.editor && this.editor.getModel()) {
|
|
8295
|
+
this.editor.setValue(formatted);
|
|
8296
|
+
}
|
|
8297
|
+
this._saveState();
|
|
8298
|
+
this._notifyCodeChange(file, formatted);
|
|
8299
|
+
}
|
|
8300
|
+
}
|
|
8301
|
+
}
|
|
8302
|
+
}
|
|
8303
|
+
|
|
8304
|
+
async shareSnapshot() {
|
|
8305
|
+
let compressor = (root && root.CodeLabWorkbenchComponents && root.CodeLabWorkbenchComponents.compressWorkspaceSnapshot) ||
|
|
8306
|
+
(typeof globalThis !== 'undefined' && globalThis.CodeLabWorkbenchComponents && globalThis.CodeLabWorkbenchComponents.compressWorkspaceSnapshot) ||
|
|
8307
|
+
null;
|
|
8308
|
+
if (!compressor && typeof require === 'function') {
|
|
8309
|
+
try {
|
|
8310
|
+
const mod = require('./workbench/share');
|
|
8311
|
+
compressor = mod.compressWorkspaceSnapshot;
|
|
8312
|
+
} catch (err) {
|
|
8313
|
+
void err;
|
|
8314
|
+
}
|
|
8315
|
+
}
|
|
8316
|
+
if (!compressor) {
|
|
8317
|
+
this._showToast('Snapshot compression not available', 'error');
|
|
8318
|
+
return;
|
|
8319
|
+
}
|
|
8320
|
+
try {
|
|
8321
|
+
const payload = {
|
|
8322
|
+
lang: this.lang,
|
|
8323
|
+
activeFile: this.activeFile,
|
|
8324
|
+
files: { ...this.files },
|
|
8325
|
+
stdin: this.customStdin || ''
|
|
8326
|
+
};
|
|
8327
|
+
const token = await compressor(payload);
|
|
8328
|
+
if (typeof window !== 'undefined' && window.location) {
|
|
8329
|
+
const newUrl = `${window.location.origin}${window.location.pathname}#codelab=${token}`;
|
|
8330
|
+
if (window.history && typeof window.history.replaceState === 'function') {
|
|
8331
|
+
window.history.replaceState(null, '', newUrl);
|
|
8332
|
+
} else {
|
|
8333
|
+
window.location.hash = `codelab=${token}`;
|
|
8334
|
+
}
|
|
8335
|
+
if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
|
|
8336
|
+
await navigator.clipboard.writeText(newUrl);
|
|
8337
|
+
this._showToast('Snapshot link copied to clipboard! (#codelab=...)', 'success');
|
|
8338
|
+
} else {
|
|
8339
|
+
this._showToast('Snapshot link generated in URL hash (#codelab=...)', 'success');
|
|
8340
|
+
}
|
|
8341
|
+
}
|
|
8342
|
+
} catch (err) {
|
|
8343
|
+
this.logger.error('Failed to create snapshot.', err);
|
|
8344
|
+
this._showToast('Failed to create snapshot', 'error');
|
|
8345
|
+
}
|
|
8346
|
+
}
|
|
8347
|
+
|
|
8348
|
+
async _checkUrlSnapshot() {
|
|
8349
|
+
if (typeof window === 'undefined' || !window.location || !window.location.hash) return;
|
|
8350
|
+
const hash = window.location.hash;
|
|
8351
|
+
const match = hash.match(/#(?:codelab|snapshot)=([A-Za-z0-9_-]+)/);
|
|
8352
|
+
if (!match) return;
|
|
8353
|
+
const token = match[1];
|
|
8354
|
+
let decompressor = (root && root.CodeLabWorkbenchComponents && root.CodeLabWorkbenchComponents.decompressWorkspaceSnapshot) ||
|
|
8355
|
+
(typeof globalThis !== 'undefined' && globalThis.CodeLabWorkbenchComponents && globalThis.CodeLabWorkbenchComponents.decompressWorkspaceSnapshot) ||
|
|
8356
|
+
null;
|
|
8357
|
+
if (!decompressor && typeof require === 'function') {
|
|
8358
|
+
try {
|
|
8359
|
+
const mod = require('./workbench/share');
|
|
8360
|
+
decompressor = mod.decompressWorkspaceSnapshot;
|
|
8361
|
+
} catch (err) {
|
|
8362
|
+
void err;
|
|
8363
|
+
}
|
|
8364
|
+
}
|
|
8365
|
+
if (!decompressor) return;
|
|
8366
|
+
try {
|
|
8367
|
+
const snapshot = await decompressor(token);
|
|
8368
|
+
if (snapshot && snapshot.files && typeof snapshot.files === 'object') {
|
|
8369
|
+
this.files = { ...snapshot.files };
|
|
8370
|
+
if (snapshot.lang && (snapshot.lang === 'js' || snapshot.lang === 'ts' || snapshot.lang === 'cpp' || snapshot.lang === 'py')) {
|
|
8371
|
+
this.lang = snapshot.lang;
|
|
8372
|
+
}
|
|
8373
|
+
if (snapshot.stdin) {
|
|
8374
|
+
this.customStdin = snapshot.stdin;
|
|
8375
|
+
}
|
|
8376
|
+
if (snapshot.activeFile && this.files[snapshot.activeFile]) {
|
|
8377
|
+
this.activeFile = snapshot.activeFile;
|
|
8378
|
+
}
|
|
8379
|
+
this.openTabs = Object.keys(this.files);
|
|
8380
|
+
this._renderFileLists();
|
|
8381
|
+
this._renderBreadcrumbs();
|
|
8382
|
+
this._syncAllModels();
|
|
8383
|
+
if (this.activeFile) this.openFile(this.activeFile);
|
|
8384
|
+
this._showToast('Restored workspace from snapshot URL', 'success');
|
|
8385
|
+
}
|
|
8386
|
+
} catch (err) {
|
|
8387
|
+
this.logger.warn('Failed to decompress URL snapshot.', err);
|
|
8388
|
+
}
|
|
8389
|
+
}
|
|
8390
|
+
|
|
7747
8391
|
async runTests(filterTestNames = null) {
|
|
7748
8392
|
if (this.isRunning) return;
|
|
7749
8393
|
const entry = this._findEntryFile('test');
|
|
7750
8394
|
if (!entry) {
|
|
7751
|
-
this.terminalLogs.push({ type: 'stderr', text: 'No test.js
|
|
8395
|
+
this.terminalLogs.push({ type: 'stderr', text: 'No test file (test.js, test.ts, test.cpp, test.py) found in this workspace.' });
|
|
7752
8396
|
this.drawerTab = 'terminal';
|
|
7753
8397
|
this._renderDrawerBody();
|
|
7754
8398
|
return;
|
|
7755
8399
|
}
|
|
7756
8400
|
|
|
7757
8401
|
this.isRunning = true;
|
|
7758
|
-
this.
|
|
8402
|
+
this.testSuiteVisible = true;
|
|
7759
8403
|
this.drawerTab = 'tests';
|
|
8404
|
+
this._refreshDrawerTabs();
|
|
8405
|
+
this._updateRunStateUI();
|
|
7760
8406
|
const isCppTest = /\.(cpp|cc|cxx)$/i.test(entry);
|
|
8407
|
+
const isPyTest = /\.py$/i.test(entry);
|
|
7761
8408
|
this.terminalLogs.push({
|
|
7762
8409
|
type: 'system',
|
|
7763
|
-
text: isCppTest
|
|
8410
|
+
text: isCppTest
|
|
8411
|
+
? `\n$ g++ -std=c++20 ${entry} -o a.out && ./a.out`
|
|
8412
|
+
: isPyTest
|
|
8413
|
+
? `\n$ pytest ${entry}`
|
|
8414
|
+
: `\n$ node ${entry}`
|
|
7764
8415
|
});
|
|
7765
8416
|
|
|
7766
8417
|
let abortCtrl = new AbortController();
|
|
@@ -7774,6 +8425,7 @@ int main() {
|
|
|
7774
8425
|
files: { ...this.files },
|
|
7775
8426
|
entry,
|
|
7776
8427
|
mode: 'test',
|
|
8428
|
+
stdin: this.customStdin || '',
|
|
7777
8429
|
testFilter: filterTestNames,
|
|
7778
8430
|
signal: abortCtrl.signal,
|
|
7779
8431
|
onStdout: (c) => {
|
|
@@ -7793,6 +8445,9 @@ int main() {
|
|
|
7793
8445
|
this.lastTestResults = res.testResults || [];
|
|
7794
8446
|
this.lastFsSnapshot = res.fsSnapshot || [];
|
|
7795
8447
|
this.lastHttpTrace = res.httpTrace || [];
|
|
8448
|
+
if (res.durationMs !== undefined) this.lastDurationMs = res.durationMs;
|
|
8449
|
+
if (res.peakMemoryBytes !== undefined) this.lastPeakMemoryBytes = res.peakMemoryBytes;
|
|
8450
|
+
this._updateTelemetryHud();
|
|
7796
8451
|
}
|
|
7797
8452
|
|
|
7798
8453
|
if (!aborted && !streamedStdout && res.stdout) {
|
|
@@ -8352,6 +9007,7 @@ int main() {
|
|
|
8352
9007
|
}
|
|
8353
9008
|
|
|
8354
9009
|
showProblemsModal() {
|
|
9010
|
+
this.switchDrawerTab('problems');
|
|
8355
9011
|
const slot = this.container ? this.container.querySelector('#cl-modal-slot') : null;
|
|
8356
9012
|
if (!slot) return;
|
|
8357
9013
|
const items = this.getDiagnostics();
|
|
@@ -8750,7 +9406,11 @@ int main() {
|
|
|
8750
9406
|
if (this.enabledLanguages instanceof Set && this.enabledLanguages.size > 1) {
|
|
8751
9407
|
this.hasMultipleLanguages = true;
|
|
8752
9408
|
}
|
|
8753
|
-
this.
|
|
9409
|
+
if (typeof this._refreshToolbarAndTabs === 'function') {
|
|
9410
|
+
this._refreshToolbarAndTabs();
|
|
9411
|
+
} else {
|
|
9412
|
+
this._refreshLanguageSwitcher();
|
|
9413
|
+
}
|
|
8754
9414
|
return this;
|
|
8755
9415
|
}
|
|
8756
9416
|
|
|
@@ -8885,8 +9545,13 @@ int main() {
|
|
|
8885
9545
|
openCommandPalette(mode) { if (this._instance) this._instance.openCommandPalette(mode); }
|
|
8886
9546
|
showDiffModal(file, target) { if (this._instance) this._instance.showDiffModal(file, target); }
|
|
8887
9547
|
cloneRepo(repoInput, opts) { return this._instance ? this._instance.cloneRepo(repoInput, opts) : Promise.reject(new Error('Workbench not mounted')); }
|
|
9548
|
+
runCode() { return this._instance ? this._instance.runCode() : Promise.resolve(); }
|
|
9549
|
+
runEntry() { return this._instance ? this._instance.runEntry() : Promise.resolve(); }
|
|
9550
|
+
runActiveFile() { return this._instance ? this._instance.runActiveFile() : Promise.resolve(); }
|
|
8888
9551
|
runDemo() { return this._instance ? this._instance.runDemo() : Promise.resolve(); }
|
|
8889
9552
|
runTests(filter) { return this._instance ? this._instance.runTests(filter) : Promise.resolve(); }
|
|
9553
|
+
formatActiveDocument() { return this._instance ? this._instance.formatActiveDocument() : Promise.resolve(); }
|
|
9554
|
+
shareSnapshot() { return this._instance ? this._instance.shareSnapshot() : Promise.resolve(); }
|
|
8890
9555
|
previewApp() { return this._instance ? this._instance.previewApp() : Promise.resolve(null); }
|
|
8891
9556
|
stopExecution() { if (this._instance) this._instance.stopExecution(); }
|
|
8892
9557
|
reset() { if (this._instance) this._instance.reset(); }
|
|
@@ -8981,7 +9646,8 @@ int main() {
|
|
|
8981
9646
|
guidedLab: null,
|
|
8982
9647
|
javascript: null,
|
|
8983
9648
|
typescript: null,
|
|
8984
|
-
cpp: null
|
|
9649
|
+
cpp: null,
|
|
9650
|
+
python: null
|
|
8985
9651
|
},
|
|
8986
9652
|
parseGitHubRepoUrl,
|
|
8987
9653
|
cloneRepo: cloneGitHubRepository,
|
|
@@ -9008,3 +9674,22 @@ int main() {
|
|
|
9008
9674
|
module.exports = CodeLabSDK;
|
|
9009
9675
|
}
|
|
9010
9676
|
})(typeof window !== 'undefined' ? window : globalThis);
|
|
9677
|
+
|
|
9678
|
+
// ── TypeScript module surface (stripped from browser bundles) ──────────────
|
|
9679
|
+
const _hostWorkbench: any = (typeof globalThis !== 'undefined' ? (globalThis as any).CodeLabWorkbench : undefined)
|
|
9680
|
+
|| (typeof window !== 'undefined' ? (window as any).CodeLabWorkbench : undefined)
|
|
9681
|
+
|| (typeof module !== 'undefined' && module.exports && (module.exports.CodeLabWorkbench || module.exports) ? (module.exports.CodeLabWorkbench || module.exports) : undefined);
|
|
9682
|
+
|
|
9683
|
+
const _hostElement: any = (typeof globalThis !== 'undefined' ? (globalThis as any).CodeLabElement : undefined)
|
|
9684
|
+
|| (typeof window !== 'undefined' ? (window as any).CodeLabElement : undefined)
|
|
9685
|
+
|| (typeof module !== 'undefined' && module.exports ? module.exports.CodeLabElement : undefined);
|
|
9686
|
+
|
|
9687
|
+
const _hostSDK: any = (typeof globalThis !== 'undefined' ? (globalThis as any).CodeLab : undefined)
|
|
9688
|
+
|| (typeof window !== 'undefined' ? (window as any).CodeLab : undefined)
|
|
9689
|
+
|| (typeof module !== 'undefined' && module.exports ? module.exports : {});
|
|
9690
|
+
|
|
9691
|
+
export const CodeLabWorkbench: any = _hostWorkbench;
|
|
9692
|
+
export const Workbench: any = _hostWorkbench;
|
|
9693
|
+
export const CodeLabElement: any = _hostElement;
|
|
9694
|
+
export const CodeLab: any = _hostSDK;
|
|
9695
|
+
export default _hostSDK;
|