@innovatorved/code-lab 0.7.1 → 0.7.2

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.
Files changed (71) hide show
  1. package/ARCHITECTURE.md +2 -2
  2. package/CHANGELOG.md +10 -0
  3. package/README.md +5 -5
  4. package/dist/code-lab-sql.esm.js +2 -2
  5. package/dist/code-lab-sql.umd.js +3 -3
  6. package/dist/code-lab.css +1 -1
  7. package/dist/code-lab.d.ts +47 -38
  8. package/dist/code-lab.esm.js +918 -884
  9. package/dist/code-lab.js +917 -881
  10. package/dist/extensions/cpp.esm.js +33 -33
  11. package/dist/extensions/cpp.js +33 -33
  12. package/dist/extensions/python.esm.js +79 -49
  13. package/dist/extensions/python.js +79 -49
  14. package/dist/index.d.ts +1 -1
  15. package/dist/logger.d.ts +4 -20
  16. package/dist/modular-kernel.d.ts +0 -1
  17. package/dist/packages/core/src/errors.d.ts +5 -1
  18. package/dist/packages/fs/src/backends.d.ts +0 -27
  19. package/dist/packages/fs/src/index.d.ts +1 -1
  20. package/dist/packages/ui/src/html.d.ts +1 -0
  21. package/dist/packages/ui/src/index.d.ts +1 -0
  22. package/dist/{apps/web/src/index.d.ts → packages/ui/src/kernel.d.ts} +3 -2
  23. package/dist/packages/ui/src/observability.d.ts +1 -1
  24. package/dist/packages/ui/src/settings-dialog.d.ts +0 -1
  25. package/dist/preview-sw.js +1 -1
  26. package/dist/runtime.d.ts +3 -0
  27. package/dist/runtime.esm.js +2 -2
  28. package/dist/runtime.js +2 -2
  29. package/dist/schemas.d.ts +1 -1
  30. package/dist/shell.esm.js +277 -285
  31. package/dist/shell.js +277 -285
  32. package/dist/terminal.esm.js +2 -2
  33. package/dist/terminal.js +2 -2
  34. package/dist/workbench/editor.d.ts +0 -4
  35. package/dist/workbench/index.d.ts +0 -2
  36. package/dist/workbench/intellisense.d.ts +0 -1
  37. package/dist/workbench/xterm-adapter.d.ts +0 -1
  38. package/package.json +2 -4
  39. package/src/code-lab.css +0 -8086
  40. package/src/csp.ts +0 -590
  41. package/src/diagnostics.ts +0 -287
  42. package/src/extensions/cpp.ts +0 -2371
  43. package/src/extensions/guided-lab.ts +0 -68
  44. package/src/extensions/javascript.ts +0 -54
  45. package/src/extensions/python.ts +0 -1743
  46. package/src/extensions/typescript.ts +0 -85
  47. package/src/extensions/umbrella.ts +0 -5
  48. package/src/html.ts +0 -88
  49. package/src/index.ts +0 -129
  50. package/src/logger.ts +0 -139
  51. package/src/modular-kernel.ts +0 -7
  52. package/src/preview-sw.js +0 -296
  53. package/src/runtime/test-harness.ts +0 -57
  54. package/src/runtime.ts +0 -10565
  55. package/src/sample.html +0 -304
  56. package/src/schemas.ts +0 -366
  57. package/src/scm.ts +0 -2453
  58. package/src/search.ts +0 -433
  59. package/src/shell.ts +0 -10990
  60. package/src/storage.ts +0 -773
  61. package/src/terminal.ts +0 -1402
  62. package/src/workbench/command-palette.ts +0 -101
  63. package/src/workbench/diff-editor.ts +0 -472
  64. package/src/workbench/editor.ts +0 -49
  65. package/src/workbench/icons.ts +0 -255
  66. package/src/workbench/index.ts +0 -29
  67. package/src/workbench/intellisense.ts +0 -1884
  68. package/src/workbench/share.ts +0 -128
  69. package/src/workbench/xterm-adapter.ts +0 -1571
  70. package/src/workbench.ts +0 -21825
  71. package/src/zip.ts +0 -348
@@ -1,287 +0,0 @@
1
- /**
2
- * @innovatorved/code-lab — Unified Diagnostics & Problems Aggregator Store
3
- * ============================================================================
4
- * Aggregates diagnostics from Monaco TypeScript/JavaScript workers, runtime
5
- * execution exceptions, preview errors, and linters into a reactive store
6
- * driving editor markers and the bottom drawer Problems panel.
7
- *
8
- * Strict leaf module: fully typed, zero explicit any, zero empty catches.
9
- */
10
-
11
- export type DiagnosticSeverity = 'error' | 'warning' | 'info' | 'hint';
12
-
13
- export interface DiagnosticItem {
14
- id: string;
15
- file: string;
16
- line: number;
17
- col?: number;
18
- column?: number;
19
- endLine?: number;
20
- endCol?: number;
21
- endColumn?: number;
22
- message: string;
23
- severity: DiagnosticSeverity;
24
- source?: string;
25
- code?: string | number;
26
- tags?: string[];
27
- }
28
-
29
- export type DiagnosticListener = (items: DiagnosticItem[]) => void;
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
-
49
- export class DiagnosticsStore {
50
- private readonly items: Map<string, DiagnosticItem> = new Map();
51
- private readonly listeners: Set<DiagnosticListener> = new Set();
52
- private batchDepth = 0;
53
- private batchDirty = false;
54
-
55
- private normalizeItem(item: DiagnosticItem): DiagnosticItem | null {
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);
70
- return {
71
- ...item,
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 } : {}),
79
- message: String(item.message || ''),
80
- severity: item.severity || 'error'
81
- };
82
- }
83
-
84
- public add(item: DiagnosticItem): void {
85
- const normalized = this.normalizeItem(item);
86
- if (!normalized) return;
87
- this.items.set(normalized.id, normalized);
88
- this.notify();
89
- }
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
-
188
- public setMany(items: ReadonlyArray<DiagnosticItem>, clearSource?: string): void {
189
- this.batch(() => {
190
- if (clearSource !== undefined) {
191
- this.clear(clearSource);
192
- }
193
- for (const item of items) {
194
- const normalized = this.normalizeItem(item);
195
- if (normalized) {
196
- this.items.set(normalized.id, normalized);
197
- this.batchDirty = true;
198
- }
199
- }
200
- });
201
- }
202
-
203
- public batch(fn: () => void): void {
204
- this.batchDepth++;
205
- try {
206
- fn();
207
- } finally {
208
- this.batchDepth--;
209
- if (this.batchDepth === 0 && this.batchDirty) {
210
- this.batchDirty = false;
211
- this.notify();
212
- }
213
- }
214
- }
215
-
216
- public remove(id: string): void {
217
- if (this.items.delete(id)) {
218
- this.notify();
219
- }
220
- }
221
-
222
- public clear(source?: string): void {
223
- if (source !== undefined && source !== '') {
224
- let changed = false;
225
- for (const [id, item] of this.items.entries()) {
226
- if (item.source === source) {
227
- this.items.delete(id);
228
- changed = true;
229
- }
230
- }
231
- if (changed) {
232
- this.notify();
233
- }
234
- } else if (this.items.size > 0) {
235
- this.items.clear();
236
- this.notify();
237
- }
238
- }
239
-
240
- public getAll(): DiagnosticItem[] {
241
- return Array.from(this.items.values());
242
- }
243
-
244
- public getByFile(file: string): DiagnosticItem[] {
245
- const normalizedTarget = normalizeDiagnosticFilePath(file);
246
- const out: DiagnosticItem[] = [];
247
- for (const item of this.items.values()) {
248
- if (item.file === normalizedTarget || item.file === file) {
249
- out.push(item);
250
- }
251
- }
252
- return out;
253
- }
254
-
255
- public subscribe(listener: DiagnosticListener): () => void {
256
- this.listeners.add(listener);
257
- return () => {
258
- this.listeners.delete(listener);
259
- };
260
- }
261
-
262
- private notify(): void {
263
- if (this.batchDepth > 0) {
264
- this.batchDirty = true;
265
- return;
266
- }
267
- if (this.listeners.size === 0) return;
268
- const snapshot = this.getAll();
269
- for (const listener of this.listeners) {
270
- try {
271
- listener(snapshot);
272
- } catch (err) {
273
- console.warn('[code-lab] diagnostics subscriber error:', err);
274
- }
275
- }
276
- }
277
- }
278
-
279
- export function createDiagnosticsStore(): DiagnosticsStore {
280
- return new DiagnosticsStore();
281
- }
282
-
283
- export default {
284
- DiagnosticsStore,
285
- createDiagnosticsStore,
286
- normalizeDiagnosticFilePath
287
- };