@innovatorved/code-lab 0.7.0 → 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 (159) hide show
  1. package/ARCHITECTURE.md +2 -2
  2. package/CHANGELOG.md +30 -0
  3. package/README.md +6 -6
  4. package/dist/code-lab-sql.esm.js +19 -19
  5. package/dist/code-lab-sql.umd.js +20 -20
  6. package/dist/code-lab.css +1 -1
  7. package/dist/code-lab.d.ts +47 -38
  8. package/dist/code-lab.esm.js +1183 -1909
  9. package/dist/code-lab.js +1182 -1906
  10. package/dist/extensions/cpp.esm.js +132 -8760
  11. package/dist/extensions/cpp.js +124 -8770
  12. package/dist/extensions/guided-lab.esm.js +33 -6836
  13. package/dist/extensions/guided-lab.js +33 -6854
  14. package/dist/extensions/javascript.esm.js +1 -36
  15. package/dist/extensions/javascript.js +1 -58
  16. package/dist/extensions/python.esm.js +113 -8122
  17. package/dist/extensions/python.js +113 -8140
  18. package/dist/extensions/typescript.esm.js +1 -55
  19. package/dist/extensions/typescript.js +1 -77
  20. package/dist/index.d.ts +1 -1
  21. package/dist/logger.d.ts +4 -20
  22. package/dist/modular-kernel.d.ts +0 -5
  23. package/dist/packages/core/src/errors.d.ts +5 -1
  24. package/dist/packages/fs/src/backends.d.ts +0 -27
  25. package/dist/packages/fs/src/index.d.ts +1 -1
  26. package/dist/packages/ui/src/html.d.ts +1 -0
  27. package/dist/packages/ui/src/index.d.ts +1 -0
  28. package/dist/{apps/web/src/index.d.ts → packages/ui/src/kernel.d.ts} +3 -11
  29. package/dist/packages/ui/src/observability.d.ts +1 -1
  30. package/dist/packages/ui/src/settings-dialog.d.ts +0 -1
  31. package/dist/preview-sw.js +1 -1
  32. package/dist/runtime.d.ts +3 -0
  33. package/dist/runtime.esm.js +78 -78
  34. package/dist/runtime.js +78 -78
  35. package/dist/schemas.d.ts +10 -1
  36. package/dist/schemas.esm.js +33 -6815
  37. package/dist/schemas.js +33 -6831
  38. package/dist/shell.esm.js +277 -285
  39. package/dist/shell.js +277 -285
  40. package/dist/terminal.esm.js +9 -7
  41. package/dist/terminal.js +7 -7
  42. package/dist/workbench/command-palette.d.ts +0 -4
  43. package/dist/workbench/editor.d.ts +0 -4
  44. package/dist/workbench/index.d.ts +0 -22
  45. package/dist/workbench/intellisense.d.ts +1 -8
  46. package/dist/workbench/xterm-adapter.d.ts +0 -1
  47. package/package.json +4 -13
  48. package/dist/code-lab.umd.js +0 -6117
  49. package/dist/packages/editor/src/index.d.ts +0 -118
  50. package/dist/packages/preview/src/index.d.ts +0 -34
  51. package/dist/packages/runtime/src/index.d.ts +0 -47
  52. package/dist/packages/terminal/src/index.d.ts +0 -54
  53. package/dist/workbench/drawer.d.ts +0 -18
  54. package/dist/workbench/file-tree.d.ts +0 -11
  55. package/dist/workbench/guided-pane.d.ts +0 -11
  56. package/dist/workbench/styles.d.ts +0 -4
  57. package/dist/workbench/toolbar.d.ts +0 -17
  58. package/packages/commands/README.md +0 -7
  59. package/packages/commands/package.json +0 -16
  60. package/packages/commands/src/index.ts +0 -467
  61. package/packages/commands/tsconfig.json +0 -22
  62. package/packages/core/README.md +0 -12
  63. package/packages/core/package.json +0 -13
  64. package/packages/core/src/di.ts +0 -147
  65. package/packages/core/src/disposable.ts +0 -112
  66. package/packages/core/src/errors.ts +0 -205
  67. package/packages/core/src/events.ts +0 -157
  68. package/packages/core/src/index.ts +0 -49
  69. package/packages/core/src/path.ts +0 -118
  70. package/packages/core/src/registry.ts +0 -61
  71. package/packages/core/tsconfig.json +0 -19
  72. package/packages/editor/README.md +0 -9
  73. package/packages/editor/package.json +0 -18
  74. package/packages/editor/src/index.ts +0 -344
  75. package/packages/editor/tsconfig.json +0 -24
  76. package/packages/fs/README.md +0 -7
  77. package/packages/fs/package.json +0 -16
  78. package/packages/fs/src/backends.ts +0 -301
  79. package/packages/fs/src/index.ts +0 -18
  80. package/packages/fs/src/types.ts +0 -44
  81. package/packages/fs/src/vfs-service.ts +0 -257
  82. package/packages/fs/tsconfig.json +0 -22
  83. package/packages/preview/README.md +0 -3
  84. package/packages/preview/package.json +0 -16
  85. package/packages/preview/src/index.ts +0 -125
  86. package/packages/preview/tsconfig.json +0 -22
  87. package/packages/runtime/README.md +0 -3
  88. package/packages/runtime/package.json +0 -17
  89. package/packages/runtime/src/index.ts +0 -134
  90. package/packages/runtime/tsconfig.json +0 -23
  91. package/packages/settings/README.md +0 -7
  92. package/packages/settings/package.json +0 -16
  93. package/packages/settings/src/builtin-schemas.ts +0 -262
  94. package/packages/settings/src/configuration-service.ts +0 -609
  95. package/packages/settings/src/index.ts +0 -38
  96. package/packages/settings/src/jsonc.ts +0 -189
  97. package/packages/settings/src/schema.ts +0 -164
  98. package/packages/settings/tsconfig.json +0 -22
  99. package/packages/sql/README.md +0 -12
  100. package/packages/sql/package.json +0 -13
  101. package/packages/sql/src/completions.ts +0 -359
  102. package/packages/sql/src/diagnostics.ts +0 -200
  103. package/packages/sql/src/formatter.ts +0 -271
  104. package/packages/sql/src/index.ts +0 -54
  105. package/packages/sql/src/sql-editor.ts +0 -802
  106. package/packages/sql/src/styles.ts +0 -524
  107. package/packages/sql/src/tokenizer.ts +0 -457
  108. package/packages/sql/src/types.ts +0 -148
  109. package/packages/sql/tsconfig.json +0 -19
  110. package/packages/terminal/README.md +0 -3
  111. package/packages/terminal/package.json +0 -16
  112. package/packages/terminal/src/index.ts +0 -183
  113. package/packages/terminal/tsconfig.json +0 -22
  114. package/packages/ui/README.md +0 -8
  115. package/packages/ui/package.json +0 -18
  116. package/packages/ui/src/index.ts +0 -40
  117. package/packages/ui/src/observability.ts +0 -173
  118. package/packages/ui/src/plugin-registry.ts +0 -289
  119. package/packages/ui/src/settings-dialog.ts +0 -939
  120. package/packages/ui/src/themes.ts +0 -333
  121. package/packages/ui/tsconfig.json +0 -24
  122. package/src/code-lab.css +0 -8584
  123. package/src/csp.ts +0 -590
  124. package/src/diagnostics.ts +0 -287
  125. package/src/extensions/cpp.ts +0 -2389
  126. package/src/extensions/guided-lab.ts +0 -64
  127. package/src/extensions/javascript.ts +0 -54
  128. package/src/extensions/python.ts +0 -1737
  129. package/src/extensions/typescript.ts +0 -85
  130. package/src/extensions/umbrella.ts +0 -5
  131. package/src/html.ts +0 -88
  132. package/src/index.ts +0 -129
  133. package/src/logger.ts +0 -139
  134. package/src/modular-kernel.ts +0 -11
  135. package/src/preview-sw.js +0 -296
  136. package/src/runtime/test-harness.ts +0 -57
  137. package/src/runtime.ts +0 -10480
  138. package/src/sample.html +0 -304
  139. package/src/schemas.ts +0 -366
  140. package/src/scm.ts +0 -2453
  141. package/src/search.ts +0 -433
  142. package/src/shell.ts +0 -10987
  143. package/src/storage.ts +0 -773
  144. package/src/terminal.ts +0 -1400
  145. package/src/workbench/command-palette.ts +0 -381
  146. package/src/workbench/diff-editor.ts +0 -470
  147. package/src/workbench/drawer.ts +0 -157
  148. package/src/workbench/editor.ts +0 -49
  149. package/src/workbench/file-tree.ts +0 -51
  150. package/src/workbench/guided-pane.ts +0 -43
  151. package/src/workbench/icons.ts +0 -255
  152. package/src/workbench/index.ts +0 -44
  153. package/src/workbench/intellisense.ts +0 -1871
  154. package/src/workbench/share.ts +0 -128
  155. package/src/workbench/styles.ts +0 -211
  156. package/src/workbench/toolbar.ts +0 -182
  157. package/src/workbench/xterm-adapter.ts +0 -1571
  158. package/src/workbench.ts +0 -22132
  159. package/src/zip.ts +0 -348
@@ -1,381 +0,0 @@
1
- /**
2
- * @innovatorved/code-lab — VS Code Quick Open & Fuzzy Command Palette (Cmd+P / Cmd+Shift+P / F1)
3
- */
4
-
5
- export interface CommandPaletteItem {
6
- id: string;
7
- label: string;
8
- category?: string;
9
- detail?: string;
10
- shortcut?: string;
11
- action: () => void;
12
- }
13
-
14
- export interface FuzzyMatchResult {
15
- score: number;
16
- indices: number[];
17
- }
18
-
19
- function escapeHtml(str: unknown): string {
20
- return String(str ?? '')
21
- .replace(/&/g, '&')
22
- .replace(/</g, '&lt;')
23
- .replace(/>/g, '&gt;')
24
- .replace(/"/g, '&quot;')
25
- .replace(/'/g, '&#39;');
26
- }
27
-
28
- /**
29
- * VS Code-style subsequence fuzzy matcher with bonuses for consecutive matches,
30
- * word-boundary / camelCase transitions, and prefix alignment.
31
- */
32
- export function fuzzyScoreText(query: string, candidate: string): FuzzyMatchResult | null {
33
- const q = String(query || '').trim();
34
- const text = String(candidate || '');
35
- if (!q) return { score: 1, indices: [] };
36
- if (!text) return null;
37
-
38
- const qLower = q.toLowerCase();
39
- const tLower = text.toLowerCase();
40
-
41
- const indices: number[] = [];
42
- let qi = 0;
43
- let score = 0;
44
- let prevMatchIdx = -2;
45
-
46
- for (let ti = 0; ti < text.length && qi < qLower.length; ti++) {
47
- if (tLower[ti] === qLower[qi]) {
48
- indices.push(ti);
49
- score += 10;
50
-
51
- // Consecutive match bonus
52
- if (ti === prevMatchIdx + 1) {
53
- score += 14;
54
- }
55
- // Prefix match bonus
56
- if (ti === 0) {
57
- score += 18;
58
- } else {
59
- const prev = text[ti - 1];
60
- const curr = text[ti];
61
- // Path separator / word boundary / camelCase transition bonus
62
- if (prev === '/' || prev === '-' || prev === '_' || prev === ' ' || prev === ':' || prev === '.') {
63
- score += 12;
64
- } else if (prev >= 'a' && prev <= 'z' && curr >= 'A' && curr <= 'Z') {
65
- score += 10;
66
- }
67
- }
68
-
69
- prevMatchIdx = ti;
70
- qi++;
71
- }
72
- }
73
-
74
- if (qi < qLower.length) return null;
75
-
76
- // Slightly prefer shorter, tighter matches
77
- score -= Math.min(20, Math.floor((text.length - q.length) * 0.25));
78
- return { score, indices };
79
- }
80
-
81
- /**
82
- * Renders HTML with `<mark class="codelab-palette-hl">` around matched subsequence characters.
83
- */
84
- export function renderHighlightedText(text: string, indices: number[]): string {
85
- if (!indices || indices.length === 0) return escapeHtml(text);
86
- const matchSet = new Set(indices);
87
- let html = '';
88
- let inMark = false;
89
- for (let i = 0; i < text.length; i++) {
90
- const isHit = matchSet.has(i);
91
- if (isHit && !inMark) {
92
- html += '<mark class="codelab-palette-hl">';
93
- inMark = true;
94
- } else if (!isHit && inMark) {
95
- html += '</mark>';
96
- inMark = false;
97
- }
98
- html += escapeHtml(text[i]);
99
- }
100
- if (inMark) html += '</mark>';
101
- return html;
102
- }
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
- }