@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,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
- }