@innovatorved/code-lab 0.7.0 → 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.
Files changed (129) hide show
  1. package/ARCHITECTURE.md +2 -2
  2. package/CHANGELOG.md +20 -0
  3. package/README.md +2 -2
  4. package/dist/apps/web/src/index.d.ts +0 -9
  5. package/dist/code-lab-sql.esm.js +19 -19
  6. package/dist/code-lab-sql.umd.js +20 -20
  7. package/dist/code-lab.css +1 -1
  8. package/dist/code-lab.d.ts +1 -1
  9. package/dist/code-lab.esm.js +679 -1439
  10. package/dist/code-lab.js +678 -1438
  11. package/dist/extensions/cpp.esm.js +132 -8760
  12. package/dist/extensions/cpp.js +124 -8770
  13. package/dist/extensions/guided-lab.esm.js +33 -6836
  14. package/dist/extensions/guided-lab.js +33 -6854
  15. package/dist/extensions/javascript.esm.js +1 -36
  16. package/dist/extensions/javascript.js +1 -58
  17. package/dist/extensions/python.esm.js +79 -8118
  18. package/dist/extensions/python.js +79 -8136
  19. package/dist/extensions/typescript.esm.js +1 -55
  20. package/dist/extensions/typescript.js +1 -77
  21. package/dist/modular-kernel.d.ts +0 -4
  22. package/dist/preview-sw.js +1 -1
  23. package/dist/runtime.esm.js +77 -77
  24. package/dist/runtime.js +77 -77
  25. package/dist/schemas.d.ts +9 -0
  26. package/dist/schemas.esm.js +33 -6815
  27. package/dist/schemas.js +33 -6831
  28. package/dist/shell.esm.js +33 -33
  29. package/dist/shell.js +33 -33
  30. package/dist/terminal.esm.js +8 -6
  31. package/dist/terminal.js +6 -6
  32. package/dist/workbench/command-palette.d.ts +0 -4
  33. package/dist/workbench/index.d.ts +0 -20
  34. package/dist/workbench/intellisense.d.ts +1 -7
  35. package/package.json +3 -10
  36. package/src/code-lab.css +4 -502
  37. package/src/extensions/cpp.ts +11 -29
  38. package/src/extensions/guided-lab.ts +6 -2
  39. package/src/extensions/python.ts +9 -3
  40. package/src/modular-kernel.ts +0 -4
  41. package/src/runtime.ts +124 -39
  42. package/src/schemas.ts +2 -2
  43. package/src/shell.ts +3 -0
  44. package/src/terminal.ts +4 -2
  45. package/src/workbench/command-palette.ts +22 -302
  46. package/src/workbench/diff-editor.ts +2 -0
  47. package/src/workbench/icons.ts +1 -1
  48. package/src/workbench/index.ts +0 -15
  49. package/src/workbench/intellisense.ts +17 -4
  50. package/src/workbench.ts +68 -375
  51. package/dist/code-lab.umd.js +0 -6117
  52. package/dist/packages/editor/src/index.d.ts +0 -118
  53. package/dist/packages/preview/src/index.d.ts +0 -34
  54. package/dist/packages/runtime/src/index.d.ts +0 -47
  55. package/dist/packages/terminal/src/index.d.ts +0 -54
  56. package/dist/workbench/drawer.d.ts +0 -18
  57. package/dist/workbench/file-tree.d.ts +0 -11
  58. package/dist/workbench/guided-pane.d.ts +0 -11
  59. package/dist/workbench/styles.d.ts +0 -4
  60. package/dist/workbench/toolbar.d.ts +0 -17
  61. package/packages/commands/README.md +0 -7
  62. package/packages/commands/package.json +0 -16
  63. package/packages/commands/src/index.ts +0 -467
  64. package/packages/commands/tsconfig.json +0 -22
  65. package/packages/core/README.md +0 -12
  66. package/packages/core/package.json +0 -13
  67. package/packages/core/src/di.ts +0 -147
  68. package/packages/core/src/disposable.ts +0 -112
  69. package/packages/core/src/errors.ts +0 -205
  70. package/packages/core/src/events.ts +0 -157
  71. package/packages/core/src/index.ts +0 -49
  72. package/packages/core/src/path.ts +0 -118
  73. package/packages/core/src/registry.ts +0 -61
  74. package/packages/core/tsconfig.json +0 -19
  75. package/packages/editor/README.md +0 -9
  76. package/packages/editor/package.json +0 -18
  77. package/packages/editor/src/index.ts +0 -344
  78. package/packages/editor/tsconfig.json +0 -24
  79. package/packages/fs/README.md +0 -7
  80. package/packages/fs/package.json +0 -16
  81. package/packages/fs/src/backends.ts +0 -301
  82. package/packages/fs/src/index.ts +0 -18
  83. package/packages/fs/src/types.ts +0 -44
  84. package/packages/fs/src/vfs-service.ts +0 -257
  85. package/packages/fs/tsconfig.json +0 -22
  86. package/packages/preview/README.md +0 -3
  87. package/packages/preview/package.json +0 -16
  88. package/packages/preview/src/index.ts +0 -125
  89. package/packages/preview/tsconfig.json +0 -22
  90. package/packages/runtime/README.md +0 -3
  91. package/packages/runtime/package.json +0 -17
  92. package/packages/runtime/src/index.ts +0 -134
  93. package/packages/runtime/tsconfig.json +0 -23
  94. package/packages/settings/README.md +0 -7
  95. package/packages/settings/package.json +0 -16
  96. package/packages/settings/src/builtin-schemas.ts +0 -262
  97. package/packages/settings/src/configuration-service.ts +0 -609
  98. package/packages/settings/src/index.ts +0 -38
  99. package/packages/settings/src/jsonc.ts +0 -189
  100. package/packages/settings/src/schema.ts +0 -164
  101. package/packages/settings/tsconfig.json +0 -22
  102. package/packages/sql/README.md +0 -12
  103. package/packages/sql/package.json +0 -13
  104. package/packages/sql/src/completions.ts +0 -359
  105. package/packages/sql/src/diagnostics.ts +0 -200
  106. package/packages/sql/src/formatter.ts +0 -271
  107. package/packages/sql/src/index.ts +0 -54
  108. package/packages/sql/src/sql-editor.ts +0 -802
  109. package/packages/sql/src/styles.ts +0 -524
  110. package/packages/sql/src/tokenizer.ts +0 -457
  111. package/packages/sql/src/types.ts +0 -148
  112. package/packages/sql/tsconfig.json +0 -19
  113. package/packages/terminal/README.md +0 -3
  114. package/packages/terminal/package.json +0 -16
  115. package/packages/terminal/src/index.ts +0 -183
  116. package/packages/terminal/tsconfig.json +0 -22
  117. package/packages/ui/README.md +0 -8
  118. package/packages/ui/package.json +0 -18
  119. package/packages/ui/src/index.ts +0 -40
  120. package/packages/ui/src/observability.ts +0 -173
  121. package/packages/ui/src/plugin-registry.ts +0 -289
  122. package/packages/ui/src/settings-dialog.ts +0 -939
  123. package/packages/ui/src/themes.ts +0 -333
  124. package/packages/ui/tsconfig.json +0 -24
  125. package/src/workbench/drawer.ts +0 -157
  126. package/src/workbench/file-tree.ts +0 -51
  127. package/src/workbench/guided-pane.ts +0 -43
  128. package/src/workbench/styles.ts +0 -211
  129. package/src/workbench/toolbar.ts +0 -182
@@ -33,65 +33,64 @@ export function fuzzyScoreText(query: string, candidate: string): FuzzyMatchResu
33
33
  const q = String(query || '').trim();
34
34
  const text = String(candidate || '');
35
35
  if (!q) return { score: 1, indices: [] };
36
- if (!text) return null;
37
36
 
38
37
  const qLower = q.toLowerCase();
39
38
  const tLower = text.toLowerCase();
40
39
 
41
- const indices: number[] = [];
42
40
  let qi = 0;
43
41
  let score = 0;
44
- let prevMatchIdx = -2;
42
+ let consecutive = 0;
43
+ const indices: number[] = [];
45
44
 
46
- for (let ti = 0; ti < text.length && qi < qLower.length; ti++) {
45
+ for (let ti = 0; ti < tLower.length && qi < qLower.length; ti++) {
47
46
  if (tLower[ti] === qLower[qi]) {
48
47
  indices.push(ti);
49
48
  score += 10;
50
49
 
51
- // Consecutive match bonus
52
- if (ti === prevMatchIdx + 1) {
53
- score += 14;
50
+ if (indices.length > 1 && indices[indices.length - 2] === ti - 1) {
51
+ consecutive++;
52
+ score += 12 + consecutive * 4;
53
+ } else {
54
+ consecutive = 0;
54
55
  }
55
- // Prefix match bonus
56
+
56
57
  if (ti === 0) {
57
- score += 18;
58
+ score += 25;
58
59
  } else {
59
60
  const prev = text[ti - 1];
60
61
  const curr = text[ti];
61
- // Path separator / word boundary / camelCase transition bonus
62
- if (prev === '/' || prev === '-' || prev === '_' || prev === ' ' || prev === ':' || prev === '.') {
63
- score += 12;
62
+ if (prev === '/' || prev === '\\' || prev === '-' || prev === '_' || prev === '.' || prev === ' ' || prev === ':') {
63
+ score += 18;
64
64
  } else if (prev >= 'a' && prev <= 'z' && curr >= 'A' && curr <= 'Z') {
65
- score += 10;
65
+ score += 14;
66
66
  }
67
67
  }
68
68
 
69
- prevMatchIdx = ti;
69
+ if (text[ti] === q[qi]) score += 2;
70
70
  qi++;
71
71
  }
72
72
  }
73
73
 
74
74
  if (qi < qLower.length) return null;
75
75
 
76
- // Slightly prefer shorter, tighter matches
77
- score -= Math.min(20, Math.floor((text.length - q.length) * 0.25));
76
+ score -= Math.min(20, Math.floor((text.length - q.length) / 4));
77
+ if (tLower === qLower) score += 100;
78
+ else if (tLower.startsWith(qLower)) score += 45;
79
+
78
80
  return { score, indices };
79
81
  }
80
82
 
81
- /**
82
- * Renders HTML with `<mark class="codelab-palette-hl">` around matched subsequence characters.
83
- */
84
83
  export function renderHighlightedText(text: string, indices: number[]): string {
85
84
  if (!indices || indices.length === 0) return escapeHtml(text);
86
- const matchSet = new Set(indices);
85
+ const set = new Set(indices);
87
86
  let html = '';
88
87
  let inMark = false;
89
88
  for (let i = 0; i < text.length; i++) {
90
- const isHit = matchSet.has(i);
91
- if (isHit && !inMark) {
89
+ const matched = set.has(i);
90
+ if (matched && !inMark) {
92
91
  html += '<mark class="codelab-palette-hl">';
93
92
  inMark = true;
94
- } else if (!isHit && inMark) {
93
+ } else if (!matched && inMark) {
95
94
  html += '</mark>';
96
95
  inMark = false;
97
96
  }
@@ -100,282 +99,3 @@ export function renderHighlightedText(text: string, indices: number[]): string {
100
99
  if (inMark) html += '</mark>';
101
100
  return html;
102
101
  }
103
-
104
- export function getStandardWorkbenchCommands(workbench: any): CommandPaletteItem[] {
105
- const isGuided = Boolean(workbench.hasGuidedLab && workbench.mode === 'guided');
106
-
107
- const commands: CommandPaletteItem[] = [
108
- {
109
- id: 'run-code',
110
- label: isGuided ? 'CodeLab: Verify Current Guided Step' : 'Run: Run Active File',
111
- shortcut: '⌘↵',
112
- action: () => {
113
- if (isGuided) workbench.verifyCurrentStep();
114
- else workbench.runCode();
115
- }
116
- },
117
- {
118
- id: 'run-demo',
119
- label: 'CodeLab: Run Demo Script',
120
- shortcut: '⇧⌘↵',
121
- action: () => workbench.runDemo()
122
- },
123
- {
124
- id: 'run-tests',
125
- label: 'Test: Run Unit Tests',
126
- shortcut: '⌘↵',
127
- action: () => workbench.runTests()
128
- },
129
- {
130
- id: 'format-document',
131
- label: 'Format Document',
132
- category: 'Editor',
133
- shortcut: '⇧⌥F',
134
- action: () => workbench.formatActiveDocument()
135
- },
136
- {
137
- id: 'view-toggle-panel',
138
- label: 'View: Toggle Panel',
139
- shortcut: '⌘J',
140
- action: () => {
141
- if (typeof workbench.togglePanel === 'function') workbench.togglePanel();
142
- else if (typeof workbench.setPanelVisible === 'function') workbench.setPanelVisible(Boolean(workbench._panelCollapsed));
143
- }
144
- },
145
- {
146
- id: 'view-toggle-terminal',
147
- label: 'View: Toggle Terminal',
148
- shortcut: '⌃`',
149
- action: () => {
150
- if (typeof workbench.toggleTerminalPanel === 'function') workbench.toggleTerminalPanel();
151
- else if (typeof workbench.togglePanel === 'function') workbench.togglePanel('terminal');
152
- }
153
- },
154
- {
155
- id: 'view-toggle-sidebar',
156
- label: 'View: Toggle Primary Side Bar',
157
- shortcut: '⌘B',
158
- action: () => {
159
- if (typeof workbench.togglePrimarySidebar === 'function') workbench.togglePrimarySidebar();
160
- }
161
- },
162
- {
163
- id: 'terminal-new',
164
- label: 'Terminal: Create New Terminal',
165
- shortcut: '⌃⇧`',
166
- action: () => {
167
- if (typeof workbench.createNewTerminalSession === 'function') workbench.createNewTerminalSession();
168
- }
169
- },
170
- {
171
- id: 'terminal-split',
172
- label: 'Terminal: Split Terminal',
173
- shortcut: '⌘\\',
174
- action: () => {
175
- if (typeof workbench.splitTerminalSession === 'function') workbench.splitTerminalSession();
176
- }
177
- },
178
- {
179
- id: 'terminal-clear',
180
- label: 'Terminal: Clear',
181
- action: () => {
182
- if (typeof workbench.clearTerminal === 'function') workbench.clearTerminal();
183
- }
184
- },
185
- {
186
- id: 'open-problems',
187
- label: 'View: Focus Problems (Errors, Warnings)',
188
- shortcut: '⇧⌘M',
189
- action: () => {
190
- workbench.drawerTab = 'problems';
191
- if (typeof workbench.setPanelVisible === 'function') workbench.setPanelVisible(true);
192
- if (typeof workbench._renderDrawerBody === 'function') workbench._renderDrawerBody();
193
- }
194
- },
195
- {
196
- id: 'open-stdin',
197
- label: 'View: Open Output / Stdin Panel',
198
- action: () => {
199
- workbench.drawerTab = 'stdin';
200
- if (typeof workbench.setPanelVisible === 'function') workbench.setPanelVisible(true);
201
- if (typeof workbench._renderDrawerBody === 'function') workbench._renderDrawerBody();
202
- }
203
- },
204
- {
205
- id: 'new-file',
206
- label: 'File: New File...',
207
- action: () => workbench.startInlineCreate('file', '')
208
- },
209
- {
210
- id: 'new-folder',
211
- label: 'File: New Folder...',
212
- action: () => workbench.startInlineCreate('folder', '')
213
- },
214
- {
215
- id: 'rename-active',
216
- label: 'File: Rename Active File...',
217
- shortcut: 'F2',
218
- action: () => {
219
- if (workbench.activeFile && workbench.activeFile !== '__welcome__') {
220
- workbench.startInlineRename('file', workbench.activeFile);
221
- }
222
- }
223
- },
224
- {
225
- id: 'delete-active',
226
- label: 'File: Delete Active File',
227
- action: () => {
228
- if (workbench.activeFile && workbench.activeFile !== '__welcome__') {
229
- workbench.deleteFile(workbench.activeFile);
230
- }
231
- }
232
- },
233
- {
234
- id: 'open-welcome',
235
- label: 'Help: Welcome',
236
- action: () => {
237
- if (typeof workbench.openWelcomeTab === 'function') workbench.openWelcomeTab();
238
- }
239
- },
240
- {
241
- id: 'open-settings',
242
- label: 'Preferences: Open Settings (UI)',
243
- shortcut: '⌘,',
244
- action: () => {
245
- if (typeof workbench.openSettingsView === 'function') workbench.openSettingsView();
246
- else if (typeof workbench.showSettingsModal === 'function') workbench.showSettingsModal();
247
- }
248
- },
249
- {
250
- id: 'toggle-theme',
251
- label: 'Preferences: Cycle Color Theme (Dark Modern / Light Modern / High Contrast)',
252
- action: () => {
253
- const order = ['dark', 'light', 'high-contrast'];
254
- const cur = typeof workbench._resolvedTheme === 'function' ? workbench._resolvedTheme() : workbench.theme;
255
- const next = order[(order.indexOf(cur) + 1) % order.length] || 'dark';
256
- if (typeof workbench.setTheme === 'function') workbench.setTheme(next);
257
- }
258
- },
259
- {
260
- id: 'search-workspace',
261
- label: 'Search: Find in Files',
262
- shortcut: '⇧⌘F',
263
- action: () => workbench.showSearchModal()
264
- },
265
- {
266
- id: 'open-scm',
267
- label: 'Source Control: Focus on Source Control View',
268
- shortcut: '⌃⇧G',
269
- action: () => workbench.showScmModal()
270
- },
271
- {
272
- id: 'git-clone',
273
- label: 'Git: Clone Repository...',
274
- action: () => {
275
- if (typeof workbench.showCloneModal === 'function') workbench.showCloneModal();
276
- }
277
- },
278
- {
279
- id: 'git-stash',
280
- label: 'Git: Stash Changes',
281
- action: () => {
282
- if (workbench.shell && typeof workbench.shell.execute === 'function') {
283
- void workbench.shell.execute('git stash push').then(() => {
284
- if (typeof workbench._refreshGitDecorations === 'function') workbench._refreshGitDecorations();
285
- });
286
- }
287
- }
288
- },
289
- {
290
- id: 'git-stash-pop',
291
- label: 'Git: Pop Latest Stash',
292
- action: () => {
293
- if (workbench.shell && typeof workbench.shell.execute === 'function') {
294
- void workbench.shell.execute('git stash pop').then(() => {
295
- if (typeof workbench._syncFilesFromVfs === 'function') workbench._syncFilesFromVfs();
296
- if (typeof workbench._refreshGitDecorations === 'function') workbench._refreshGitDecorations();
297
- });
298
- }
299
- }
300
- },
301
- {
302
- id: 'share-snapshot',
303
- label: 'Share: Copy URL Snapshot to Clipboard (#codelab=...)',
304
- action: () => workbench.shareSnapshot()
305
- },
306
- {
307
- id: 'export-workspace-zip',
308
- label: 'File: Download Workspace as ZIP Archive',
309
- action: () => workbench.exportProjectZip({ download: true })
310
- },
311
- {
312
- id: 'export-workspace-json',
313
- label: 'File: Export Workspace as JSON',
314
- action: () => workbench.exportWorkspace({ download: true })
315
- },
316
- {
317
- id: 'toggle-fullscreen',
318
- label: 'View: Toggle Full Screen',
319
- action: () => workbench.toggleFullscreen()
320
- }
321
- ];
322
-
323
- if (workbench.hasGuidedLab) {
324
- commands.push(
325
- {
326
- id: 'compare-solution',
327
- label: 'Diff: Compare Active File with Reference Solution',
328
- action: () => workbench.showDiffModal(workbench.activeFile || workbench._pickDefaultFile(), 'solution')
329
- },
330
- {
331
- id: 'compare-starter',
332
- label: 'Diff: Compare Active File with Starter Template',
333
- action: () => workbench.showDiffModal(workbench.activeFile || workbench._pickDefaultFile(), 'starter')
334
- },
335
- {
336
- id: 'switch-lang',
337
- label: 'Language: Cycle Active Lab Language (JS / TS / C++ / PY)',
338
- action: () => {
339
- const order = ['js'];
340
- if (workbench.enabledLanguages?.has('ts')) order.push('ts');
341
- if (workbench.enabledLanguages?.has('cpp')) order.push('cpp');
342
- if (workbench.enabledLanguages?.has('py')) order.push('py');
343
- const next = order[(order.indexOf(workbench.lang) + 1) % order.length] || 'js';
344
- workbench.setLanguage(next);
345
- }
346
- }
347
- );
348
- }
349
-
350
- // Merge live Monaco editor actions (`Rename Symbol`, `Go to References`, `Change All Occurrences`, `Fold All`, etc.)
351
- const editor = workbench.editor;
352
- if (editor && typeof editor.getSupportedActions === 'function') {
353
- try {
354
- const existingLabels = new Set(commands.map((c) => c.label.toLowerCase()));
355
- const actions = editor.getSupportedActions() || [];
356
- for (const act of actions) {
357
- if (!act || !act.id || !act.label) continue;
358
- if (typeof act.isSupported === 'function' && !act.isSupported()) continue;
359
- const label = `Editor: ${act.label}`;
360
- if (existingLabels.has(label.toLowerCase()) || existingLabels.has(String(act.label).toLowerCase())) continue;
361
- existingLabels.add(label.toLowerCase());
362
- commands.push({
363
- id: `monaco:${act.id}`,
364
- label,
365
- action: () => {
366
- try {
367
- editor.focus?.();
368
- void act.run();
369
- } catch (_err) {
370
- void _err;
371
- }
372
- }
373
- });
374
- }
375
- } catch (_err) {
376
- void _err;
377
- }
378
- }
379
-
380
- return commands;
381
- }
@@ -131,6 +131,7 @@ export class CodeLabDiffEditorManager {
131
131
  const welcomeHost = this.workbench.container?.querySelector('#cl-welcome-host');
132
132
  if (welcomeHost) welcomeHost.style.display = 'none';
133
133
 
134
+ diffContainer.hidden = false;
134
135
  diffContainer.style.display = 'flex';
135
136
  editorHost.style.display = 'none';
136
137
  if (fallbackTextarea) fallbackTextarea.style.display = 'none';
@@ -455,6 +456,7 @@ export class CodeLabDiffEditorManager {
455
456
  this.isActive = false;
456
457
  const diffContainer = this.workbench.container?.querySelector('#cl-inline-diff-container');
457
458
  if (diffContainer) {
459
+ diffContainer.hidden = true;
458
460
  diffContainer.style.display = 'none';
459
461
  }
460
462
  const isWelcomeActive = this.workbench.activeFile === '__welcome__';
@@ -134,7 +134,7 @@ export const CL_ICONS: Record<string, string> = {
134
134
  layout:
135
135
  '<svg aria-hidden="true" width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"><rect x="1.5" y="2" width="13" height="12" rx="1"/><line x1="1.5" y1="6" x2="14.5" y2="6"/><line x1="6" y1="14" x2="6" y2="6"/></svg>',
136
136
  maximize:
137
- '<svg aria-hidden="true" width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><polyline points="12 10 8 6 4 10"/></svg>',
137
+ '<svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg>',
138
138
  settings:
139
139
  '<svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>',
140
140
  files:
@@ -3,42 +3,27 @@
3
3
  */
4
4
 
5
5
  export * from './icons';
6
- export * from './styles';
7
- export * from './toolbar';
8
- export * from './drawer';
9
6
  export * from './diff-editor';
10
7
  export * from './command-palette';
11
8
  export * from './share';
12
- export * from './file-tree';
13
9
  export * from './editor';
14
- export * from './guided-pane';
15
10
  export * from './xterm-adapter';
16
11
  export * from './intellisense';
17
12
 
18
13
  import * as icons from './icons';
19
- import * as styles from './styles';
20
- import * as toolbar from './toolbar';
21
- import * as drawer from './drawer';
22
14
  import * as diffEditor from './diff-editor';
23
15
  import * as commandPalette from './command-palette';
24
16
  import * as share from './share';
25
- import * as fileTree from './file-tree';
26
17
  import * as editor from './editor';
27
- import * as guidedPane from './guided-pane';
28
18
  import * as xtermAdapter from './xterm-adapter';
29
19
  import * as intellisense from './intellisense';
30
20
 
31
21
  export const CodeLabWorkbenchComponents = {
32
22
  ...icons,
33
- ...styles,
34
- ...toolbar,
35
- ...drawer,
36
23
  ...diffEditor,
37
24
  ...commandPalette,
38
25
  ...share,
39
- ...fileTree,
40
26
  ...editor,
41
- ...guidedPane,
42
27
  ...xtermAdapter,
43
28
  ...intellisense
44
29
  };
@@ -1062,6 +1062,7 @@ export class WorkspaceAtaController {
1062
1062
  private inFlight = new Set<string>();
1063
1063
  private disposables: Array<{ dispose?: () => void }> = [];
1064
1064
  private debounceTimer: ReturnType<typeof setTimeout> | null = null;
1065
+ private disposed = false;
1065
1066
 
1066
1067
  constructor(monaco: MonacoNamespaceLike | null | undefined) {
1067
1068
  this.monaco = monaco;
@@ -1118,19 +1119,24 @@ export class WorkspaceAtaController {
1118
1119
  }
1119
1120
 
1120
1121
  private async acquireOne(pkgName: string): Promise<void> {
1122
+ if (this.disposed) return;
1121
1123
  const cached = await readAtaCache(pkgName);
1124
+ if (this.disposed) return;
1122
1125
  if (cached) {
1123
1126
  this.injectExtraLib(pkgName, cached);
1124
1127
  return;
1125
1128
  }
1126
1129
  const fetched = await fetchPackageDtsFromCdn(pkgName);
1130
+ if (this.disposed) return;
1127
1131
  if (fetched) {
1128
1132
  await writeAtaCache(pkgName, fetched);
1133
+ if (this.disposed) return;
1129
1134
  this.injectExtraLib(pkgName, fetched);
1130
1135
  }
1131
1136
  }
1132
1137
 
1133
1138
  public dispose(): void {
1139
+ this.disposed = true;
1134
1140
  if (this.debounceTimer) {
1135
1141
  clearTimeout(this.debounceTimer);
1136
1142
  this.debounceTimer = null;
@@ -1357,16 +1363,23 @@ const SQL_FUNCTIONS: Array<{ name: string; sig: string; doc: string }> = [
1357
1363
  * - JSON schemas (`package.json`, `tsconfig.json`, `jsconfig.json`)
1358
1364
  * - HTML Emmet completions, CSS cross-file variable completions/hovers, SQL schema completions/hovers
1359
1365
  */
1366
+ const monacoWorkspaceGetters = new WeakMap<object, WorkspaceFilesGetter>();
1367
+
1360
1368
  export function initializeMonacoIntelligence(
1361
1369
  monaco: MonacoNamespaceLike | null | undefined,
1362
1370
  getWorkspaceFiles: WorkspaceFilesGetter
1363
1371
  ): void {
1364
1372
  if (!monaco || typeof monaco !== 'object') return;
1373
+ monacoWorkspaceGetters.set(monaco, getWorkspaceFiles);
1365
1374
  registerCodeLabMonacoThemes(monaco);
1366
1375
  syncTsConfigToMonaco(monaco, getWorkspaceFiles() || {});
1367
1376
 
1368
1377
  if (registeredMonacoInstances.has(monaco)) return;
1369
1378
  registeredMonacoInstances.add(monaco);
1379
+ const getCurrentFiles = (): Record<string, string> => {
1380
+ const fn = monacoWorkspaceGetters.get(monaco);
1381
+ return (fn ? fn() : {}) || {};
1382
+ };
1370
1383
 
1371
1384
  // 1. Node.js / Web ambient declarations
1372
1385
  try {
@@ -1438,7 +1451,7 @@ export function initializeMonacoIntelligence(
1438
1451
  provideCompletionItems(model: MonacoTextModelLike, position: MonacoPositionLike) {
1439
1452
  const linePrefix = String(model.getLineContent(position.lineNumber) || '').slice(0, position.column - 1);
1440
1453
  if (!/(?:var\(\s*|--)[a-zA-Z0-9_-]*$/.test(linePrefix)) return { suggestions: [] };
1441
- const vars = collectCssVariables(getWorkspaceFiles() || {});
1454
+ const vars = collectCssVariables(getCurrentFiles());
1442
1455
  const word = model.getWordUntilPosition(position);
1443
1456
  const startCol = Math.max(1, linePrefix.lastIndexOf('--') + 1 || word.startColumn);
1444
1457
  const range = {
@@ -1469,7 +1482,7 @@ export function initializeMonacoIntelligence(
1469
1482
  const start = m.index + 1;
1470
1483
  const end = start + m[0].length;
1471
1484
  if (position.column >= start && position.column <= end) {
1472
- const info = collectCssVariables(getWorkspaceFiles() || {}).get(m[0]);
1485
+ const info = collectCssVariables(getCurrentFiles()).get(m[0]);
1473
1486
  if (!info) return null;
1474
1487
  const hoverRange = monaco.Range
1475
1488
  ? new monaco.Range(position.lineNumber, start, position.lineNumber, end)
@@ -1500,7 +1513,7 @@ export function initializeMonacoIntelligence(
1500
1513
  endLineNumber: position.lineNumber,
1501
1514
  endColumn: word.endColumn
1502
1515
  };
1503
- const tables = collectSqlSchemaTables(getWorkspaceFiles() || {}, model.getValue?.() || '');
1516
+ const tables = collectSqlSchemaTables(getCurrentFiles(), model.getValue?.() || '');
1504
1517
  const linePrefix = String(model.getLineContent(position.lineNumber) || '').slice(0, position.column - 1);
1505
1518
  const dotMatch = linePrefix.match(/([A-Za-z_][A-Za-z0-9_]*)\.[A-Za-z0-9_]*$/);
1506
1519
 
@@ -1578,7 +1591,7 @@ export function initializeMonacoIntelligence(
1578
1591
  contents: [{ value: `\`\`\`sql\n${fn.sig}\n\`\`\`` }, { value: fn.doc }]
1579
1592
  };
1580
1593
  }
1581
- const tables = collectSqlSchemaTables(getWorkspaceFiles() || {}, model.getValue?.() || '');
1594
+ const tables = collectSqlSchemaTables(getCurrentFiles(), model.getValue?.() || '');
1582
1595
  const table = tables.find((t) => t.table.toLowerCase() === word.word.toLowerCase());
1583
1596
  if (table) {
1584
1597
  const cols = table.columns.map((c) => ` ${c.name} ${c.type}`).join(',\n');