@innovatorved/code-lab 0.6.1 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ARCHITECTURE.md +2 -2
- package/CHANGELOG.md +35 -0
- package/README.md +38 -1
- package/dist/apps/web/src/index.d.ts +0 -9
- package/dist/code-lab-sql.esm.js +19 -19
- package/dist/code-lab-sql.umd.js +20 -20
- package/dist/code-lab.css +1 -1
- package/dist/code-lab.d.ts +19 -1
- package/dist/code-lab.esm.js +933 -1685
- package/dist/code-lab.js +932 -1684
- package/dist/extensions/cpp.esm.js +132 -8751
- package/dist/extensions/cpp.js +124 -8761
- package/dist/extensions/guided-lab.esm.js +33 -6827
- package/dist/extensions/guided-lab.js +33 -6845
- package/dist/extensions/javascript.esm.js +1 -36
- package/dist/extensions/javascript.js +1 -58
- package/dist/extensions/python.esm.js +79 -8109
- package/dist/extensions/python.js +79 -8127
- package/dist/extensions/typescript.esm.js +1 -55
- package/dist/extensions/typescript.js +1 -77
- package/dist/index.d.ts +1 -1
- package/dist/modular-kernel.d.ts +0 -4
- package/dist/preview-sw.js +1 -1
- package/dist/runtime.esm.js +79 -79
- package/dist/runtime.js +79 -79
- package/dist/schemas.d.ts +22 -1
- package/dist/schemas.esm.js +33 -6806
- package/dist/schemas.js +33 -6822
- package/dist/shell.esm.js +248 -242
- package/dist/shell.js +248 -242
- package/dist/terminal.esm.js +8 -6
- package/dist/terminal.js +6 -6
- package/dist/workbench/command-palette.d.ts +0 -4
- package/dist/workbench/index.d.ts +0 -20
- package/dist/workbench/intellisense.d.ts +1 -7
- package/package.json +3 -10
- package/src/code-lab.css +11 -503
- package/src/extensions/cpp.ts +11 -29
- package/src/extensions/guided-lab.ts +6 -2
- package/src/extensions/python.ts +9 -3
- package/src/index.ts +1 -1
- package/src/modular-kernel.ts +0 -4
- package/src/runtime.ts +153 -42
- package/src/schemas.ts +12 -3
- package/src/shell.ts +109 -16
- package/src/terminal.ts +4 -2
- package/src/workbench/command-palette.ts +22 -302
- package/src/workbench/diff-editor.ts +2 -0
- package/src/workbench/icons.ts +1 -1
- package/src/workbench/index.ts +0 -15
- package/src/workbench/intellisense.ts +17 -4
- package/src/workbench.ts +432 -456
- package/dist/code-lab.umd.js +0 -6109
- package/dist/packages/editor/src/index.d.ts +0 -118
- package/dist/packages/preview/src/index.d.ts +0 -34
- package/dist/packages/runtime/src/index.d.ts +0 -47
- package/dist/packages/terminal/src/index.d.ts +0 -54
- package/dist/workbench/drawer.d.ts +0 -18
- package/dist/workbench/file-tree.d.ts +0 -11
- package/dist/workbench/guided-pane.d.ts +0 -11
- package/dist/workbench/styles.d.ts +0 -4
- package/dist/workbench/toolbar.d.ts +0 -17
- package/packages/commands/README.md +0 -7
- package/packages/commands/package.json +0 -16
- package/packages/commands/src/index.ts +0 -467
- package/packages/commands/tsconfig.json +0 -22
- package/packages/core/README.md +0 -12
- package/packages/core/package.json +0 -13
- package/packages/core/src/di.ts +0 -147
- package/packages/core/src/disposable.ts +0 -112
- package/packages/core/src/errors.ts +0 -205
- package/packages/core/src/events.ts +0 -157
- package/packages/core/src/index.ts +0 -49
- package/packages/core/src/path.ts +0 -118
- package/packages/core/src/registry.ts +0 -61
- package/packages/core/tsconfig.json +0 -19
- package/packages/editor/README.md +0 -9
- package/packages/editor/package.json +0 -18
- package/packages/editor/src/index.ts +0 -344
- package/packages/editor/tsconfig.json +0 -24
- package/packages/fs/README.md +0 -7
- package/packages/fs/package.json +0 -16
- package/packages/fs/src/backends.ts +0 -301
- package/packages/fs/src/index.ts +0 -18
- package/packages/fs/src/types.ts +0 -44
- package/packages/fs/src/vfs-service.ts +0 -257
- package/packages/fs/tsconfig.json +0 -22
- package/packages/preview/README.md +0 -3
- package/packages/preview/package.json +0 -16
- package/packages/preview/src/index.ts +0 -125
- package/packages/preview/tsconfig.json +0 -22
- package/packages/runtime/README.md +0 -3
- package/packages/runtime/package.json +0 -17
- package/packages/runtime/src/index.ts +0 -134
- package/packages/runtime/tsconfig.json +0 -23
- package/packages/settings/README.md +0 -7
- package/packages/settings/package.json +0 -16
- package/packages/settings/src/builtin-schemas.ts +0 -246
- package/packages/settings/src/configuration-service.ts +0 -609
- package/packages/settings/src/index.ts +0 -38
- package/packages/settings/src/jsonc.ts +0 -189
- package/packages/settings/src/schema.ts +0 -164
- package/packages/settings/tsconfig.json +0 -22
- package/packages/sql/README.md +0 -12
- package/packages/sql/package.json +0 -13
- package/packages/sql/src/completions.ts +0 -359
- package/packages/sql/src/diagnostics.ts +0 -200
- package/packages/sql/src/formatter.ts +0 -271
- package/packages/sql/src/index.ts +0 -54
- package/packages/sql/src/sql-editor.ts +0 -802
- package/packages/sql/src/styles.ts +0 -524
- package/packages/sql/src/tokenizer.ts +0 -457
- package/packages/sql/src/types.ts +0 -148
- package/packages/sql/tsconfig.json +0 -19
- package/packages/terminal/README.md +0 -3
- package/packages/terminal/package.json +0 -16
- package/packages/terminal/src/index.ts +0 -183
- package/packages/terminal/tsconfig.json +0 -22
- package/packages/ui/README.md +0 -8
- package/packages/ui/package.json +0 -18
- package/packages/ui/src/index.ts +0 -40
- package/packages/ui/src/observability.ts +0 -173
- package/packages/ui/src/plugin-registry.ts +0 -289
- package/packages/ui/src/settings-dialog.ts +0 -911
- package/packages/ui/src/themes.ts +0 -333
- package/packages/ui/tsconfig.json +0 -24
- package/src/workbench/drawer.ts +0 -157
- package/src/workbench/file-tree.ts +0 -51
- package/src/workbench/guided-pane.ts +0 -43
- package/src/workbench/styles.ts +0 -211
- package/src/workbench/toolbar.ts +0 -182
package/src/runtime.ts
CHANGED
|
@@ -6593,7 +6593,9 @@ function __initVirtualRuntime(rootScope) {
|
|
|
6593
6593
|
},
|
|
6594
6594
|
ref() {
|
|
6595
6595
|
this._ref = true;
|
|
6596
|
-
resourceTracker.
|
|
6596
|
+
if (resourceTracker.allTimers.has(rawId)) {
|
|
6597
|
+
resourceTracker.activeTimers.add(rawId);
|
|
6598
|
+
}
|
|
6597
6599
|
return this;
|
|
6598
6600
|
},
|
|
6599
6601
|
hasRef() {
|
|
@@ -7714,6 +7716,8 @@ function __initVirtualRuntime(rootScope) {
|
|
|
7714
7716
|
return isDeepEqual(a, b, true);
|
|
7715
7717
|
}
|
|
7716
7718
|
|
|
7719
|
+
const activeBunServers = new Set();
|
|
7720
|
+
|
|
7717
7721
|
const BunObj = {
|
|
7718
7722
|
version: '1.1.0',
|
|
7719
7723
|
serve(opts = {}) {
|
|
@@ -7724,6 +7728,7 @@ function __initVirtualRuntime(rootScope) {
|
|
|
7724
7728
|
hostname,
|
|
7725
7729
|
development: false,
|
|
7726
7730
|
stop() {
|
|
7731
|
+
activeBunServers.delete(serverObj);
|
|
7727
7732
|
activePortTable.unregisterServer(port);
|
|
7728
7733
|
}
|
|
7729
7734
|
};
|
|
@@ -7735,6 +7740,7 @@ function __initVirtualRuntime(rootScope) {
|
|
|
7735
7740
|
fetch: opts.fetch ? opts.fetch.bind(serverObj) : undefined,
|
|
7736
7741
|
stop: () => serverObj.stop()
|
|
7737
7742
|
});
|
|
7743
|
+
activeBunServers.add(serverObj);
|
|
7738
7744
|
return serverObj;
|
|
7739
7745
|
},
|
|
7740
7746
|
file(p) {
|
|
@@ -8966,6 +8972,7 @@ function __initVirtualRuntime(rootScope) {
|
|
|
8966
8972
|
'Python WebAssembly toolchain is not registered. Enable pythonExtension from "@innovatorved/code-lab/extensions/python" to run Python files.'
|
|
8967
8973
|
);
|
|
8968
8974
|
}
|
|
8975
|
+
const pyTestResultsBefore = testResults.length;
|
|
8969
8976
|
const pyRes = await pyCompiler({
|
|
8970
8977
|
entry: entryAbs,
|
|
8971
8978
|
vfs,
|
|
@@ -8973,13 +8980,14 @@ function __initVirtualRuntime(rootScope) {
|
|
|
8973
8980
|
args: argv || [entryAbs],
|
|
8974
8981
|
env: Object.assign({}, sandboxProcess.env, options.env || {}),
|
|
8975
8982
|
stdin: options.stdin || '',
|
|
8983
|
+
onRequestStdin: options.onRequestStdin,
|
|
8976
8984
|
testFilter,
|
|
8977
8985
|
onStdout: emitStdout,
|
|
8978
8986
|
onStderr: emitStderr
|
|
8979
8987
|
});
|
|
8980
8988
|
if (pyRes) {
|
|
8981
8989
|
exitCode = typeof pyRes.exitCode === 'number' ? pyRes.exitCode : (pyRes.ok ? 0 : 1);
|
|
8982
|
-
if (pyRes.testResults && Array.isArray(pyRes.testResults)) {
|
|
8990
|
+
if (testResults.length === pyTestResultsBefore && pyRes.testResults && Array.isArray(pyRes.testResults)) {
|
|
8983
8991
|
for (const tr of pyRes.testResults) {
|
|
8984
8992
|
testResults.push(tr);
|
|
8985
8993
|
}
|
|
@@ -9012,13 +9020,31 @@ function __initVirtualRuntime(rootScope) {
|
|
|
9012
9020
|
}
|
|
9013
9021
|
}
|
|
9014
9022
|
|
|
9023
|
+
const hasLiveServers = () => {
|
|
9024
|
+
if (vhttp.hasActiveServers()) return true;
|
|
9025
|
+
if (activeBunServers.size > 0) {
|
|
9026
|
+
for (const srv of Array.from(activeBunServers)) {
|
|
9027
|
+
if (!activePortTable.getServer(srv.port)) {
|
|
9028
|
+
activeBunServers.delete(srv);
|
|
9029
|
+
}
|
|
9030
|
+
}
|
|
9031
|
+
return activeBunServers.size > 0;
|
|
9032
|
+
}
|
|
9033
|
+
return false;
|
|
9034
|
+
};
|
|
9035
|
+
|
|
9015
9036
|
const deadline = performance.now() + timeoutMs;
|
|
9016
9037
|
let idleTicks = 0;
|
|
9017
|
-
while (!hasExited
|
|
9038
|
+
while (!hasExited) {
|
|
9018
9039
|
if (signal && signal.aborted) {
|
|
9019
9040
|
handleSigint();
|
|
9020
9041
|
break;
|
|
9021
9042
|
}
|
|
9043
|
+
const liveServers = hasLiveServers();
|
|
9044
|
+
const holdForInteractiveServer = Boolean(!isBackground && signal && liveServers);
|
|
9045
|
+
if (!holdForInteractiveServer && performance.now() >= deadline) {
|
|
9046
|
+
break;
|
|
9047
|
+
}
|
|
9022
9048
|
await Promise.resolve();
|
|
9023
9049
|
await Promise.resolve();
|
|
9024
9050
|
const busy =
|
|
@@ -9026,7 +9052,7 @@ function __initVirtualRuntime(rootScope) {
|
|
|
9026
9052
|
resourceTracker.activeImmediates.size > 0 ||
|
|
9027
9053
|
resourceTracker.inFlightHttp.size > 0 ||
|
|
9028
9054
|
resourceTracker.pendingTests.size > 0 ||
|
|
9029
|
-
(isBackground
|
|
9055
|
+
((isBackground || Boolean(signal)) && liveServers);
|
|
9030
9056
|
|
|
9031
9057
|
if (!busy) {
|
|
9032
9058
|
idleTicks++;
|
|
@@ -9034,7 +9060,7 @@ function __initVirtualRuntime(rootScope) {
|
|
|
9034
9060
|
} else {
|
|
9035
9061
|
idleTicks = 0;
|
|
9036
9062
|
}
|
|
9037
|
-
await new Promise((r) => setTimeout(r, 2));
|
|
9063
|
+
await new Promise((r) => setTimeout(r, holdForInteractiveServer ? 25 : 2));
|
|
9038
9064
|
}
|
|
9039
9065
|
} catch (err) {
|
|
9040
9066
|
if (err && err._isProcessExit) {
|
|
@@ -9070,6 +9096,10 @@ function __initVirtualRuntime(rootScope) {
|
|
|
9070
9096
|
if (!isBackground) {
|
|
9071
9097
|
vhttp.closeAllServers();
|
|
9072
9098
|
vnet.closeAllServers();
|
|
9099
|
+
for (const srv of Array.from(activeBunServers)) {
|
|
9100
|
+
try { srv.stop(); } catch (err) { _runtimeLogger.debug('executeInVirtualRuntime bun server stop failed', err); }
|
|
9101
|
+
}
|
|
9102
|
+
activeBunServers.clear();
|
|
9073
9103
|
if (initialOpenFds && typeof vfs._listOpenFds === 'function' && typeof vfs.closeSync === 'function') {
|
|
9074
9104
|
for (const fd of vfs._listOpenFds()) {
|
|
9075
9105
|
if (!initialOpenFds.has(fd)) {
|
|
@@ -9479,7 +9509,7 @@ function __initVirtualRuntime(rootScope) {
|
|
|
9479
9509
|
const andParts = whereClause.split(/\s+AND\s+/i);
|
|
9480
9510
|
for (const part of andParts) {
|
|
9481
9511
|
const trimmed = part.trim();
|
|
9482
|
-
const isNullMatch = trimmed.match(/^([a-zA-Z0-9_]+)\s+IS\s+(NOT\s+)?NULL$/i);
|
|
9512
|
+
const isNullMatch = trimmed.match(/^([a-zA-Z0-9_.]+)\s+IS\s+(NOT\s+)?NULL$/i);
|
|
9483
9513
|
if (isNullMatch) {
|
|
9484
9514
|
const col = isNullMatch[1];
|
|
9485
9515
|
const isNot = Boolean(isNullMatch[2]);
|
|
@@ -9487,7 +9517,7 @@ function __initVirtualRuntime(rootScope) {
|
|
|
9487
9517
|
if (isNot ? isNull : !isNull) return false;
|
|
9488
9518
|
continue;
|
|
9489
9519
|
}
|
|
9490
|
-
const likeMatch = trimmed.match(/^([a-zA-Z0-9_]+)\s+LIKE\s+(.+)$/i);
|
|
9520
|
+
const likeMatch = trimmed.match(/^([a-zA-Z0-9_.]+)\s+LIKE\s+(.+)$/i);
|
|
9491
9521
|
if (likeMatch) {
|
|
9492
9522
|
const col = likeMatch[1];
|
|
9493
9523
|
let pat = likeMatch[2].trim();
|
|
@@ -9497,7 +9527,7 @@ function __initVirtualRuntime(rootScope) {
|
|
|
9497
9527
|
if (!re.test(String(row[col] ?? ''))) return false;
|
|
9498
9528
|
continue;
|
|
9499
9529
|
}
|
|
9500
|
-
const eqMatch = trimmed.match(/^([a-zA-Z0-9_]+)\s*(=|!=|<>|>=|<=|>|<)\s*(.*)$/);
|
|
9530
|
+
const eqMatch = trimmed.match(/^([a-zA-Z0-9_.]+)\s*(=|!=|<>|>=|<=|>|<)\s*(.*)$/);
|
|
9501
9531
|
if (eqMatch) {
|
|
9502
9532
|
const col = eqMatch[1].trim();
|
|
9503
9533
|
const op = eqMatch[2];
|
|
@@ -9644,6 +9674,37 @@ function __initVirtualRuntime(rootScope) {
|
|
|
9644
9674
|
return null;
|
|
9645
9675
|
}
|
|
9646
9676
|
|
|
9677
|
+
_evalSelectExpr(expr, rows, fallbackRow) {
|
|
9678
|
+
const trimmed = expr.trim();
|
|
9679
|
+
const roundMatch = trimmed.match(/^ROUND\s*\(([\s\S]+),\s*(\d+)\s*\)$/i);
|
|
9680
|
+
if (roundMatch) {
|
|
9681
|
+
const innerVal = Number(this._evalSelectExpr(roundMatch[1], rows, fallbackRow));
|
|
9682
|
+
const decimals = Number(roundMatch[2]);
|
|
9683
|
+
const factor = Math.pow(10, decimals);
|
|
9684
|
+
return Number.isFinite(innerVal) ? Math.round(innerVal * factor) / factor : null;
|
|
9685
|
+
}
|
|
9686
|
+
const arithMatch = trimmed.match(/^((?:AVG|SUM|COUNT|MIN|MAX)\s*\([^)]+\))\s*([/*+-])\s*([0-9.]+)$/i);
|
|
9687
|
+
if (arithMatch) {
|
|
9688
|
+
const base = Number(this._evalSelectExpr(arithMatch[1], rows, fallbackRow));
|
|
9689
|
+
const rhs = Number(arithMatch[3]);
|
|
9690
|
+
if (arithMatch[2] === '/') return rhs !== 0 ? base / rhs : null;
|
|
9691
|
+
if (arithMatch[2] === '*') return base * rhs;
|
|
9692
|
+
if (arithMatch[2] === '+') return base + rhs;
|
|
9693
|
+
if (arithMatch[2] === '-') return base - rhs;
|
|
9694
|
+
}
|
|
9695
|
+
const aggMatch = trimmed.match(/^(AVG|SUM|COUNT|MIN|MAX)\s*\(([^)]+)\)$/i);
|
|
9696
|
+
if (aggMatch) {
|
|
9697
|
+
return this._evalAggregate(aggMatch[1].toUpperCase(), aggMatch[2].trim(), rows);
|
|
9698
|
+
}
|
|
9699
|
+
if (fallbackRow && Object.prototype.hasOwnProperty.call(fallbackRow, trimmed)) {
|
|
9700
|
+
return fallbackRow[trimmed];
|
|
9701
|
+
}
|
|
9702
|
+
if (rows[0] && Object.prototype.hasOwnProperty.call(rows[0], trimmed)) {
|
|
9703
|
+
return rows[0][trimmed];
|
|
9704
|
+
}
|
|
9705
|
+
return null;
|
|
9706
|
+
}
|
|
9707
|
+
|
|
9647
9708
|
_executeSelect(sql, params = []) {
|
|
9648
9709
|
const s = stripSqlComments(sql).replace(/;$/, '').trim();
|
|
9649
9710
|
if (!s) return [];
|
|
@@ -9707,7 +9768,7 @@ function __initVirtualRuntime(rootScope) {
|
|
|
9707
9768
|
return [];
|
|
9708
9769
|
}
|
|
9709
9770
|
|
|
9710
|
-
const match = s.match(/^SELECT\s+(?:DISTINCT\s+)?([\s\S]*?)\s+FROM\s+([a-zA-Z0-9_]+)(?:\s+WHERE\s+([\s\S]*?))?(?:\s+GROUP\s+BY\s+([\s\S]*?))?(?:\s+ORDER\s+BY\s+([\s\S]*?))?(?:\s+LIMIT\s+(\d+|\?)(?:\s+OFFSET\s+(\d+|\?))?)?$/i);
|
|
9771
|
+
const match = s.match(/^SELECT\s+(?:DISTINCT\s+)?([\s\S]*?)\s+FROM\s+([a-zA-Z0-9_]+)(?:\s+(?:AS\s+)?(?!WHERE\b|JOIN\b|INNER\b|LEFT\b|RIGHT\b|FULL\b|CROSS\b|GROUP\b|ORDER\b|LIMIT\b)([a-zA-Z0-9_]+))?((?:\s+(?:(?:INNER|LEFT(?:\s+OUTER)?)\s+)?JOIN\s+[a-zA-Z0-9_]+(?:\s+(?:AS\s+)?(?!ON\b)[a-zA-Z0-9_]+)?\s+ON\s+[a-zA-Z0-9_.]+\s*=\s*[a-zA-Z0-9_.]+)*)(?:\s+WHERE\s+([\s\S]*?))?(?:\s+GROUP\s+BY\s+([\s\S]*?))?(?:\s+ORDER\s+BY\s+([\s\S]*?))?(?:\s+LIMIT\s+(\d+|\?)(?:\s+OFFSET\s+(\d+|\?))?)?$/i);
|
|
9711
9772
|
if (!match) {
|
|
9712
9773
|
const noFromMatch = s.match(/^SELECT\s+([\s\S]+)$/i);
|
|
9713
9774
|
if (noFromMatch) {
|
|
@@ -9728,17 +9789,69 @@ function __initVirtualRuntime(rootScope) {
|
|
|
9728
9789
|
}
|
|
9729
9790
|
const selectColsRaw = match[1].trim();
|
|
9730
9791
|
const tableName = match[2].trim();
|
|
9731
|
-
const
|
|
9732
|
-
const
|
|
9733
|
-
const
|
|
9734
|
-
const
|
|
9735
|
-
const
|
|
9792
|
+
const tableAlias = (match[3] || tableName).trim();
|
|
9793
|
+
const joinsRaw = (match[4] || '').trim();
|
|
9794
|
+
const whereClause = match[5] ? match[5].trim() : null;
|
|
9795
|
+
const groupByClause = match[6] ? match[6].trim() : null;
|
|
9796
|
+
const orderByClause = match[7] ? match[7].trim() : null;
|
|
9797
|
+
const limitRaw = match[8] ? match[8].trim() : null;
|
|
9798
|
+
const offsetRaw = match[9] ? match[9].trim() : null;
|
|
9736
9799
|
|
|
9737
9800
|
const table = this.tables.get(tableName);
|
|
9738
9801
|
if (!table) return [];
|
|
9739
9802
|
|
|
9803
|
+
const qualifyRow = (rawRow, tblName, aliasName) => {
|
|
9804
|
+
const out = Object.assign({}, rawRow);
|
|
9805
|
+
for (const [k, v] of Object.entries(rawRow)) {
|
|
9806
|
+
out[`${tblName}.${k}`] = v;
|
|
9807
|
+
if (aliasName && aliasName !== tblName) out[`${aliasName}.${k}`] = v;
|
|
9808
|
+
}
|
|
9809
|
+
return out;
|
|
9810
|
+
};
|
|
9811
|
+
|
|
9812
|
+
let workingRows = table.rows.map((r) => qualifyRow(r, tableName, tableAlias));
|
|
9813
|
+
if (joinsRaw) {
|
|
9814
|
+
const joinRe = /(?:(INNER|LEFT(?:\s+OUTER)?)\s+)?JOIN\s+([a-zA-Z0-9_]+)(?:\s+(?:AS\s+)?(?!ON\b)([a-zA-Z0-9_]+))?\s+ON\s+([a-zA-Z0-9_.]+)\s*=\s*([a-zA-Z0-9_.]+)/gi;
|
|
9815
|
+
let jm;
|
|
9816
|
+
while ((jm = joinRe.exec(joinsRaw)) !== null) {
|
|
9817
|
+
const isLeft = Boolean(jm[1] && /^LEFT/i.test(jm[1]));
|
|
9818
|
+
const joinTblName = jm[2];
|
|
9819
|
+
const joinAlias = jm[3] || joinTblName;
|
|
9820
|
+
const leftKey = jm[4];
|
|
9821
|
+
const rightKey = jm[5];
|
|
9822
|
+
const joinTbl = this.tables.get(joinTblName);
|
|
9823
|
+
if (!joinTbl) {
|
|
9824
|
+
workingRows = [];
|
|
9825
|
+
break;
|
|
9826
|
+
}
|
|
9827
|
+
const nextRows = [];
|
|
9828
|
+
for (const baseRow of workingRows) {
|
|
9829
|
+
let matchedAny = false;
|
|
9830
|
+
for (const jr of joinTbl.rows) {
|
|
9831
|
+
const qJr = qualifyRow(jr, joinTblName, joinAlias);
|
|
9832
|
+
const merged = Object.assign({}, baseRow, qJr);
|
|
9833
|
+
const lv = Object.prototype.hasOwnProperty.call(baseRow, leftKey) ? baseRow[leftKey] : qJr[leftKey];
|
|
9834
|
+
const rv = Object.prototype.hasOwnProperty.call(qJr, rightKey) ? qJr[rightKey] : baseRow[rightKey];
|
|
9835
|
+
if (lv !== undefined && rv !== undefined && String(lv) === String(rv)) {
|
|
9836
|
+
nextRows.push(merged);
|
|
9837
|
+
matchedAny = true;
|
|
9838
|
+
}
|
|
9839
|
+
}
|
|
9840
|
+
if (!matchedAny && isLeft) {
|
|
9841
|
+
const nullPad = Object.assign({}, baseRow);
|
|
9842
|
+
for (const colDef of joinTbl.columns) {
|
|
9843
|
+
nullPad[`${joinTblName}.${colDef.name}`] = null;
|
|
9844
|
+
if (joinAlias !== joinTblName) nullPad[`${joinAlias}.${colDef.name}`] = null;
|
|
9845
|
+
}
|
|
9846
|
+
nextRows.push(nullPad);
|
|
9847
|
+
}
|
|
9848
|
+
}
|
|
9849
|
+
workingRows = nextRows;
|
|
9850
|
+
}
|
|
9851
|
+
}
|
|
9852
|
+
|
|
9740
9853
|
const pList = Array.isArray(params) ? [...params] : [params];
|
|
9741
|
-
const filteredRows =
|
|
9854
|
+
const filteredRows = workingRows.filter((row) => {
|
|
9742
9855
|
const rowParams = [...pList];
|
|
9743
9856
|
return this._matchWhere(row, whereClause, rowParams);
|
|
9744
9857
|
});
|
|
@@ -9752,12 +9865,17 @@ function __initVirtualRuntime(rootScope) {
|
|
|
9752
9865
|
if (selectColsRaw !== '*') {
|
|
9753
9866
|
const parts = splitCsvRespectingQuotes(selectColsRaw);
|
|
9754
9867
|
for (const p of parts) {
|
|
9755
|
-
const asMatch = p.match(/^([\s\S]*?)\s+
|
|
9756
|
-
|
|
9757
|
-
const
|
|
9758
|
-
|
|
9759
|
-
|
|
9760
|
-
|
|
9868
|
+
const asMatch = p.match(/^([\s\S]*?)\s+AS\s+([a-zA-Z0-9_]+)$/i) ||
|
|
9869
|
+
(!/\)/.test(p.trim()) ? p.match(/^([a-zA-Z0-9_.]+)\s+([a-zA-Z0-9_]+)$/) : null);
|
|
9870
|
+
const rawExpr = (asMatch ? asMatch[1] : p).trim();
|
|
9871
|
+
const defaultAlias = rawExpr.includes('.') && !/[()\s]/.test(rawExpr)
|
|
9872
|
+
? rawExpr.split('.').pop()
|
|
9873
|
+
: rawExpr;
|
|
9874
|
+
const spec = {
|
|
9875
|
+
expr: rawExpr,
|
|
9876
|
+
alias: asMatch ? asMatch[2].trim() : defaultAlias
|
|
9877
|
+
};
|
|
9878
|
+
if (/\b(AVG|SUM|COUNT|MIN|MAX)\s*\(/i.test(spec.expr)) {
|
|
9761
9879
|
hasAggregate = true;
|
|
9762
9880
|
}
|
|
9763
9881
|
colSpecs.push(spec);
|
|
@@ -9766,49 +9884,41 @@ function __initVirtualRuntime(rootScope) {
|
|
|
9766
9884
|
|
|
9767
9885
|
let outputRows = [];
|
|
9768
9886
|
if (groupByClause) {
|
|
9769
|
-
const
|
|
9887
|
+
const groupCols = groupByClause.split(',').map((c) => c.trim()).filter(Boolean);
|
|
9770
9888
|
const groups = new Map();
|
|
9771
9889
|
for (const row of filteredRows) {
|
|
9772
|
-
const key =
|
|
9890
|
+
const key = groupCols.length === 1
|
|
9891
|
+
? row[groupCols[0]]
|
|
9892
|
+
: JSON.stringify(groupCols.map((gc) => row[gc]));
|
|
9773
9893
|
if (!groups.has(key)) groups.set(key, []);
|
|
9774
9894
|
groups.get(key).push(row);
|
|
9775
9895
|
}
|
|
9776
9896
|
|
|
9777
|
-
for (const [
|
|
9897
|
+
for (const [, rows] of groups.entries()) {
|
|
9778
9898
|
const outRow = {};
|
|
9779
9899
|
for (const col of colSpecs) {
|
|
9780
|
-
|
|
9781
|
-
const alias = col.alias;
|
|
9782
|
-
const aggMatch = expr.match(/^(AVG|SUM|COUNT|MIN|MAX)\s*\(([^)]+)\)$/i);
|
|
9783
|
-
if (aggMatch) {
|
|
9784
|
-
outRow[alias] = this._evalAggregate(aggMatch[1].toUpperCase(), aggMatch[2].trim(), rows);
|
|
9785
|
-
} else if (expr === groupCol) {
|
|
9786
|
-
outRow[alias] = key;
|
|
9787
|
-
} else {
|
|
9788
|
-
outRow[alias] = rows[0] ? rows[0][expr] : null;
|
|
9789
|
-
}
|
|
9900
|
+
outRow[col.alias] = this._evalSelectExpr(col.expr, rows, rows[0]);
|
|
9790
9901
|
}
|
|
9791
9902
|
outputRows.push(outRow);
|
|
9792
9903
|
}
|
|
9793
9904
|
} else if (hasAggregate) {
|
|
9794
9905
|
const outRow = {};
|
|
9795
9906
|
for (const col of colSpecs) {
|
|
9796
|
-
|
|
9797
|
-
if (aggMatch) {
|
|
9798
|
-
outRow[col.alias] = this._evalAggregate(aggMatch[1].toUpperCase(), aggMatch[2].trim(), filteredRows);
|
|
9799
|
-
} else {
|
|
9800
|
-
outRow[col.alias] = filteredRows[0] ? filteredRows[0][col.expr] : null;
|
|
9801
|
-
}
|
|
9907
|
+
outRow[col.alias] = this._evalSelectExpr(col.expr, filteredRows, filteredRows[0]);
|
|
9802
9908
|
}
|
|
9803
9909
|
outputRows.push(outRow);
|
|
9804
9910
|
} else {
|
|
9805
9911
|
for (const row of filteredRows) {
|
|
9806
9912
|
if (selectColsRaw === '*') {
|
|
9807
|
-
|
|
9913
|
+
const clean = {};
|
|
9914
|
+
for (const [k, v] of Object.entries(row)) {
|
|
9915
|
+
if (!k.includes('.')) clean[k] = v;
|
|
9916
|
+
}
|
|
9917
|
+
outputRows.push(clean);
|
|
9808
9918
|
} else {
|
|
9809
9919
|
const outRow = {};
|
|
9810
9920
|
for (const col of colSpecs) {
|
|
9811
|
-
outRow[col.alias] =
|
|
9921
|
+
outRow[col.alias] = this._evalSelectExpr(col.expr, [row], row);
|
|
9812
9922
|
}
|
|
9813
9923
|
outputRows.push(outRow);
|
|
9814
9924
|
}
|
|
@@ -10257,6 +10367,7 @@ _hostRuntime.executeInWorker = async function executeInWorker(options = {}) {
|
|
|
10257
10367
|
if (options.signal.aborted) {
|
|
10258
10368
|
const job = _activeWorkerJobs.get(requestId);
|
|
10259
10369
|
if (job) job.cancel('SIGINT: Interrupted by user (Ctrl+C)');
|
|
10370
|
+
return;
|
|
10260
10371
|
} else {
|
|
10261
10372
|
abortListener = () => {
|
|
10262
10373
|
const job = _activeWorkerJobs.get(requestId);
|
package/src/schemas.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Zod Schemas and Inferred TypeScript Types for code-lab v0.
|
|
4
|
+
* Zod Schemas and Inferred TypeScript Types for code-lab v0.7.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
// ── 1. Guided Step ──────────────────────────────────────────────────────────
|
|
@@ -22,7 +22,7 @@ export type GuidedStep = z.infer<typeof GuidedStepSchema>;
|
|
|
22
22
|
|
|
23
23
|
// ── 2. Language Bundle ──────────────────────────────────────────────────────
|
|
24
24
|
|
|
25
|
-
export const LanguageIdSchema = z.enum(['js', 'ts', 'cpp', 'py']);
|
|
25
|
+
export const LanguageIdSchema = z.enum(['js', 'ts', 'cpp', 'py', 'sql']);
|
|
26
26
|
export type LanguageId = z.infer<typeof LanguageIdSchema>;
|
|
27
27
|
export const LanguageEnum = LanguageIdSchema;
|
|
28
28
|
|
|
@@ -100,7 +100,7 @@ export const CppExtensionOptionsSchema = z.object({
|
|
|
100
100
|
export type CppExtensionOptions = z.input<typeof CppExtensionOptionsSchema>;
|
|
101
101
|
|
|
102
102
|
export const PythonToolchainProgressSchema = z.object({
|
|
103
|
-
stage: z.enum(['downloading', 'caching', 'extracting', 'initializing', 'ready']),
|
|
103
|
+
stage: z.enum(['downloading', 'caching', 'extracting', 'initializing', 'ready', 'error']),
|
|
104
104
|
loadedBytes: z.number().optional(),
|
|
105
105
|
totalBytes: z.number().optional(),
|
|
106
106
|
percent: z.number().optional(),
|
|
@@ -259,6 +259,15 @@ export const WorkbenchOptionsSchema = z.object({
|
|
|
259
259
|
mode: z.enum(['guided', 'sandbox']).optional(),
|
|
260
260
|
language: LanguageIdSchema.optional(),
|
|
261
261
|
lang: LanguageIdSchema.optional(),
|
|
262
|
+
showLanguageSelector: z.boolean().optional(),
|
|
263
|
+
sqlDialect: z.enum(['postgres', 'sqlite']).optional(),
|
|
264
|
+
sqlFiles: z.record(z.string(), z.string()).optional(),
|
|
265
|
+
settings: z.record(z.string(), z.any()).optional(),
|
|
266
|
+
userSettings: z.record(z.string(), z.any()).optional(),
|
|
267
|
+
defaultSettings: z.record(z.string(), z.any()).optional(),
|
|
268
|
+
config: z.record(z.string(), z.any()).optional(),
|
|
269
|
+
overrides: z.record(z.string(), z.any()).optional(),
|
|
270
|
+
lockSettings: z.boolean().optional(),
|
|
262
271
|
stepIndex: z.number().int().optional(),
|
|
263
272
|
onStepComplete: z.function({ input: [z.any(), z.number()], output: z.void() }).optional(),
|
|
264
273
|
onLabComplete: z.function({ input: [z.string()], output: z.void() }).optional()
|
package/src/shell.ts
CHANGED
|
@@ -3535,7 +3535,7 @@
|
|
|
3535
3535
|
if (scriptArgs && scriptArgs.length > 0) {
|
|
3536
3536
|
cmd += ' ' + scriptArgs.map(quoteShellArg).join(' ');
|
|
3537
3537
|
}
|
|
3538
|
-
const fallback = tryDevScriptFallback(scriptName, cmd, ctx);
|
|
3538
|
+
const fallback = await tryDevScriptFallback(scriptName, cmd, ctx);
|
|
3539
3539
|
if (fallback) return fallback;
|
|
3540
3540
|
const binPrefix = `${PosixPath.join(ctx.cwd || '/workspace', 'node_modules/.bin')}:/workspace/node_modules/.bin`;
|
|
3541
3541
|
const scriptEnv = {
|
|
@@ -3547,6 +3547,7 @@
|
|
|
3547
3547
|
env: scriptEnv,
|
|
3548
3548
|
stdin: ctx.stdin,
|
|
3549
3549
|
signal: ctx.signal,
|
|
3550
|
+
isBackground: ctx.isBackground,
|
|
3550
3551
|
onStdout: ctx.onStdout,
|
|
3551
3552
|
onStderr: ctx.onStderr,
|
|
3552
3553
|
onRequestStdin: ctx.onRequestStdin || (ctx.shell && ctx.shell.options ? ctx.shell.options.onRequestStdin : undefined)
|
|
@@ -4100,31 +4101,96 @@
|
|
|
4100
4101
|
// Common dev-server commands that cannot run inside the virtual runtime are
|
|
4101
4102
|
// transparently redirected to the built-in preview server.
|
|
4102
4103
|
const PREVIEW_TOOL_RE = /\b(vite|ng|astro|next|webpack|parcel|esbuild|snowpack|react-scripts|serve|http-server)\b/;
|
|
4104
|
+
const NATIVE_DEV_SERVER_RE = /^(vite|ng|astro|next|webpack|parcel|esbuild|snowpack|react-scripts)$/;
|
|
4103
4105
|
// The same tools, when typed directly at the prompt (`ng serve`, `vite`).
|
|
4104
4106
|
// `serve` is omitted: it is a first-class builtin shell command.
|
|
4105
4107
|
const DIRECT_DEV_TOOL_RE = /^(vite|ng|astro|next|webpack|parcel|esbuild|snowpack|react-scripts|http-server)$/;
|
|
4106
4108
|
|
|
4107
|
-
|
|
4109
|
+
/**
|
|
4110
|
+
* Holds a foreground interactive server command open until Ctrl+C (SIGINT)
|
|
4111
|
+
* or external port shutdown, unregistering the port cleanly on interrupt.
|
|
4112
|
+
*/
|
|
4113
|
+
async function waitForForegroundServer(entry, ctx, banner) {
|
|
4114
|
+
const portTable = ctx && ctx.shell ? ctx.shell.portTable : null;
|
|
4115
|
+
const isInteractiveFg = Boolean(ctx && !ctx.isBackground && ctx.signal);
|
|
4116
|
+
if (!isInteractiveFg) {
|
|
4117
|
+
return { code: 0, stdout: banner, stderr: '' };
|
|
4118
|
+
}
|
|
4119
|
+
|
|
4120
|
+
const fullBanner = `${banner.replace(/\n+$/, '')}\n ➜ Press Ctrl+C to stop\n\n`;
|
|
4121
|
+
if (typeof ctx.onStdout === 'function') {
|
|
4122
|
+
ctx.onStdout(fullBanner);
|
|
4123
|
+
}
|
|
4124
|
+
|
|
4125
|
+
const closeServer = () => {
|
|
4126
|
+
if (entry && entry.server && typeof entry.server.close === 'function') {
|
|
4127
|
+
try { entry.server.close(); } catch (err) { _shellLogger.debug('Foreground server close failed.', err); }
|
|
4128
|
+
} else if (portTable && typeof portTable.unregisterServer === 'function' && entry) {
|
|
4129
|
+
try { portTable.unregisterServer(entry.port); } catch (err) { _shellLogger.debug('Foreground server unregister failed.', err); }
|
|
4130
|
+
}
|
|
4131
|
+
};
|
|
4132
|
+
|
|
4133
|
+
if (ctx.signal.aborted) {
|
|
4134
|
+
closeServer();
|
|
4135
|
+
return { code: 130, stdout: fullBanner, stderr: '', alreadyStreamed: typeof ctx.onStdout === 'function', aborted: true };
|
|
4136
|
+
}
|
|
4137
|
+
|
|
4138
|
+
return await new Promise((resolve) => {
|
|
4139
|
+
let settled = false;
|
|
4140
|
+
const cleanup = () => {
|
|
4141
|
+
if (ctx.signal && typeof ctx.signal.removeEventListener === 'function') {
|
|
4142
|
+
try { ctx.signal.removeEventListener('abort', onAbort); } catch (_) { void _; }
|
|
4143
|
+
}
|
|
4144
|
+
if (portTable && typeof portTable.off === 'function') {
|
|
4145
|
+
try { portTable.off('close', onPortClose); } catch (_) { void _; }
|
|
4146
|
+
}
|
|
4147
|
+
};
|
|
4148
|
+
const finish = (code, aborted) => {
|
|
4149
|
+
if (settled) return;
|
|
4150
|
+
settled = true;
|
|
4151
|
+
cleanup();
|
|
4152
|
+
resolve({
|
|
4153
|
+
code,
|
|
4154
|
+
stdout: fullBanner,
|
|
4155
|
+
stderr: '',
|
|
4156
|
+
alreadyStreamed: typeof ctx.onStdout === 'function',
|
|
4157
|
+
aborted
|
|
4158
|
+
});
|
|
4159
|
+
};
|
|
4160
|
+
const onAbort = () => {
|
|
4161
|
+
closeServer();
|
|
4162
|
+
finish(130, true);
|
|
4163
|
+
};
|
|
4164
|
+
const onPortClose = (closedPort, closedEntry) => {
|
|
4165
|
+
if (entry && Number(closedPort) === Number(entry.port) && (!closedEntry || closedEntry === entry)) {
|
|
4166
|
+
finish(0, false);
|
|
4167
|
+
}
|
|
4168
|
+
};
|
|
4169
|
+
ctx.signal.addEventListener('abort', onAbort, { once: true });
|
|
4170
|
+
if (portTable && typeof portTable.on === 'function') {
|
|
4171
|
+
portTable.on('close', onPortClose);
|
|
4172
|
+
}
|
|
4173
|
+
});
|
|
4174
|
+
}
|
|
4175
|
+
|
|
4176
|
+
async function tryDevScriptFallback(scriptName, cmd, ctx, opts) {
|
|
4108
4177
|
if (!PREVIEW_TOOL_RE.test(cmd)) return null;
|
|
4109
|
-
// Only fall back when the referenced tool is not actually installed.
|
|
4110
4178
|
const bin = (cmd.match(PREVIEW_TOOL_RE) || [])[1];
|
|
4111
4179
|
const force = Boolean(opts && opts.force);
|
|
4112
4180
|
const binPath = PosixPath.join('/workspace/node_modules/.bin', bin);
|
|
4113
|
-
|
|
4181
|
+
const isInstalled = ctx.vfs.existsSync(binPath);
|
|
4182
|
+
if (!force && !NATIVE_DEV_SERVER_RE.test(bin) && isInstalled) return null;
|
|
4114
4183
|
const portMatch = cmd.match(/--port(?:=|\s+)(\d+)/);
|
|
4115
4184
|
const defaultPorts = { ng: 4200, vite: 5173, astro: 4321, next: 3000 };
|
|
4116
4185
|
const port = portMatch ? Number(portMatch[1]) : (defaultPorts[bin] || 3000);
|
|
4117
4186
|
const rootDir = typeof ctx.resolvePath === 'function' ? ctx.resolvePath('.') : (ctx.cwd || '/workspace');
|
|
4118
4187
|
const entry = registerPreviewServer(ctx, rootDir, port);
|
|
4119
4188
|
if (!entry) return null;
|
|
4120
|
-
const note = force
|
|
4189
|
+
const note = (force || isInstalled)
|
|
4121
4190
|
? `${bin} is a native dev server and cannot execute inside this virtual runtime — using the CodeLab preview server instead.`
|
|
4122
4191
|
: `${bin} is not available in this virtual runtime — using the CodeLab preview server instead.`;
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
stdout: `\n> ${scriptName}\n> ${cmd}\n\n ${note}\n\n ➜ Local: http://127.0.0.1:${entry.port}/\n\n`,
|
|
4126
|
-
stderr: ''
|
|
4127
|
-
};
|
|
4192
|
+
const banner = `\n> ${scriptName}\n> ${cmd}\n\n ${note}\n\n ➜ Local: http://127.0.0.1:${entry.port}/\n\n`;
|
|
4193
|
+
return await waitForForegroundServer(entry, ctx, banner);
|
|
4128
4194
|
}
|
|
4129
4195
|
|
|
4130
4196
|
function evaluatePosixTest(args, ctx) {
|
|
@@ -7625,6 +7691,33 @@
|
|
|
7625
7691
|
return { code: 0, stdout: 'Python 3.12.8 (CPython WebAssembly via Pyodide)\n', stderr: '' };
|
|
7626
7692
|
}
|
|
7627
7693
|
|
|
7694
|
+
if (args[0] === '-m' && args[1] === 'http.server') {
|
|
7695
|
+
let port = 8000;
|
|
7696
|
+
let dirArg = '.';
|
|
7697
|
+
for (let i = 2; i < args.length; i++) {
|
|
7698
|
+
const a = args[i];
|
|
7699
|
+
if ((a === '-d' || a === '--directory') && args[i + 1]) {
|
|
7700
|
+
dirArg = args[++i];
|
|
7701
|
+
} else if (a.startsWith('--directory=')) {
|
|
7702
|
+
dirArg = a.slice('--directory='.length) || '.';
|
|
7703
|
+
} else if (a === '-b' || a === '--bind') {
|
|
7704
|
+
i++;
|
|
7705
|
+
} else if (/^\d+$/.test(a)) {
|
|
7706
|
+
port = Number(a);
|
|
7707
|
+
}
|
|
7708
|
+
}
|
|
7709
|
+
const rootDir = ctx.resolvePath(dirArg);
|
|
7710
|
+
if (!ctx.vfs.existsSync(rootDir)) {
|
|
7711
|
+
return { code: 1, stdout: '', stderr: `python3: http.server: ${dirArg}: No such file or directory\n` };
|
|
7712
|
+
}
|
|
7713
|
+
const entry = registerPreviewServer(ctx, rootDir, port);
|
|
7714
|
+
if (!entry) {
|
|
7715
|
+
return { code: 1, stdout: '', stderr: 'python3: http.server: no virtual port table available\n' };
|
|
7716
|
+
}
|
|
7717
|
+
const banner = `Serving HTTP on 127.0.0.1 port ${entry.port} (http://127.0.0.1:${entry.port}/) ...\n`;
|
|
7718
|
+
return await waitForForegroundServer(entry, ctx, banner);
|
|
7719
|
+
}
|
|
7720
|
+
|
|
7628
7721
|
const pyCompiler =
|
|
7629
7722
|
(ctx.shell && ctx.shell.options && ctx.shell.options.pythonCompiler) ||
|
|
7630
7723
|
(typeof globalThis !== 'undefined' && globalThis.__codelabPythonCompiler) ||
|
|
@@ -8249,11 +8342,8 @@
|
|
|
8249
8342
|
if (!entry) {
|
|
8250
8343
|
return { code: 1, stdout: '', stderr: 'serve: no virtual port table available\n' };
|
|
8251
8344
|
}
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
stdout: `\n ⚡ CodeLab preview server\n\n ➜ Local: http://127.0.0.1:${entry.port}/\n ➜ Root: ${rootDir}\n ➜ Preview: open the Web Preview drawer for port ${entry.port}\n\n`,
|
|
8255
|
-
stderr: ''
|
|
8256
|
-
};
|
|
8345
|
+
const banner = `\n ⚡ CodeLab preview server\n\n ➜ Local: http://127.0.0.1:${entry.port}/\n ➜ Root: ${rootDir}\n ➜ Preview: open the Web Preview drawer for port ${entry.port}\n\n`;
|
|
8346
|
+
return await waitForForegroundServer(entry, ctx, banner);
|
|
8257
8347
|
},
|
|
8258
8348
|
|
|
8259
8349
|
// -----------------------------------------------------------------------
|
|
@@ -10414,6 +10504,8 @@
|
|
|
10414
10504
|
vfs: this.vfs,
|
|
10415
10505
|
portTable: this.portTable,
|
|
10416
10506
|
gitState: this.gitState,
|
|
10507
|
+
_initialBootRoot: this._initialBootRoot,
|
|
10508
|
+
_initialBootSnapshot: this._initialBootSnapshot,
|
|
10417
10509
|
env: Object.assign({}, this.env, innerCtx.env || {})
|
|
10418
10510
|
});
|
|
10419
10511
|
subShell.cwd = innerCtx.cwd || this.cwd;
|
|
@@ -10736,6 +10828,7 @@
|
|
|
10736
10828
|
res = await this.commands[cmdName](args, cmdCtx);
|
|
10737
10829
|
if (cmdName === 'export' || cmdName === 'unset' || cmdName === 'cd' || cmdName === 'read') {
|
|
10738
10830
|
for (const k of Object.keys(context.env)) {
|
|
10831
|
+
if (/^(\d+|#|@|\*)$/.test(k)) continue;
|
|
10739
10832
|
if (!(k in this.env)) delete context.env[k];
|
|
10740
10833
|
}
|
|
10741
10834
|
Object.assign(context.env, this.env);
|
|
@@ -10803,7 +10896,7 @@
|
|
|
10803
10896
|
// this runtime — whether or not it was installed — so route it to the
|
|
10804
10897
|
// built-in preview server rather than reporting a misleading "command
|
|
10805
10898
|
// not found".
|
|
10806
|
-
const fb = tryDevScriptFallback(cmdName, [cmdName, ...args].join(' '), cmdCtx, { force: true });
|
|
10899
|
+
const fb = await tryDevScriptFallback(cmdName, [cmdName, ...args].join(' '), cmdCtx, { force: true });
|
|
10807
10900
|
res = fb || { code: 127, stdout: '', stderr: `shell: ${cmdName}: command not found\n` };
|
|
10808
10901
|
} else if (typeof this.options.onProcessSpawn === 'function') {
|
|
10809
10902
|
const spawned = await this.options.onProcessSpawn(cmdName, args, {
|
package/src/terminal.ts
CHANGED
|
@@ -1008,7 +1008,7 @@
|
|
|
1008
1008
|
return;
|
|
1009
1009
|
}
|
|
1010
1010
|
|
|
1011
|
-
if (key === 'Home' || (
|
|
1011
|
+
if (key === 'Home' || (e.ctrlKey && !e.metaKey && (key === 'a' || key === 'A'))) {
|
|
1012
1012
|
if (e.preventDefault) e.preventDefault();
|
|
1013
1013
|
this.cursor = 0;
|
|
1014
1014
|
this.updateActiveLine();
|
|
@@ -1141,9 +1141,10 @@
|
|
|
1141
1141
|
this.buffer = this.buffer.slice(0, this.cursor) + seg + this.buffer.slice(this.cursor);
|
|
1142
1142
|
this.cursor = this.buffer.length;
|
|
1143
1143
|
this.submitLine();
|
|
1144
|
-
while (this.isCommandRunning()) {
|
|
1144
|
+
while (this._mounted && this.isCommandRunning()) {
|
|
1145
1145
|
await new Promise((r) => setTimeout(r, 10));
|
|
1146
1146
|
}
|
|
1147
|
+
if (!this._mounted) return;
|
|
1147
1148
|
} else if (seg.length > 0) {
|
|
1148
1149
|
this.buffer = seg;
|
|
1149
1150
|
this.cursor = seg.length;
|
|
@@ -1379,6 +1380,7 @@
|
|
|
1379
1380
|
parseAnsiToHtml,
|
|
1380
1381
|
escapeHtml,
|
|
1381
1382
|
ANSI_CODE_MAP,
|
|
1383
|
+
ansi256ToColor,
|
|
1382
1384
|
resolveAnsiControlCodes
|
|
1383
1385
|
};
|
|
1384
1386
|
});
|