@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,609 +0,0 @@
1
- import {
2
- createServiceId,
3
- Emitter,
4
- type Event,
5
- type IDisposable,
6
- toDisposable
7
- } from '@code-lab/core';
8
- import {
9
- BUILTIN_SETTINGS,
10
- buildSettingsJsonSchema,
11
- EXTENSIONS_JSON_SCHEMA,
12
- TASKS_JSON_SCHEMA,
13
- type SettingDescriptor
14
- } from './builtin-schemas';
15
- import { parseJsonc } from './jsonc';
16
- import { type JsonSchema, validateJsonSchema } from './schema';
17
-
18
- export type ConfigurationTarget = 'default' | 'user' | 'workspace' | 'override';
19
-
20
- export type ConfigurationResetScope = 'user' | 'workspace' | 'all';
21
-
22
- export interface SettingDiagnostic {
23
- readonly file: string;
24
- readonly key?: string;
25
- readonly message: string;
26
- readonly line: number;
27
- readonly column: number;
28
- readonly severity: 'error' | 'warning';
29
- }
30
-
31
- export interface ConfigurationChangeEvent {
32
- readonly affectedKeys: ReadonlySet<string>;
33
- readonly source: ConfigurationTarget;
34
- readonly affectsConfiguration: (prefixOrKey: string) => boolean;
35
- }
36
-
37
- export interface SettingInspection<T = unknown> {
38
- readonly key: string;
39
- readonly defaultValue: T | undefined;
40
- readonly userValue: T | undefined;
41
- readonly workspaceValue: T | undefined;
42
- readonly overrideValue: T | undefined;
43
- readonly effectiveValue: T | undefined;
44
- readonly effectiveSource: ConfigurationTarget;
45
- }
46
-
47
- export interface WorkspaceTaskDefinition {
48
- readonly id: string;
49
- readonly label: string;
50
- readonly command: string;
51
- readonly group?: 'run' | 'build' | 'test' | 'dev';
52
- readonly runOn?: 'manual' | 'folderOpen';
53
- readonly cwd?: string;
54
- readonly env?: Readonly<Record<string, string>>;
55
- }
56
-
57
- export interface WorkspaceExtensionsConfig {
58
- readonly recommendations: readonly string[];
59
- readonly autoActivate: readonly string[];
60
- }
61
-
62
- export interface IConfigurationService extends IDisposable {
63
- readonly onDidChangeConfiguration: Event<ConfigurationChangeEvent>;
64
- readonly onDidChangeDiagnostics: Event<readonly SettingDiagnostic[]>;
65
- registerSetting(descriptor: SettingDescriptor): IDisposable;
66
- getDescriptors(): SettingDescriptor[];
67
- getJsonSchema(): JsonSchema;
68
- get<T = unknown>(key: string, fallback?: T): T;
69
- inspect<T = unknown>(key: string): SettingInspection<T>;
70
- getDiagnostics(): readonly SettingDiagnostic[];
71
- getWorkspaceSettings(): Record<string, unknown>;
72
- setUserSetting(key: string, value: unknown): boolean;
73
- resetSetting(key: string): void;
74
- resetScopedSetting(key: string, scope: ConfigurationResetScope): Promise<void>;
75
- resetAllSettings(scope?: ConfigurationResetScope): Promise<void>;
76
- setWorkspaceSetting(key: string, value: unknown): boolean;
77
- loadWorkspaceSettingsJson(rawJsonc: string, filePath?: string): readonly SettingDiagnostic[];
78
- setOverrides(overrides: Readonly<Record<string, unknown>>): void;
79
- toWorkspaceJsonString(): string;
80
- exportProfile(): string;
81
- importProfile(rawJsonc: string): readonly SettingDiagnostic[];
82
- toUrlParam(): string;
83
- applyUrlParam(encoded: string): readonly SettingDiagnostic[];
84
- }
85
-
86
- export const IConfigurationServiceId = createServiceId<IConfigurationService>('code-lab.configuration');
87
-
88
- function findKeyLine(raw: string, key: string): number {
89
- const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
90
- const match = new RegExp(`"${escaped}"\\s*:`).exec(raw);
91
- if (!match) return 1;
92
- return raw.slice(0, match.index).split('\n').length;
93
- }
94
-
95
- export class ConfigurationService implements IConfigurationService {
96
- private readonly descriptors = new Map<string, SettingDescriptor>();
97
- private readonly userValues = new Map<string, unknown>();
98
- private readonly workspaceValues = new Map<string, unknown>();
99
- private readonly overrideValues = new Map<string, unknown>();
100
- private diagnostics: SettingDiagnostic[] = [];
101
- private readonly changeEmitter = new Emitter<ConfigurationChangeEvent>({ name: 'config.change' });
102
- private readonly diagEmitter = new Emitter<readonly SettingDiagnostic[]>({ name: 'config.diagnostics' });
103
-
104
- public constructor(includeBuiltins = true) {
105
- if (includeBuiltins) {
106
- for (const d of BUILTIN_SETTINGS) {
107
- this.descriptors.set(d.key, d);
108
- }
109
- }
110
- }
111
-
112
- public get onDidChangeConfiguration(): Event<ConfigurationChangeEvent> {
113
- return this.changeEmitter.event;
114
- }
115
-
116
- public get onDidChangeDiagnostics(): Event<readonly SettingDiagnostic[]> {
117
- return this.diagEmitter.event;
118
- }
119
-
120
- public registerSetting(descriptor: SettingDescriptor): IDisposable {
121
- this.descriptors.set(descriptor.key, descriptor);
122
- this.fireChange([descriptor.key], 'default');
123
- return toDisposable(() => {
124
- if (this.descriptors.get(descriptor.key) === descriptor) {
125
- this.descriptors.delete(descriptor.key);
126
- this.fireChange([descriptor.key], 'default');
127
- }
128
- });
129
- }
130
-
131
- public getDescriptors(): SettingDescriptor[] {
132
- return Array.from(this.descriptors.values());
133
- }
134
-
135
- public getJsonSchema(): JsonSchema {
136
- return buildSettingsJsonSchema(this.getDescriptors());
137
- }
138
-
139
- public getDiagnostics(): readonly SettingDiagnostic[] {
140
- return this.diagnostics;
141
- }
142
-
143
- public inspect<T = unknown>(key: string): SettingInspection<T> {
144
- const defaultValue = this.descriptors.get(key)?.defaultValue as T | undefined;
145
- const userValue = this.userValues.get(key) as T | undefined;
146
- const workspaceValue = this.workspaceValues.get(key) as T | undefined;
147
- const overrideValue = this.overrideValues.get(key) as T | undefined;
148
-
149
- if (overrideValue !== undefined) {
150
- return {
151
- key,
152
- defaultValue,
153
- userValue,
154
- workspaceValue,
155
- overrideValue,
156
- effectiveValue: overrideValue,
157
- effectiveSource: 'override'
158
- };
159
- }
160
- if (workspaceValue !== undefined) {
161
- return {
162
- key,
163
- defaultValue,
164
- userValue,
165
- workspaceValue,
166
- overrideValue,
167
- effectiveValue: workspaceValue,
168
- effectiveSource: 'workspace'
169
- };
170
- }
171
- if (userValue !== undefined) {
172
- return {
173
- key,
174
- defaultValue,
175
- userValue,
176
- workspaceValue,
177
- overrideValue,
178
- effectiveValue: userValue,
179
- effectiveSource: 'user'
180
- };
181
- }
182
- return {
183
- key,
184
- defaultValue,
185
- userValue,
186
- workspaceValue,
187
- overrideValue,
188
- effectiveValue: defaultValue,
189
- effectiveSource: 'default'
190
- };
191
- }
192
-
193
- public get<T = unknown>(key: string, fallback?: T): T {
194
- const inspected = this.inspect<T>(key);
195
- if (inspected.effectiveValue !== undefined) {
196
- return inspected.effectiveValue;
197
- }
198
- return fallback as T;
199
- }
200
-
201
- private validateKeyValue(key: string, value: unknown): string | null {
202
- const desc = this.descriptors.get(key);
203
- if (!desc) return null; // allow plugin keys not yet registered
204
- const issues = validateJsonSchema(value, desc.schema, key);
205
- return issues.length > 0 ? issues[0].message : null;
206
- }
207
-
208
- public setUserSetting(key: string, value: unknown): boolean {
209
- const err = this.validateKeyValue(key, value);
210
- if (err) return false;
211
- this.userValues.set(key, value);
212
- this.fireChange([key], 'user');
213
- return true;
214
- }
215
-
216
- public setWorkspaceSetting(key: string, value: unknown): boolean {
217
- const err = this.validateKeyValue(key, value);
218
- if (err) return false;
219
- this.workspaceValues.set(key, value);
220
- this.fireChange([key], 'workspace');
221
- return true;
222
- }
223
-
224
- public resetSetting(key: string): void {
225
- const hadUser = this.userValues.delete(key);
226
- const hadWs = this.workspaceValues.delete(key);
227
- const hadOv = this.overrideValues.delete(key);
228
- if (hadUser || hadWs || hadOv) {
229
- this.fireChange([key], 'user');
230
- }
231
- }
232
-
233
- public getWorkspaceSettings(): Record<string, unknown> {
234
- const out: Record<string, unknown> = {};
235
- const keys = Array.from(this.workspaceValues.keys()).sort();
236
- for (const k of keys) {
237
- out[k] = this.workspaceValues.get(k);
238
- }
239
- return out;
240
- }
241
-
242
- public async resetScopedSetting(key: string, scope: ConfigurationResetScope): Promise<void> {
243
- if (scope === 'user') {
244
- if (this.userValues.delete(key)) {
245
- this.fireChange([key], 'user');
246
- }
247
- return;
248
- }
249
- if (scope === 'workspace') {
250
- if (this.workspaceValues.delete(key)) {
251
- this.fireChange([key], 'workspace');
252
- }
253
- return;
254
- }
255
- const hadUser = this.userValues.delete(key);
256
- const hadWs = this.workspaceValues.delete(key);
257
- const hadOv = this.overrideValues.delete(key);
258
- if (hadUser || hadWs || hadOv) {
259
- this.fireChange([key], 'user');
260
- }
261
- }
262
-
263
- public async resetAllSettings(scope: ConfigurationResetScope = 'all'): Promise<void> {
264
- if (scope === 'user') {
265
- const affected = new Set<string>(this.userValues.keys());
266
- this.userValues.clear();
267
- if (affected.size > 0) {
268
- this.fireChange(affected, 'user');
269
- }
270
- return;
271
- }
272
- if (scope === 'workspace') {
273
- const affected = new Set<string>(this.workspaceValues.keys());
274
- this.workspaceValues.clear();
275
- if (this.diagnostics.length > 0) {
276
- this.updateDiagnostics([]);
277
- }
278
- if (affected.size > 0) {
279
- this.fireChange(affected, 'workspace');
280
- }
281
- return;
282
- }
283
- const affected = new Set<string>([
284
- ...this.userValues.keys(),
285
- ...this.workspaceValues.keys(),
286
- ...this.overrideValues.keys()
287
- ]);
288
- this.userValues.clear();
289
- this.workspaceValues.clear();
290
- this.overrideValues.clear();
291
- if (this.diagnostics.length > 0) {
292
- this.updateDiagnostics([]);
293
- }
294
- if (affected.size > 0) {
295
- this.fireChange(affected, 'user');
296
- }
297
- }
298
-
299
- public loadWorkspaceSettingsJson(
300
- rawJsonc: string,
301
- filePath = '.codelab/settings.json'
302
- ): readonly SettingDiagnostic[] {
303
- const nextDiags: SettingDiagnostic[] = [];
304
- const affected = new Set<string>(this.workspaceValues.keys());
305
-
306
- if (!rawJsonc || !rawJsonc.trim()) {
307
- this.workspaceValues.clear();
308
- this.updateDiagnostics([]);
309
- if (affected.size > 0) this.fireChange(affected, 'workspace');
310
- return [];
311
- }
312
-
313
- const parsed = parseJsonc<Record<string, unknown>>(rawJsonc);
314
- for (const pe of parsed.errors) {
315
- nextDiags.push({
316
- file: filePath,
317
- message: `Invalid settings JSONC: ${pe.message}`,
318
- line: pe.line,
319
- column: pe.column,
320
- severity: 'error'
321
- });
322
- }
323
-
324
- if (parsed.value === undefined || typeof parsed.value !== 'object' || parsed.value === null || Array.isArray(parsed.value)) {
325
- if (parsed.errors.length === 0) {
326
- nextDiags.push({
327
- file: filePath,
328
- message: 'Settings root must be a JSON object',
329
- line: 1,
330
- column: 1,
331
- severity: 'error'
332
- });
333
- }
334
- // Keep safe defaults by clearing invalid workspace overrides
335
- this.workspaceValues.clear();
336
- this.updateDiagnostics(nextDiags);
337
- if (affected.size > 0) this.fireChange(affected, 'workspace');
338
- return nextDiags;
339
- }
340
-
341
- this.workspaceValues.clear();
342
- for (const [key, val] of Object.entries(parsed.value)) {
343
- affected.add(key);
344
- const schemaError = this.validateKeyValue(key, val);
345
- if (schemaError) {
346
- const fallback = this.userValues.has(key)
347
- ? this.userValues.get(key)
348
- : this.descriptors.get(key)?.defaultValue;
349
- nextDiags.push({
350
- file: filePath,
351
- key,
352
- message: `Invalid "${key}": ${schemaError}. Falling back to ${JSON.stringify(fallback)}.`,
353
- line: findKeyLine(rawJsonc, key),
354
- column: 3,
355
- severity: 'warning'
356
- });
357
- } else {
358
- this.workspaceValues.set(key, val);
359
- }
360
- }
361
-
362
- this.updateDiagnostics(nextDiags);
363
- if (affected.size > 0) {
364
- this.fireChange(affected, 'workspace');
365
- }
366
- return nextDiags;
367
- }
368
-
369
- public setOverrides(overrides: Readonly<Record<string, unknown>>): void {
370
- const affected = new Set<string>(this.overrideValues.keys());
371
- this.overrideValues.clear();
372
- for (const [key, val] of Object.entries(overrides)) {
373
- if (this.validateKeyValue(key, val) === null) {
374
- this.overrideValues.set(key, val);
375
- affected.add(key);
376
- }
377
- }
378
- if (affected.size > 0) {
379
- this.fireChange(affected, 'override');
380
- }
381
- }
382
-
383
- public toWorkspaceJsonString(): string {
384
- return JSON.stringify(this.getWorkspaceSettings(), null, 2) + '\n';
385
- }
386
-
387
- public exportProfile(): string {
388
- const userObj: Record<string, unknown> = {};
389
- for (const [k, v] of this.userValues.entries()) userObj[k] = v;
390
- const wsObj: Record<string, unknown> = {};
391
- for (const [k, v] of this.workspaceValues.entries()) wsObj[k] = v;
392
- return JSON.stringify(
393
- {
394
- version: 1,
395
- user: userObj,
396
- workspace: wsObj
397
- },
398
- null,
399
- 2
400
- );
401
- }
402
-
403
- public importProfile(rawJsonc: string): readonly SettingDiagnostic[] {
404
- const parsed = parseJsonc<{ user?: Record<string, unknown>; workspace?: Record<string, unknown> }>(rawJsonc);
405
- if (!parsed.value || typeof parsed.value !== 'object') {
406
- return [
407
- {
408
- file: 'settings-profile.json',
409
- message: parsed.errors[0]?.message ?? 'Invalid settings profile JSON',
410
- line: 1,
411
- column: 1,
412
- severity: 'error'
413
- }
414
- ];
415
- }
416
- const diags: SettingDiagnostic[] = [];
417
- const affected = new Set<string>();
418
- const userIn = parsed.value.user ?? (
419
- !('workspace' in parsed.value) ? (parsed.value as unknown as Record<string, unknown>) : undefined
420
- );
421
- if (userIn && typeof userIn === 'object') {
422
- for (const [k, v] of Object.entries(userIn)) {
423
- const err = this.validateKeyValue(k, v);
424
- if (err) {
425
- diags.push({
426
- file: 'settings-profile.json',
427
- key: k,
428
- message: `Invalid "${k}": ${err}`,
429
- line: 1,
430
- column: 1,
431
- severity: 'warning'
432
- });
433
- } else {
434
- this.userValues.set(k, v);
435
- affected.add(k);
436
- }
437
- }
438
- }
439
- if (parsed.value.workspace && typeof parsed.value.workspace === 'object') {
440
- for (const [k, v] of Object.entries(parsed.value.workspace)) {
441
- const err = this.validateKeyValue(k, v);
442
- if (!err) {
443
- this.workspaceValues.set(k, v);
444
- affected.add(k);
445
- }
446
- }
447
- }
448
- if (affected.size > 0) this.fireChange(affected, 'user');
449
- return diags;
450
- }
451
-
452
- public toUrlParam(): string {
453
- const effectiveDiff: Record<string, unknown> = {};
454
- for (const desc of this.descriptors.values()) {
455
- const val = this.get(desc.key);
456
- if (JSON.stringify(val) !== JSON.stringify(desc.defaultValue)) {
457
- effectiveDiff[desc.key] = val;
458
- }
459
- }
460
- const json = JSON.stringify(effectiveDiff);
461
- if (typeof btoa === 'function') {
462
- return btoa(encodeURIComponent(json));
463
- }
464
- return encodeURIComponent(json);
465
- }
466
-
467
- public applyUrlParam(encoded: string): readonly SettingDiagnostic[] {
468
- if (!encoded) return [];
469
- let json = '';
470
- try {
471
- json = typeof atob === 'function' ? decodeURIComponent(atob(encoded)) : decodeURIComponent(encoded);
472
- } catch {
473
- try {
474
- json = decodeURIComponent(encoded);
475
- } catch {
476
- return [{ file: 'url', message: 'Invalid encoded URL settings', line: 1, column: 1, severity: 'warning' }];
477
- }
478
- }
479
- const parsed = parseJsonc<Record<string, unknown>>(json);
480
- if (!parsed.value || typeof parsed.value !== 'object' || Array.isArray(parsed.value)) {
481
- return [{ file: 'url', message: 'URL settings must decode to an object', line: 1, column: 1, severity: 'warning' }];
482
- }
483
- this.setOverrides(parsed.value);
484
- return [];
485
- }
486
-
487
- private updateDiagnostics(next: SettingDiagnostic[]): void {
488
- this.diagnostics = next;
489
- this.diagEmitter.fire(this.diagnostics);
490
- }
491
-
492
- private fireChange(keys: Iterable<string>, source: ConfigurationTarget): void {
493
- const affectedKeys = new Set<string>(keys);
494
- this.changeEmitter.fire({
495
- affectedKeys,
496
- source,
497
- affectsConfiguration: (prefixOrKey: string) => {
498
- if (affectedKeys.has(prefixOrKey)) return true;
499
- const prefix = prefixOrKey.endsWith('.') ? prefixOrKey : `${prefixOrKey}.`;
500
- for (const k of affectedKeys) {
501
- if (k.startsWith(prefix)) return true;
502
- }
503
- return false;
504
- }
505
- });
506
- }
507
-
508
- public dispose(): void {
509
- this.descriptors.clear();
510
- this.userValues.clear();
511
- this.workspaceValues.clear();
512
- this.overrideValues.clear();
513
- this.changeEmitter.dispose();
514
- this.diagEmitter.dispose();
515
- }
516
- }
517
-
518
- export function parseTasksConfig(
519
- rawJsonc: string,
520
- filePath = '.codelab/tasks.json'
521
- ): { tasks: WorkspaceTaskDefinition[]; diagnostics: SettingDiagnostic[] } {
522
- const diagnostics: SettingDiagnostic[] = [];
523
- if (!rawJsonc || !rawJsonc.trim()) return { tasks: [], diagnostics };
524
- const parsed = parseJsonc<{ version?: string; tasks?: unknown[] }>(rawJsonc);
525
- for (const err of parsed.errors) {
526
- diagnostics.push({
527
- file: filePath,
528
- message: `Invalid tasks.json: ${err.message}`,
529
- line: err.line,
530
- column: err.column,
531
- severity: 'error'
532
- });
533
- }
534
- if (!parsed.value) return { tasks: [], diagnostics };
535
- const schemaIssues = validateJsonSchema(parsed.value, TASKS_JSON_SCHEMA, 'tasks');
536
- for (const issue of schemaIssues) {
537
- diagnostics.push({
538
- file: filePath,
539
- message: `${issue.path}: ${issue.message}`,
540
- line: 1,
541
- column: 1,
542
- severity: 'warning'
543
- });
544
- }
545
- const rawTasks = Array.isArray(parsed.value.tasks) ? parsed.value.tasks : [];
546
- const tasks: WorkspaceTaskDefinition[] = [];
547
- for (let i = 0; i < rawTasks.length; i++) {
548
- const item = rawTasks[i];
549
- if (typeof item === 'object' && item !== null) {
550
- const rec = item as Record<string, unknown>;
551
- if (typeof rec.label === 'string' && typeof rec.command === 'string' && rec.command.trim()) {
552
- tasks.push({
553
- id: typeof rec.id === 'string' && rec.id ? rec.id : `task-${i + 1}`,
554
- label: rec.label,
555
- command: rec.command,
556
- group:
557
- rec.group === 'run' || rec.group === 'build' || rec.group === 'test' || rec.group === 'dev'
558
- ? rec.group
559
- : undefined,
560
- runOn: rec.runOn === 'folderOpen' ? 'folderOpen' : 'manual',
561
- cwd: typeof rec.cwd === 'string' ? rec.cwd : undefined,
562
- env:
563
- typeof rec.env === 'object' && rec.env !== null && !Array.isArray(rec.env)
564
- ? (rec.env as Record<string, string>)
565
- : undefined
566
- });
567
- }
568
- }
569
- }
570
- return { tasks, diagnostics };
571
- }
572
-
573
- export function parseExtensionsConfig(
574
- rawJsonc: string,
575
- filePath = '.codelab/extensions.json'
576
- ): { config: WorkspaceExtensionsConfig; diagnostics: SettingDiagnostic[] } {
577
- const diagnostics: SettingDiagnostic[] = [];
578
- const empty: WorkspaceExtensionsConfig = { recommendations: [], autoActivate: [] };
579
- if (!rawJsonc || !rawJsonc.trim()) return { config: empty, diagnostics };
580
- const parsed = parseJsonc<Record<string, unknown>>(rawJsonc);
581
- for (const err of parsed.errors) {
582
- diagnostics.push({
583
- file: filePath,
584
- message: `Invalid extensions.json: ${err.message}`,
585
- line: err.line,
586
- column: err.column,
587
- severity: 'error'
588
- });
589
- }
590
- if (!parsed.value || typeof parsed.value !== 'object' || Array.isArray(parsed.value)) {
591
- return { config: empty, diagnostics };
592
- }
593
- for (const issue of validateJsonSchema(parsed.value, EXTENSIONS_JSON_SCHEMA, 'extensions')) {
594
- diagnostics.push({
595
- file: filePath,
596
- message: `${issue.path}: ${issue.message}`,
597
- line: 1,
598
- column: 1,
599
- severity: 'warning'
600
- });
601
- }
602
- const recs = Array.isArray(parsed.value.recommendations)
603
- ? parsed.value.recommendations.filter((x): x is string => typeof x === 'string')
604
- : [];
605
- const auto = Array.isArray(parsed.value.autoActivate)
606
- ? parsed.value.autoActivate.filter((x): x is string => typeof x === 'string')
607
- : [];
608
- return { config: { recommendations: recs, autoActivate: auto }, diagnostics };
609
- }
@@ -1,38 +0,0 @@
1
- export {
2
- type JsoncParseError,
3
- type JsoncParseResult,
4
- stripJsonCommentsAndTrailingCommas,
5
- parseJsonc
6
- } from './jsonc';
7
-
8
- export {
9
- type JsonSchemaType,
10
- type JsonSchema,
11
- type SchemaValidationIssue,
12
- validateJsonSchema
13
- } from './schema';
14
-
15
- export {
16
- type SettingCategory,
17
- type SettingDescriptor,
18
- BUILTIN_SETTINGS,
19
- buildSettingsJsonSchema,
20
- KEYBINDINGS_JSON_SCHEMA,
21
- TASKS_JSON_SCHEMA,
22
- EXTENSIONS_JSON_SCHEMA
23
- } from './builtin-schemas';
24
-
25
- export {
26
- type ConfigurationTarget,
27
- type ConfigurationResetScope,
28
- type SettingDiagnostic,
29
- type ConfigurationChangeEvent,
30
- type SettingInspection,
31
- type WorkspaceTaskDefinition,
32
- type WorkspaceExtensionsConfig,
33
- type IConfigurationService,
34
- IConfigurationServiceId,
35
- ConfigurationService,
36
- parseTasksConfig,
37
- parseExtensionsConfig
38
- } from './configuration-service';