@innovatorved/code-lab 0.6.1 → 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.
- package/ARCHITECTURE.md +2 -2
- package/CHANGELOG.md +35 -0
- package/README.md +38 -1
- package/dist/apps/web/src/index.d.ts +0 -9
- package/dist/code-lab-sql.esm.js +19 -19
- package/dist/code-lab-sql.umd.js +20 -20
- package/dist/code-lab.css +1 -1
- package/dist/code-lab.d.ts +19 -1
- package/dist/code-lab.esm.js +933 -1685
- package/dist/code-lab.js +932 -1684
- package/dist/extensions/cpp.esm.js +132 -8751
- package/dist/extensions/cpp.js +124 -8761
- package/dist/extensions/guided-lab.esm.js +33 -6827
- package/dist/extensions/guided-lab.js +33 -6845
- package/dist/extensions/javascript.esm.js +1 -36
- package/dist/extensions/javascript.js +1 -58
- package/dist/extensions/python.esm.js +79 -8109
- package/dist/extensions/python.js +79 -8127
- package/dist/extensions/typescript.esm.js +1 -55
- package/dist/extensions/typescript.js +1 -77
- package/dist/index.d.ts +1 -1
- package/dist/modular-kernel.d.ts +0 -4
- package/dist/preview-sw.js +1 -1
- package/dist/runtime.esm.js +79 -79
- package/dist/runtime.js +79 -79
- package/dist/schemas.d.ts +22 -1
- package/dist/schemas.esm.js +33 -6806
- package/dist/schemas.js +33 -6822
- package/dist/shell.esm.js +248 -242
- package/dist/shell.js +248 -242
- package/dist/terminal.esm.js +8 -6
- package/dist/terminal.js +6 -6
- package/dist/workbench/command-palette.d.ts +0 -4
- package/dist/workbench/index.d.ts +0 -20
- package/dist/workbench/intellisense.d.ts +1 -7
- package/package.json +3 -10
- package/src/code-lab.css +11 -503
- package/src/extensions/cpp.ts +11 -29
- package/src/extensions/guided-lab.ts +6 -2
- package/src/extensions/python.ts +9 -3
- package/src/index.ts +1 -1
- package/src/modular-kernel.ts +0 -4
- package/src/runtime.ts +153 -42
- package/src/schemas.ts +12 -3
- package/src/shell.ts +109 -16
- package/src/terminal.ts +4 -2
- package/src/workbench/command-palette.ts +22 -302
- package/src/workbench/diff-editor.ts +2 -0
- package/src/workbench/icons.ts +1 -1
- package/src/workbench/index.ts +0 -15
- package/src/workbench/intellisense.ts +17 -4
- package/src/workbench.ts +432 -456
- package/dist/code-lab.umd.js +0 -6109
- package/dist/packages/editor/src/index.d.ts +0 -118
- package/dist/packages/preview/src/index.d.ts +0 -34
- package/dist/packages/runtime/src/index.d.ts +0 -47
- package/dist/packages/terminal/src/index.d.ts +0 -54
- package/dist/workbench/drawer.d.ts +0 -18
- package/dist/workbench/file-tree.d.ts +0 -11
- package/dist/workbench/guided-pane.d.ts +0 -11
- package/dist/workbench/styles.d.ts +0 -4
- package/dist/workbench/toolbar.d.ts +0 -17
- package/packages/commands/README.md +0 -7
- package/packages/commands/package.json +0 -16
- package/packages/commands/src/index.ts +0 -467
- package/packages/commands/tsconfig.json +0 -22
- package/packages/core/README.md +0 -12
- package/packages/core/package.json +0 -13
- package/packages/core/src/di.ts +0 -147
- package/packages/core/src/disposable.ts +0 -112
- package/packages/core/src/errors.ts +0 -205
- package/packages/core/src/events.ts +0 -157
- package/packages/core/src/index.ts +0 -49
- package/packages/core/src/path.ts +0 -118
- package/packages/core/src/registry.ts +0 -61
- package/packages/core/tsconfig.json +0 -19
- package/packages/editor/README.md +0 -9
- package/packages/editor/package.json +0 -18
- package/packages/editor/src/index.ts +0 -344
- package/packages/editor/tsconfig.json +0 -24
- package/packages/fs/README.md +0 -7
- package/packages/fs/package.json +0 -16
- package/packages/fs/src/backends.ts +0 -301
- package/packages/fs/src/index.ts +0 -18
- package/packages/fs/src/types.ts +0 -44
- package/packages/fs/src/vfs-service.ts +0 -257
- package/packages/fs/tsconfig.json +0 -22
- package/packages/preview/README.md +0 -3
- package/packages/preview/package.json +0 -16
- package/packages/preview/src/index.ts +0 -125
- package/packages/preview/tsconfig.json +0 -22
- package/packages/runtime/README.md +0 -3
- package/packages/runtime/package.json +0 -17
- package/packages/runtime/src/index.ts +0 -134
- package/packages/runtime/tsconfig.json +0 -23
- package/packages/settings/README.md +0 -7
- package/packages/settings/package.json +0 -16
- package/packages/settings/src/builtin-schemas.ts +0 -246
- package/packages/settings/src/configuration-service.ts +0 -609
- package/packages/settings/src/index.ts +0 -38
- package/packages/settings/src/jsonc.ts +0 -189
- package/packages/settings/src/schema.ts +0 -164
- package/packages/settings/tsconfig.json +0 -22
- package/packages/sql/README.md +0 -12
- package/packages/sql/package.json +0 -13
- package/packages/sql/src/completions.ts +0 -359
- package/packages/sql/src/diagnostics.ts +0 -200
- package/packages/sql/src/formatter.ts +0 -271
- package/packages/sql/src/index.ts +0 -54
- package/packages/sql/src/sql-editor.ts +0 -802
- package/packages/sql/src/styles.ts +0 -524
- package/packages/sql/src/tokenizer.ts +0 -457
- package/packages/sql/src/types.ts +0 -148
- package/packages/sql/tsconfig.json +0 -19
- package/packages/terminal/README.md +0 -3
- package/packages/terminal/package.json +0 -16
- package/packages/terminal/src/index.ts +0 -183
- package/packages/terminal/tsconfig.json +0 -22
- package/packages/ui/README.md +0 -8
- package/packages/ui/package.json +0 -18
- package/packages/ui/src/index.ts +0 -40
- package/packages/ui/src/observability.ts +0 -173
- package/packages/ui/src/plugin-registry.ts +0 -289
- package/packages/ui/src/settings-dialog.ts +0 -911
- package/packages/ui/src/themes.ts +0 -333
- package/packages/ui/tsconfig.json +0 -24
- package/src/workbench/drawer.ts +0 -157
- package/src/workbench/file-tree.ts +0 -51
- package/src/workbench/guided-pane.ts +0 -43
- package/src/workbench/styles.ts +0 -211
- 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
|
-
}
|