@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
@@ -1,289 +0,0 @@
1
- import {
2
- type CommandDescriptor,
3
- type ICommandRegistry,
4
- type IKeybindingService,
5
- type KeybindingRule
6
- } from '@code-lab/commands';
7
- import {
8
- CodeLabError,
9
- ContributionRegistry,
10
- createServiceId,
11
- DisposableStore,
12
- Emitter,
13
- type Event,
14
- type IDisposable,
15
- type ILogger
16
- } from '@code-lab/core';
17
- import type { IConfigurationService, SettingDescriptor } from '@code-lab/settings';
18
- import type { IThemeService, ThemeDefinition } from './themes';
19
-
20
- export interface PanelContribution {
21
- readonly id: string;
22
- readonly title: string;
23
- readonly location: 'drawer' | 'sidebar';
24
- readonly icon?: string;
25
- readonly render: (container: HTMLElement) => void | IDisposable;
26
- }
27
-
28
- export interface LanguageContribution {
29
- readonly id: string;
30
- readonly extensions: readonly string[];
31
- readonly aliases?: readonly string[];
32
- readonly runFile?: (filePath: string, source: string) => Promise<{ ok: boolean; stdout: string; stderr: string }>;
33
- }
34
-
35
- export interface PluginContributions {
36
- readonly commands?: readonly CommandDescriptor[];
37
- readonly settings?: readonly SettingDescriptor[];
38
- readonly keybindings?: readonly KeybindingRule[];
39
- readonly themes?: readonly ThemeDefinition[];
40
- readonly panels?: readonly PanelContribution[];
41
- readonly languages?: readonly LanguageContribution[];
42
- }
43
-
44
- export interface PluginActivationContext {
45
- readonly subscriptions: DisposableStore;
46
- readonly commands: ICommandRegistry;
47
- readonly configuration: IConfigurationService;
48
- readonly keybindings: IKeybindingService;
49
- readonly themes: IThemeService;
50
- readonly logger: ILogger;
51
- readonly registerPanel?: (panel: PanelContribution) => IDisposable;
52
- }
53
-
54
- export interface CodeLabPluginManifest {
55
- readonly id: string;
56
- readonly name: string;
57
- readonly version: string;
58
- readonly description?: string;
59
- readonly activationEvents?: readonly string[];
60
- readonly contributes?: PluginContributions;
61
- readonly activate?: (ctx: PluginActivationContext) => void | Promise<void> | IDisposable;
62
- readonly deactivate?: () => void | Promise<void>;
63
- }
64
-
65
- export interface RegisteredPluginInfo {
66
- readonly manifest: CodeLabPluginManifest;
67
- readonly active: boolean;
68
- }
69
-
70
- export interface IPluginRegistry extends IDisposable {
71
- readonly panels: ContributionRegistry<string, PanelContribution>;
72
- readonly languages: ContributionRegistry<string, LanguageContribution>;
73
- readonly onDidChangePlugins: Event<string>;
74
- registerPlugin(manifest: CodeLabPluginManifest): IDisposable;
75
- activatePlugin(id: string): Promise<void>;
76
- deactivatePlugin(id: string): Promise<void>;
77
- fireActivationEvent(eventName: string): Promise<void>;
78
- getPlugins(): RegisteredPluginInfo[];
79
- resolveLanguageForFile(filePath: string): LanguageContribution | undefined;
80
- }
81
-
82
- export const IPluginRegistryId = createServiceId<IPluginRegistry>('code-lab.plugins');
83
-
84
- interface PluginRecord {
85
- manifest: CodeLabPluginManifest;
86
- active: boolean;
87
- manifestDisposables: DisposableStore;
88
- runtimeDisposables: DisposableStore;
89
- }
90
-
91
- export class PluginRegistry implements IPluginRegistry {
92
- public readonly panels = new ContributionRegistry<string, PanelContribution>('panels');
93
- public readonly languages = new ContributionRegistry<string, LanguageContribution>('languages');
94
- private readonly records = new Map<string, PluginRecord>();
95
- private readonly changeEmitter = new Emitter<string>({ name: 'plugins.change' });
96
- private readonly commands: ICommandRegistry;
97
- private readonly configuration: IConfigurationService;
98
- private readonly keybindings: IKeybindingService;
99
- private readonly themes: IThemeService;
100
- private readonly logger: ILogger;
101
-
102
- public constructor(deps: {
103
- commands: ICommandRegistry;
104
- configuration: IConfigurationService;
105
- keybindings: IKeybindingService;
106
- themes: IThemeService;
107
- logger: ILogger;
108
- }) {
109
- this.commands = deps.commands;
110
- this.configuration = deps.configuration;
111
- this.keybindings = deps.keybindings;
112
- this.themes = deps.themes;
113
- this.logger = deps.logger.child('plugins');
114
- }
115
-
116
- public get onDidChangePlugins(): Event<string> {
117
- return this.changeEmitter.event;
118
- }
119
-
120
- public registerPlugin(manifest: CodeLabPluginManifest): IDisposable {
121
- if (!manifest.id || !manifest.name) {
122
- throw new CodeLabError('ERR_PLUGIN_INVALID', 'Plugin manifest requires non-empty id and name');
123
- }
124
- if (this.records.has(manifest.id)) {
125
- void this.deactivatePlugin(manifest.id);
126
- this.records.get(manifest.id)?.manifestDisposables.dispose();
127
- }
128
-
129
- const manifestDisposables = new DisposableStore();
130
- const contributes = manifest.contributes;
131
-
132
- // Declarative contributions are registered immediately without running plugin code
133
- if (contributes?.settings) {
134
- for (const s of contributes.settings) {
135
- manifestDisposables.add(this.configuration.registerSetting(s));
136
- }
137
- }
138
- if (contributes?.themes) {
139
- for (const t of contributes.themes) {
140
- manifestDisposables.add(this.themes.registerTheme(t));
141
- }
142
- }
143
- if (contributes?.commands) {
144
- for (const cmd of contributes.commands) {
145
- manifestDisposables.add(
146
- this.commands.registerCommand({
147
- ...cmd,
148
- handler: async (...args: unknown[]) => {
149
- await this.activatePlugin(manifest.id);
150
- return cmd.handler(...args);
151
- }
152
- })
153
- );
154
- }
155
- }
156
- if (contributes?.keybindings) {
157
- for (const kb of contributes.keybindings) {
158
- manifestDisposables.add(this.keybindings.registerKeybinding({ ...kb, source: 'plugin' }));
159
- }
160
- }
161
- if (contributes?.panels) {
162
- for (const panel of contributes.panels) {
163
- manifestDisposables.add(this.panels.register(panel.id, panel));
164
- }
165
- }
166
- if (contributes?.languages) {
167
- for (const lang of contributes.languages) {
168
- manifestDisposables.add(this.languages.register(lang.id, lang));
169
- }
170
- }
171
-
172
- const record: PluginRecord = {
173
- manifest,
174
- active: false,
175
- manifestDisposables,
176
- runtimeDisposables: new DisposableStore()
177
- };
178
- this.records.set(manifest.id, record);
179
- this.changeEmitter.fire(manifest.id);
180
-
181
- const events = manifest.activationEvents ?? ['*'];
182
- if (events.includes('*') || events.includes('onStartupFinished')) {
183
- void this.activatePlugin(manifest.id);
184
- }
185
-
186
- return {
187
- dispose: (): void => {
188
- if (record.active) {
189
- record.active = false;
190
- try {
191
- record.manifest.deactivate?.();
192
- } catch (err) {
193
- this.logger.warn(`Plugin "${manifest.id}" threw during deactivate`, err);
194
- }
195
- record.runtimeDisposables.dispose();
196
- }
197
- record.manifestDisposables.dispose();
198
- this.records.delete(manifest.id);
199
- this.changeEmitter.fire(manifest.id);
200
- }
201
- };
202
- }
203
-
204
- public async activatePlugin(id: string): Promise<void> {
205
- const record = this.records.get(id);
206
- if (!record || record.active) return;
207
- record.active = true;
208
- record.runtimeDisposables = new DisposableStore();
209
- if (record.manifest.activate) {
210
- try {
211
- const ret = await record.manifest.activate({
212
- subscriptions: record.runtimeDisposables,
213
- commands: this.commands,
214
- configuration: this.configuration,
215
- keybindings: this.keybindings,
216
- themes: this.themes,
217
- logger: this.logger.child(id),
218
- registerPanel: (panel: PanelContribution): IDisposable => {
219
- const d = this.panels.register(panel.id, panel);
220
- record.runtimeDisposables.add(d);
221
- this.changeEmitter.fire(id);
222
- return d;
223
- }
224
- });
225
- if (ret && typeof ret.dispose === 'function') {
226
- record.runtimeDisposables.add(ret);
227
- }
228
- } catch (err) {
229
- record.active = false;
230
- this.logger.error(`Plugin "${id}" failed to activate`, err);
231
- throw err;
232
- }
233
- }
234
- this.changeEmitter.fire(id);
235
- }
236
-
237
- public async deactivatePlugin(id: string): Promise<void> {
238
- const record = this.records.get(id);
239
- if (!record || !record.active) return;
240
- record.active = false;
241
- try {
242
- await record.manifest.deactivate?.();
243
- } catch (err) {
244
- this.logger.warn(`Plugin "${id}" threw during deactivate`, err);
245
- }
246
- record.runtimeDisposables.dispose();
247
- this.changeEmitter.fire(id);
248
- }
249
-
250
- public async fireActivationEvent(eventName: string): Promise<void> {
251
- for (const [id, rec] of this.records.entries()) {
252
- if (rec.active) continue;
253
- const events = rec.manifest.activationEvents ?? [];
254
- if (events.includes(eventName) || events.includes('*')) {
255
- await this.activatePlugin(id);
256
- }
257
- }
258
- }
259
-
260
- public getPlugins(): RegisteredPluginInfo[] {
261
- return Array.from(this.records.values()).map((r) => ({
262
- manifest: r.manifest,
263
- active: r.active
264
- }));
265
- }
266
-
267
- public resolveLanguageForFile(filePath: string): LanguageContribution | undefined {
268
- const dotIdx = filePath.lastIndexOf('.');
269
- const ext = dotIdx !== -1 ? filePath.slice(dotIdx).toLowerCase() : '';
270
- if (!ext) return undefined;
271
- for (const lang of this.languages.values()) {
272
- if (lang.extensions.some((e) => e.toLowerCase() === ext)) {
273
- return lang;
274
- }
275
- }
276
- return undefined;
277
- }
278
-
279
- public dispose(): void {
280
- for (const rec of this.records.values()) {
281
- rec.runtimeDisposables.dispose();
282
- rec.manifestDisposables.dispose();
283
- }
284
- this.records.clear();
285
- this.panels.dispose();
286
- this.languages.dispose();
287
- this.changeEmitter.dispose();
288
- }
289
- }