@innovatorved/code-lab 0.4.0 → 0.5.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 +2 -2
- package/CHANGELOG.md +21 -0
- package/README.md +4 -28
- package/dist/code-lab-sql.esm.js +1 -1
- package/dist/code-lab-sql.umd.js +2 -2
- package/dist/code-lab.css +1553 -98
- package/dist/code-lab.d.ts +1 -1
- package/dist/code-lab.esm.js +11883 -1619
- package/dist/code-lab.js +11882 -1618
- package/dist/code-lab.umd.js +11882 -1618
- package/dist/diagnostics.d.ts +3 -0
- package/dist/extensions/cpp.esm.js +27 -29
- package/dist/extensions/cpp.js +27 -29
- package/dist/extensions/python.esm.js +27 -28
- package/dist/extensions/python.js +27 -28
- package/dist/index.d.ts +1 -1
- package/dist/packages/settings/src/configuration-service.d.ts +7 -0
- package/dist/packages/settings/src/index.d.ts +1 -1
- package/dist/packages/ui/src/index.d.ts +2 -2
- package/dist/packages/ui/src/plugin-registry.d.ts +1 -0
- package/dist/packages/ui/src/settings-dialog.d.ts +31 -3
- package/dist/packages/ui/src/themes.d.ts +5 -0
- package/dist/preview-sw.js +1 -1
- package/dist/runtime.esm.js +1 -1
- package/dist/runtime.js +1 -1
- package/dist/schemas.d.ts +1 -1
- package/dist/scm.d.ts +92 -11
- package/dist/shell.esm.js +937 -113
- package/dist/shell.js +937 -113
- package/dist/storage.d.ts +47 -0
- package/dist/terminal.esm.js +1 -1
- package/dist/terminal.js +1 -1
- package/dist/workbench/index.d.ts +1 -1
- package/dist/workbench/styles.d.ts +1 -1
- package/package.json +2 -2
- package/packages/commands/package.json +1 -1
- package/packages/core/package.json +1 -1
- package/packages/editor/package.json +1 -1
- package/packages/fs/package.json +1 -1
- package/packages/preview/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/settings/package.json +1 -1
- package/packages/settings/src/builtin-schemas.ts +17 -6
- package/packages/settings/src/configuration-service.ts +72 -6
- package/packages/settings/src/index.ts +1 -0
- package/packages/sql/package.json +1 -1
- package/packages/terminal/package.json +1 -1
- package/packages/ui/package.json +1 -1
- package/packages/ui/src/index.ts +4 -0
- package/packages/ui/src/plugin-registry.ts +17 -2
- package/packages/ui/src/settings-dialog.ts +374 -92
- package/packages/ui/src/themes.ts +105 -12
- package/src/code-lab.css +1553 -98
- package/src/diagnostics.ts +139 -7
- package/src/extensions/cpp.ts +33 -33
- package/src/extensions/python.ts +33 -32
- package/src/index.ts +1 -1
- package/src/schemas.ts +1 -1
- package/src/scm.ts +781 -58
- package/src/shell.ts +936 -112
- package/src/storage.ts +336 -3
- package/src/workbench/icons.ts +8 -1
- package/src/workbench/styles.ts +25 -19
- package/src/workbench.ts +12010 -3814
package/src/diagnostics.ts
CHANGED
|
@@ -28,6 +28,24 @@ export interface DiagnosticItem {
|
|
|
28
28
|
|
|
29
29
|
export type DiagnosticListener = (items: DiagnosticItem[]) => void;
|
|
30
30
|
|
|
31
|
+
export function normalizeDiagnosticFilePath(rawFile: string): string {
|
|
32
|
+
let p = String(rawFile || '').trim().replace(/\\/g, '/');
|
|
33
|
+
while (p.startsWith('./')) {
|
|
34
|
+
p = p.slice(2);
|
|
35
|
+
}
|
|
36
|
+
if (!p || p === '/workspace' || p === '/workspace/') return '';
|
|
37
|
+
if (p.startsWith('/workspace/')) {
|
|
38
|
+
p = p.slice('/workspace/'.length);
|
|
39
|
+
}
|
|
40
|
+
while (p.startsWith('./')) {
|
|
41
|
+
p = p.slice(2);
|
|
42
|
+
}
|
|
43
|
+
if (p.startsWith('/')) {
|
|
44
|
+
p = p.replace(/^\/+/, '');
|
|
45
|
+
}
|
|
46
|
+
return p;
|
|
47
|
+
}
|
|
48
|
+
|
|
31
49
|
export class DiagnosticsStore {
|
|
32
50
|
private readonly items: Map<string, DiagnosticItem> = new Map();
|
|
33
51
|
private readonly listeners: Set<DiagnosticListener> = new Set();
|
|
@@ -36,13 +54,28 @@ export class DiagnosticsStore {
|
|
|
36
54
|
|
|
37
55
|
private normalizeItem(item: DiagnosticItem): DiagnosticItem | null {
|
|
38
56
|
if (!item || typeof item.id !== 'string' || !item.id) return null;
|
|
57
|
+
const col = typeof item.col === 'number' && Number.isFinite(item.col) && item.col > 0
|
|
58
|
+
? Math.floor(item.col)
|
|
59
|
+
: (typeof item.column === 'number' && Number.isFinite(item.column) && item.column > 0
|
|
60
|
+
? Math.floor(item.column)
|
|
61
|
+
: 1);
|
|
62
|
+
const endLine = typeof item.endLine === 'number' && Number.isFinite(item.endLine) && item.endLine > 0
|
|
63
|
+
? Math.floor(item.endLine)
|
|
64
|
+
: undefined;
|
|
65
|
+
const endCol = typeof item.endCol === 'number' && Number.isFinite(item.endCol) && item.endCol > 0
|
|
66
|
+
? Math.floor(item.endCol)
|
|
67
|
+
: (typeof item.endColumn === 'number' && Number.isFinite(item.endColumn) && item.endColumn > 0
|
|
68
|
+
? Math.floor(item.endColumn)
|
|
69
|
+
: undefined);
|
|
39
70
|
return {
|
|
40
71
|
...item,
|
|
41
|
-
file:
|
|
42
|
-
line: typeof item.line === 'number' && item.line
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
72
|
+
file: normalizeDiagnosticFilePath(item.file || ''),
|
|
73
|
+
line: typeof item.line === 'number' && Number.isFinite(item.line) && item.line > 0
|
|
74
|
+
? Math.floor(item.line)
|
|
75
|
+
: 1,
|
|
76
|
+
col,
|
|
77
|
+
...(endLine !== undefined ? { endLine } : {}),
|
|
78
|
+
...(endCol !== undefined ? { endCol } : {}),
|
|
46
79
|
message: String(item.message || ''),
|
|
47
80
|
severity: item.severity || 'error'
|
|
48
81
|
};
|
|
@@ -55,6 +88,103 @@ export class DiagnosticsStore {
|
|
|
55
88
|
this.notify();
|
|
56
89
|
}
|
|
57
90
|
|
|
91
|
+
public setFileDiagnostics(
|
|
92
|
+
file: string,
|
|
93
|
+
sourceOrDiags: string | ReadonlyArray<Partial<DiagnosticItem>>,
|
|
94
|
+
diagsOrSource?: ReadonlyArray<Partial<DiagnosticItem>> | string
|
|
95
|
+
): DiagnosticItem[] {
|
|
96
|
+
const normalizedFile = normalizeDiagnosticFilePath(file);
|
|
97
|
+
let resolvedSource: string;
|
|
98
|
+
let rawDiags: ReadonlyArray<Partial<DiagnosticItem>>;
|
|
99
|
+
|
|
100
|
+
if (typeof sourceOrDiags === 'string') {
|
|
101
|
+
resolvedSource = sourceOrDiags || 'diagnostics';
|
|
102
|
+
rawDiags = Array.isArray(diagsOrSource) ? diagsOrSource : [];
|
|
103
|
+
} else if (Array.isArray(sourceOrDiags)) {
|
|
104
|
+
rawDiags = sourceOrDiags;
|
|
105
|
+
resolvedSource =
|
|
106
|
+
typeof diagsOrSource === 'string' && diagsOrSource ? diagsOrSource : 'diagnostics';
|
|
107
|
+
} else {
|
|
108
|
+
resolvedSource =
|
|
109
|
+
typeof diagsOrSource === 'string' && diagsOrSource ? diagsOrSource : 'diagnostics';
|
|
110
|
+
rawDiags = [];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
let changed = false;
|
|
114
|
+
for (const [existingId, existingItem] of this.items.entries()) {
|
|
115
|
+
if (existingItem.file === normalizedFile && existingItem.source === resolvedSource) {
|
|
116
|
+
this.items.delete(existingId);
|
|
117
|
+
changed = true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const inserted: DiagnosticItem[] = [];
|
|
122
|
+
for (let idx = 0; idx < rawDiags.length; idx++) {
|
|
123
|
+
const d = rawDiags[idx];
|
|
124
|
+
if (!d || typeof d !== 'object') continue;
|
|
125
|
+
|
|
126
|
+
const line =
|
|
127
|
+
typeof d.line === 'number' && Number.isFinite(d.line) && d.line > 0
|
|
128
|
+
? Math.floor(d.line)
|
|
129
|
+
: 1;
|
|
130
|
+
const col =
|
|
131
|
+
typeof d.col === 'number' && Number.isFinite(d.col) && d.col > 0
|
|
132
|
+
? Math.floor(d.col)
|
|
133
|
+
: (typeof d.column === 'number' && Number.isFinite(d.column) && d.column > 0
|
|
134
|
+
? Math.floor(d.column)
|
|
135
|
+
: 1);
|
|
136
|
+
const endLine =
|
|
137
|
+
typeof d.endLine === 'number' && Number.isFinite(d.endLine) && d.endLine > 0
|
|
138
|
+
? Math.floor(d.endLine)
|
|
139
|
+
: undefined;
|
|
140
|
+
const rawEndCol =
|
|
141
|
+
typeof d.endCol === 'number' && Number.isFinite(d.endCol) && d.endCol > 0
|
|
142
|
+
? Math.floor(d.endCol)
|
|
143
|
+
: (typeof d.endColumn === 'number' && Number.isFinite(d.endColumn) && d.endColumn > 0
|
|
144
|
+
? Math.floor(d.endColumn)
|
|
145
|
+
: undefined);
|
|
146
|
+
const severity: DiagnosticSeverity =
|
|
147
|
+
d.severity === 'error' ||
|
|
148
|
+
d.severity === 'warning' ||
|
|
149
|
+
d.severity === 'info' ||
|
|
150
|
+
d.severity === 'hint'
|
|
151
|
+
? d.severity
|
|
152
|
+
: 'error';
|
|
153
|
+
const message = String(d.message ?? '');
|
|
154
|
+
const candidateId = typeof d.id === 'string' && d.id.trim() ? d.id.trim() : '';
|
|
155
|
+
const id =
|
|
156
|
+
candidateId && !this.items.has(candidateId)
|
|
157
|
+
? candidateId
|
|
158
|
+
: `${resolvedSource}:${normalizedFile}:${candidateId || `${line}:${col}`}:${idx}`;
|
|
159
|
+
|
|
160
|
+
const normalized: DiagnosticItem = {
|
|
161
|
+
id,
|
|
162
|
+
file: normalizedFile,
|
|
163
|
+
source: resolvedSource,
|
|
164
|
+
severity,
|
|
165
|
+
message,
|
|
166
|
+
line,
|
|
167
|
+
col,
|
|
168
|
+
...(d.column !== undefined ? { column: col } : {}),
|
|
169
|
+
...(endLine !== undefined ? { endLine } : {}),
|
|
170
|
+
...(rawEndCol !== undefined ? { endCol: rawEndCol } : {}),
|
|
171
|
+
...(d.endColumn !== undefined && rawEndCol !== undefined ? { endColumn: rawEndCol } : {}),
|
|
172
|
+
...(d.code !== undefined ? { code: d.code } : {}),
|
|
173
|
+
...(Array.isArray(d.tags) ? { tags: [...d.tags] } : {})
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
this.items.set(id, normalized);
|
|
177
|
+
inserted.push(normalized);
|
|
178
|
+
changed = true;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (changed) {
|
|
182
|
+
this.notify();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return inserted;
|
|
186
|
+
}
|
|
187
|
+
|
|
58
188
|
public setMany(items: ReadonlyArray<DiagnosticItem>, clearSource?: string): void {
|
|
59
189
|
this.batch(() => {
|
|
60
190
|
if (clearSource !== undefined) {
|
|
@@ -112,9 +242,10 @@ export class DiagnosticsStore {
|
|
|
112
242
|
}
|
|
113
243
|
|
|
114
244
|
public getByFile(file: string): DiagnosticItem[] {
|
|
245
|
+
const normalizedTarget = normalizeDiagnosticFilePath(file);
|
|
115
246
|
const out: DiagnosticItem[] = [];
|
|
116
247
|
for (const item of this.items.values()) {
|
|
117
|
-
if (item.file === file) {
|
|
248
|
+
if (item.file === normalizedTarget || item.file === file) {
|
|
118
249
|
out.push(item);
|
|
119
250
|
}
|
|
120
251
|
}
|
|
@@ -151,5 +282,6 @@ export function createDiagnosticsStore(): DiagnosticsStore {
|
|
|
151
282
|
|
|
152
283
|
export default {
|
|
153
284
|
DiagnosticsStore,
|
|
154
|
-
createDiagnosticsStore
|
|
285
|
+
createDiagnosticsStore,
|
|
286
|
+
normalizeDiagnosticFilePath
|
|
155
287
|
};
|
package/src/extensions/cpp.ts
CHANGED
|
@@ -2036,39 +2036,39 @@ export function installCppExtension(workbench: any, options: ExtendedCppExtensio
|
|
|
2036
2036
|
|
|
2037
2037
|
workbench.hasMultipleLanguages = workbench.enabledLanguages.size > 1;
|
|
2038
2038
|
|
|
2039
|
-
//
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
const
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
}
|
|
2070
|
-
}
|
|
2071
|
-
}
|
|
2039
|
+
// Synchronous static C++ linter (resolves _diagnosticsStore dynamically)
|
|
2040
|
+
workbench._cppLintHandler = (file: string, code: string) => {
|
|
2041
|
+
if (!file || !/\.(?:cpp|cc|cxx|hpp|h)$/i.test(file)) return;
|
|
2042
|
+
const diags = analyzeCppSource(String(code ?? ''), file, workbench ? workbench.vfs : undefined);
|
|
2043
|
+
const store = workbench ? workbench._diagnosticsStore : null;
|
|
2044
|
+
if (store && typeof store.setFileDiagnostics === 'function') {
|
|
2045
|
+
store.setFileDiagnostics(file, 'cpp-linter', diags);
|
|
2046
|
+
} else if (store && typeof store.clear === 'function' && typeof store.add === 'function') {
|
|
2047
|
+
store.clear('cpp-linter');
|
|
2048
|
+
for (const d of diags) {
|
|
2049
|
+
store.add(d);
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
if (typeof window !== 'undefined' && (window as any).monaco) {
|
|
2053
|
+
const model =
|
|
2054
|
+
(workbench.models && typeof workbench.models.get === 'function' && workbench.models.get(file)) ||
|
|
2055
|
+
(workbench.activeFile === file && workbench.editor ? workbench.editor.getModel() : null);
|
|
2056
|
+
if (model) {
|
|
2057
|
+
const markers = diags.map((d) => ({
|
|
2058
|
+
startLineNumber: d.line,
|
|
2059
|
+
startColumn: d.col || 1,
|
|
2060
|
+
endLineNumber: d.endLine || d.line,
|
|
2061
|
+
endColumn: d.endCol || (d.col || 1) + 20,
|
|
2062
|
+
message: d.message,
|
|
2063
|
+
severity:
|
|
2064
|
+
d.severity === 'error'
|
|
2065
|
+
? (window as any).monaco.MarkerSeverity.Error
|
|
2066
|
+
: (window as any).monaco.MarkerSeverity.Warning
|
|
2067
|
+
}));
|
|
2068
|
+
(window as any).monaco.editor.setModelMarkers(model, 'cpp-linter', markers);
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
};
|
|
2072
2072
|
|
|
2073
2073
|
if (options.preload) {
|
|
2074
2074
|
toolchain.ensureLoaded().catch((err) => {
|
package/src/extensions/python.ts
CHANGED
|
@@ -1348,38 +1348,39 @@ function installPythonExtension(workbench: any, options: ExtendedPythonExtension
|
|
|
1348
1348
|
|
|
1349
1349
|
workbench.hasMultipleLanguages = workbench.enabledLanguages.size > 1;
|
|
1350
1350
|
|
|
1351
|
-
//
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1351
|
+
// Synchronous static syntax & traceback linter (resolves _diagnosticsStore dynamically)
|
|
1352
|
+
workbench._pyLintHandler = (file: string, code: string) => {
|
|
1353
|
+
if (!file || !/\.py$/i.test(file)) return;
|
|
1354
|
+
const diags = analyzePythonSource(String(code ?? ''), file);
|
|
1355
|
+
const store = workbench ? workbench._diagnosticsStore : null;
|
|
1356
|
+
if (store && typeof store.setFileDiagnostics === 'function') {
|
|
1357
|
+
store.setFileDiagnostics(file, 'python-linter', diags);
|
|
1358
|
+
} else if (store && typeof store.clear === 'function' && typeof store.add === 'function') {
|
|
1359
|
+
store.clear('python-linter');
|
|
1360
|
+
for (const d of diags) {
|
|
1361
|
+
store.add(d);
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
if (typeof window !== 'undefined' && (window as any).monaco) {
|
|
1365
|
+
const model =
|
|
1366
|
+
(workbench.models && typeof workbench.models.get === 'function' && workbench.models.get(file)) ||
|
|
1367
|
+
(workbench.activeFile === file && workbench.editor ? workbench.editor.getModel() : null);
|
|
1368
|
+
if (model) {
|
|
1369
|
+
const markers = diags.map((d) => ({
|
|
1370
|
+
startLineNumber: d.line,
|
|
1371
|
+
startColumn: d.col || 1,
|
|
1372
|
+
endLineNumber: d.endLine || d.line,
|
|
1373
|
+
endColumn: d.endCol || (d.col || 1) + 20,
|
|
1374
|
+
message: d.message,
|
|
1375
|
+
severity:
|
|
1376
|
+
d.severity === 'error'
|
|
1377
|
+
? (window as any).monaco.MarkerSeverity.Error
|
|
1378
|
+
: (window as any).monaco.MarkerSeverity.Warning
|
|
1379
|
+
}));
|
|
1380
|
+
(window as any).monaco.editor.setModelMarkers(model, 'python-linter', markers);
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
};
|
|
1383
1384
|
|
|
1384
1385
|
if (options.preload) {
|
|
1385
1386
|
toolchain.ensureLoaded().catch((err) => {
|
package/src/index.ts
CHANGED
package/src/schemas.ts
CHANGED