@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,125 +0,0 @@
1
- import {
2
- CodeLabError,
3
- createServiceId,
4
- Emitter,
5
- type Event,
6
- type IDisposable
7
- } from '@code-lab/core';
8
-
9
- export const SAFE_IFRAME_SANDBOX = 'allow-scripts allow-forms allow-modals';
10
-
11
- export interface PreviewPolicyOptions {
12
- readonly allowExternalNetwork?: boolean;
13
- readonly allowedOrigins?: readonly string[];
14
- }
15
-
16
- function sanitizeSourceList(origins: readonly string[] | undefined): string[] {
17
- if (!origins) return [];
18
- const valid: string[] = [];
19
- for (const raw of origins) {
20
- const trimmed = raw.trim();
21
- if (/^https?:\/\/[A-Za-z0-9.-]+(?::\d+)?$/.test(trimmed)) {
22
- valid.push(trimmed);
23
- }
24
- }
25
- return valid;
26
- }
27
-
28
- export function buildPreviewCsp(options: PreviewPolicyOptions = {}): string {
29
- const extra = sanitizeSourceList(options.allowedOrigins);
30
- const netSources = options.allowExternalNetwork
31
- ? ["'self'", 'https:', 'http:', 'ws:', 'wss:', ...extra]
32
- : ["'self'", ...extra];
33
-
34
- return [
35
- "default-src 'self' data: blob:",
36
- `script-src 'self' 'unsafe-inline' 'unsafe-eval' blob: https://esm.sh https://cdn.jsdelivr.net ${extra.join(' ')}`.trim(),
37
- "style-src 'self' 'unsafe-inline' https:",
38
- "img-src 'self' data: blob: https:",
39
- "font-src 'self' data: https:",
40
- `connect-src ${netSources.join(' ')}`,
41
- "frame-ancestors 'self'",
42
- "base-uri 'none'",
43
- "object-src 'none'"
44
- ].join('; ');
45
- }
46
-
47
- export function sanitizePreviewUrl(rawUrl: string): string {
48
- const trimmed = String(rawUrl ?? '').trim();
49
- if (!trimmed) return 'about:blank';
50
- if (/^(?:javascript|vbscript|data):/i.test(trimmed)) {
51
- throw new CodeLabError('ERR_SECURITY_POLICY', `Blocked unsafe preview URL scheme: ${trimmed}`);
52
- }
53
- return trimmed;
54
- }
55
-
56
- export interface PreviewState {
57
- readonly instanceId: string;
58
- readonly port: number;
59
- readonly path: string;
60
- readonly reloadNonce: number;
61
- readonly csp: string;
62
- }
63
-
64
- export interface IPreviewService extends IDisposable {
65
- readonly state: PreviewState;
66
- readonly onDidChangePreview: Event<PreviewState>;
67
- navigate(port: number, path?: string): void;
68
- reload(): void;
69
- updatePolicy(options: PreviewPolicyOptions): void;
70
- }
71
-
72
- export const IPreviewServiceId = createServiceId<IPreviewService>('code-lab.preview');
73
-
74
- export class PreviewService implements IPreviewService {
75
- private current: PreviewState;
76
- private readonly emitter = new Emitter<PreviewState>({ name: 'preview.change' });
77
-
78
- public constructor(instanceId: string, initialPort = 3000, policy: PreviewPolicyOptions = {}) {
79
- this.current = {
80
- instanceId,
81
- port: initialPort,
82
- path: '/',
83
- reloadNonce: 0,
84
- csp: buildPreviewCsp(policy)
85
- };
86
- }
87
-
88
- public get state(): PreviewState {
89
- return this.current;
90
- }
91
-
92
- public get onDidChangePreview(): Event<PreviewState> {
93
- return this.emitter.event;
94
- }
95
-
96
- public navigate(port: number, path = '/'): void {
97
- const cleanPath = sanitizePreviewUrl(path);
98
- this.current = {
99
- ...this.current,
100
- port: Math.max(1, Math.min(65535, Math.trunc(port))),
101
- path: cleanPath.startsWith('/') ? cleanPath : '/' + cleanPath
102
- };
103
- this.emitter.fire(this.current);
104
- }
105
-
106
- public reload(): void {
107
- this.current = {
108
- ...this.current,
109
- reloadNonce: this.current.reloadNonce + 1
110
- };
111
- this.emitter.fire(this.current);
112
- }
113
-
114
- public updatePolicy(options: PreviewPolicyOptions): void {
115
- this.current = {
116
- ...this.current,
117
- csp: buildPreviewCsp(options)
118
- };
119
- this.emitter.fire(this.current);
120
- }
121
-
122
- public dispose(): void {
123
- this.emitter.dispose();
124
- }
125
- }
@@ -1,22 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "lib": ["ES2022", "DOM"],
7
- "strict": true,
8
- "noImplicitAny": true,
9
- "strictNullChecks": true,
10
- "noUnusedLocals": true,
11
- "noUnusedParameters": true,
12
- "noImplicitReturns": true,
13
- "noFallthroughCasesInSwitch": true,
14
- "noEmit": true,
15
- "skipLibCheck": true,
16
- "forceConsistentCasingInFileNames": true,
17
- "paths": {
18
- "@code-lab/core": ["../core/src/index.ts"]
19
- }
20
- },
21
- "include": ["src/**/*.ts"]
22
- }
@@ -1,3 +0,0 @@
1
- # `@code-lab/runtime`
2
-
3
- Layer 2 (`services`) sandbox execution contract (`IRuntimeService`) and `WorkerHostSupervisor` managing watchdog timeouts, `AbortController` cancellation, and worker status events.
@@ -1,17 +0,0 @@
1
- {
2
- "name": "@code-lab/runtime",
3
- "version": "0.7.0",
4
- "description": "Typed sandbox execution service & worker host supervisor for CodeLab.",
5
- "type": "module",
6
- "main": "./src/index.ts",
7
- "types": "./src/index.ts",
8
- "exports": {
9
- ".": "./src/index.ts"
10
- },
11
- "dependencies": {
12
- "@code-lab/core": "workspace:*",
13
- "@code-lab/fs": "workspace:*"
14
- },
15
- "sideEffects": false,
16
- "license": "MIT"
17
- }
@@ -1,134 +0,0 @@
1
- import {
2
- CodeLabError,
3
- createServiceId,
4
- Emitter,
5
- type Event,
6
- type IDisposable
7
- } from '@code-lab/core';
8
- import type { IFileSystemService } from '@code-lab/fs';
9
-
10
- export type RuntimeStatus = 'idle' | 'running' | 'stopped' | 'error';
11
-
12
- export interface RuntimeExecutionRequest {
13
- readonly entry: string;
14
- readonly mode?: 'run' | 'test' | 'repl';
15
- readonly cwd?: string;
16
- readonly env?: Readonly<Record<string, string>>;
17
- readonly stdin?: string;
18
- readonly timeoutMs?: number;
19
- }
20
-
21
- export interface RuntimeExecutionResult {
22
- readonly ok: boolean;
23
- readonly exitCode: number;
24
- readonly stdout: string;
25
- readonly stderr: string;
26
- readonly durationMs: number;
27
- readonly timedOut?: boolean;
28
- }
29
-
30
- export type RuntimeExecutorDelegate = (
31
- req: RuntimeExecutionRequest & { files: Record<string, string>; signal: AbortSignal }
32
- ) => Promise<RuntimeExecutionResult>;
33
-
34
- export interface IRuntimeService extends IDisposable {
35
- readonly status: RuntimeStatus;
36
- readonly activeRunCount: number;
37
- readonly onDidChangeStatus: Event<RuntimeStatus>;
38
- execute(request: RuntimeExecutionRequest): Promise<RuntimeExecutionResult>;
39
- cancelAll(): void;
40
- }
41
-
42
- export const IRuntimeServiceId = createServiceId<IRuntimeService>('code-lab.runtime');
43
-
44
- export class WorkerHostSupervisor implements IRuntimeService {
45
- private currentStatus: RuntimeStatus = 'idle';
46
- private readonly activeControllers = new Set<AbortController>();
47
- private readonly statusEmitter = new Emitter<RuntimeStatus>({ name: 'runtime.status' });
48
- private readonly fs: IFileSystemService;
49
- private readonly delegate: RuntimeExecutorDelegate;
50
- private disposed = false;
51
-
52
- public constructor(fs: IFileSystemService, delegate: RuntimeExecutorDelegate) {
53
- this.fs = fs;
54
- this.delegate = delegate;
55
- }
56
-
57
- public get status(): RuntimeStatus {
58
- return this.currentStatus;
59
- }
60
-
61
- public get activeRunCount(): number {
62
- return this.activeControllers.size;
63
- }
64
-
65
- public get onDidChangeStatus(): Event<RuntimeStatus> {
66
- return this.statusEmitter.event;
67
- }
68
-
69
- private setStatus(next: RuntimeStatus): void {
70
- if (this.currentStatus === next) return;
71
- this.currentStatus = next;
72
- this.statusEmitter.fire(next);
73
- }
74
-
75
- public async execute(request: RuntimeExecutionRequest): Promise<RuntimeExecutionResult> {
76
- if (this.disposed) {
77
- throw new CodeLabError('ERR_DISPOSED', 'RuntimeService has been disposed');
78
- }
79
- const controller = new AbortController();
80
- this.activeControllers.add(controller);
81
- this.setStatus('running');
82
-
83
- const timeoutMs = request.timeoutMs ?? 8000;
84
- const start = Date.now();
85
- let timedOut = false;
86
- const timer = setTimeout(() => {
87
- timedOut = true;
88
- controller.abort();
89
- }, timeoutMs);
90
-
91
- try {
92
- const files = this.fs.toRecord('/workspace');
93
- const res = await this.delegate({
94
- ...request,
95
- files,
96
- signal: controller.signal
97
- });
98
- this.setStatus(this.activeControllers.size > 1 ? 'running' : res.ok ? 'idle' : 'error');
99
- return res;
100
- } catch (err) {
101
- this.setStatus('error');
102
- const message = err instanceof Error ? err.message : String(err);
103
- return {
104
- ok: false,
105
- exitCode: timedOut ? 124 : 1,
106
- stdout: '',
107
- stderr: timedOut ? `Execution timed out after ${timeoutMs}ms` : message,
108
- durationMs: Date.now() - start,
109
- timedOut
110
- };
111
- } finally {
112
- clearTimeout(timer);
113
- this.activeControllers.delete(controller);
114
- if (this.activeControllers.size === 0 && this.currentStatus === 'running') {
115
- this.setStatus('idle');
116
- }
117
- }
118
- }
119
-
120
- public cancelAll(): void {
121
- for (const ctrl of this.activeControllers) {
122
- ctrl.abort();
123
- }
124
- this.activeControllers.clear();
125
- this.setStatus('stopped');
126
- }
127
-
128
- public dispose(): void {
129
- if (this.disposed) return;
130
- this.disposed = true;
131
- this.cancelAll();
132
- this.statusEmitter.dispose();
133
- }
134
- }
@@ -1,23 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "lib": ["ES2022", "DOM"],
7
- "strict": true,
8
- "noImplicitAny": true,
9
- "strictNullChecks": true,
10
- "noUnusedLocals": true,
11
- "noUnusedParameters": true,
12
- "noImplicitReturns": true,
13
- "noFallthroughCasesInSwitch": true,
14
- "noEmit": true,
15
- "skipLibCheck": true,
16
- "forceConsistentCasingInFileNames": true,
17
- "paths": {
18
- "@code-lab/core": ["../core/src/index.ts"],
19
- "@code-lab/fs": ["../fs/src/index.ts"]
20
- }
21
- },
22
- "include": ["src/**/*.ts"]
23
- }
@@ -1,7 +0,0 @@
1
- # `@code-lab/settings`
2
-
3
- Layer 1 (`platform`) VS Code-inspired configuration system for **CodeLab**:
4
-
5
- - **Layered Precedence**: `default` (plugin/built-in schema defaults) → `user` → `workspace` (`.codelab/settings.json`) → `override` (URL query/embed config).
6
- - **JSONC Parser**: Supports `//` line comments, `/* ... */` block comments, and trailing commas with exact 1-based line/column diagnostics.
7
- - **CSP-Safe JSON Schema Validator**: Validates `.codelab/settings.json`, `.codelab/keybindings.json`, `.codelab/tasks.json`, and `.codelab/extensions.json` without `new Function`, automatically falling back invalid keys to safe defaults while reporting structured diagnostics.
@@ -1,16 +0,0 @@
1
- {
2
- "name": "@code-lab/settings",
3
- "version": "0.7.0",
4
- "description": "Layered configuration service (defaults -> user -> .codelab/settings.json -> URL/embed), JSONC parser, and CSP-safe JSON Schema validator.",
5
- "type": "module",
6
- "main": "./src/index.ts",
7
- "types": "./src/index.ts",
8
- "exports": {
9
- ".": "./src/index.ts"
10
- },
11
- "dependencies": {
12
- "@code-lab/core": "workspace:*"
13
- },
14
- "sideEffects": false,
15
- "license": "MIT"
16
- }
@@ -1,262 +0,0 @@
1
- import type { JsonSchema } from './schema';
2
-
3
- export type SettingCategory =
4
- | 'Editor'
5
- | 'Workbench'
6
- | 'Files'
7
- | 'Terminal'
8
- | 'Preview'
9
- | 'Runtime'
10
- | 'SQL';
11
-
12
- export interface SettingDescriptor<T = unknown> {
13
- readonly key: string;
14
- readonly category: SettingCategory;
15
- readonly title: string;
16
- readonly description: string;
17
- readonly defaultValue: T;
18
- readonly schema: JsonSchema;
19
- }
20
-
21
- export const BUILTIN_SETTINGS: readonly SettingDescriptor[] = [
22
- {
23
- key: 'editor.fontSize',
24
- category: 'Editor',
25
- title: 'Editor Font Size',
26
- description: 'Controls the font size in pixels in the code editor.',
27
- defaultValue: 13,
28
- schema: { type: 'integer', minimum: 10, maximum: 32, default: 13 }
29
- },
30
- {
31
- key: 'editor.tabSize',
32
- category: 'Editor',
33
- title: 'Tab Size',
34
- description: 'The number of spaces a tab is equal to.',
35
- defaultValue: 2,
36
- schema: { type: 'integer', minimum: 1, maximum: 8, default: 2 }
37
- },
38
- {
39
- key: 'editor.wordWrap',
40
- category: 'Editor',
41
- title: 'Word Wrap',
42
- description: 'Controls how lines should wrap in the editor.',
43
- defaultValue: 'off',
44
- schema: { type: 'string', enum: ['off', 'on', 'wordWrapColumn'], default: 'off' }
45
- },
46
- {
47
- key: 'editor.minimap.enabled',
48
- category: 'Editor',
49
- title: 'Minimap Enabled',
50
- description: 'Controls whether the editor minimap is shown.',
51
- defaultValue: false,
52
- schema: { type: 'boolean', default: false }
53
- },
54
- {
55
- key: 'editor.lineNumbers',
56
- category: 'Editor',
57
- title: 'Line Numbers',
58
- description: 'Controls the display of line numbers in the editor gutter.',
59
- defaultValue: 'on',
60
- schema: { type: 'string', enum: ['on', 'off', 'relative'], default: 'on' }
61
- },
62
- {
63
- key: 'editor.formatOnSave',
64
- category: 'Editor',
65
- title: 'Format On Save',
66
- description: 'Format a file automatically when saving.',
67
- defaultValue: false,
68
- schema: { type: 'boolean', default: false }
69
- },
70
- {
71
- key: 'workbench.colorTheme',
72
- category: 'Workbench',
73
- title: 'Color Theme',
74
- description: 'Specifies the color theme used in the workbench (`dark`, `light`, or `high-contrast`).',
75
- defaultValue: 'dark',
76
- schema: { type: 'string', enum: ['dark', 'light', 'high-contrast'], default: 'dark' }
77
- },
78
- {
79
- key: 'workbench.sideBar.visible',
80
- category: 'Workbench',
81
- title: 'Sidebar Visible',
82
- description: 'Controls the visibility of the file explorer / activity sidebar.',
83
- defaultValue: true,
84
- schema: { type: 'boolean', default: true }
85
- },
86
- {
87
- key: 'workbench.sidebar.defaultLocation',
88
- category: 'Workbench',
89
- title: 'Sidebar Location',
90
- description: 'Controls whether the primary sidebar is docked on the left or right.',
91
- defaultValue: 'left',
92
- schema: { type: 'string', enum: ['left', 'right'], default: 'left' }
93
- },
94
- {
95
- key: 'workbench.statusBar.visible',
96
- category: 'Workbench',
97
- title: 'Status Bar Visible',
98
- description: 'Controls the visibility of the status bar at the bottom of the workbench.',
99
- defaultValue: true,
100
- schema: { type: 'boolean', default: true }
101
- },
102
- {
103
- key: 'workbench.panel.defaultTab',
104
- category: 'Workbench',
105
- title: 'Default Bottom Panel Tab',
106
- description: 'Default active tab in the bottom panel.',
107
- defaultValue: 'terminal',
108
- schema: {
109
- type: 'string',
110
- enum: [
111
- 'terminal',
112
- 'problems',
113
- 'tests',
114
- 'stdin',
115
- 'ports',
116
- 'preview',
117
- 'network',
118
- 'inspector',
119
- 'observability',
120
- 'sql-results'
121
- ],
122
- default: 'terminal'
123
- }
124
- },
125
- {
126
- key: 'files.autoSave',
127
- category: 'Files',
128
- title: 'Auto Save',
129
- description: 'Controls automatic persistence of dirty files.',
130
- defaultValue: 'afterDelay',
131
- schema: { type: 'string', enum: ['afterDelay', 'off'], default: 'afterDelay' }
132
- },
133
- {
134
- key: 'files.autoSaveDelay',
135
- category: 'Files',
136
- title: 'Auto Save Delay (ms)',
137
- description: 'Controls the delay in milliseconds after which a dirty file is saved automatically.',
138
- defaultValue: 300,
139
- schema: { type: 'integer', minimum: 50, maximum: 30000, default: 300 }
140
- },
141
- {
142
- key: 'files.exclude',
143
- category: 'Files',
144
- title: 'Excluded File Globs',
145
- description: 'Configure glob patterns for excluding files and folders from the explorer and search.',
146
- defaultValue: ['**/node_modules/**', '**/.git/**'],
147
- schema: { type: 'array', items: { type: 'string' }, default: ['**/node_modules/**', '**/.git/**'] }
148
- },
149
- {
150
- key: 'terminal.fontSize',
151
- category: 'Terminal',
152
- title: 'Terminal Font Size',
153
- description: 'Controls the font size in pixels of the integrated PTY terminal.',
154
- defaultValue: 13,
155
- schema: { type: 'integer', minimum: 10, maximum: 28, default: 13 }
156
- },
157
- {
158
- key: 'terminal.scrollback',
159
- category: 'Terminal',
160
- title: 'Terminal Scrollback',
161
- description: 'Controls the maximum amount of lines the terminal keeps in its buffer.',
162
- defaultValue: 1000,
163
- schema: { type: 'integer', minimum: 100, maximum: 50000, default: 1000 }
164
- },
165
- {
166
- key: 'preview.autoReload',
167
- category: 'Preview',
168
- title: 'Preview Auto Reload',
169
- description: 'Automatically refresh the web preview iframe when workspace files change.',
170
- defaultValue: true,
171
- schema: { type: 'boolean', default: true }
172
- },
173
- {
174
- key: 'runtime.timeoutMs',
175
- category: 'Runtime',
176
- title: 'Execution Watchdog Timeout (ms)',
177
- description: 'Maximum execution time in milliseconds before terminating runaway sandbox workers.',
178
- defaultValue: 8000,
179
- schema: { type: 'integer', minimum: 500, maximum: 120000, default: 8000 }
180
- },
181
- {
182
- key: 'sql.defaultDialect',
183
- category: 'SQL',
184
- title: 'Default SQL Dialect',
185
- description: 'Default SQL dialect used for highlighting, formatting, and completions.',
186
- defaultValue: 'postgres',
187
- schema: { type: 'string', enum: ['postgres', 'sqlite'], default: 'postgres' }
188
- }
189
- ];
190
-
191
- export function buildSettingsJsonSchema(descriptors: readonly SettingDescriptor[]): JsonSchema {
192
- const properties: Record<string, JsonSchema> = {};
193
- for (const d of descriptors) {
194
- properties[d.key] = {
195
- ...d.schema,
196
- title: d.title,
197
- description: d.description,
198
- default: d.defaultValue
199
- };
200
- }
201
- return {
202
- $schema: 'http://json-schema.org/draft-07/schema#',
203
- title: 'CodeLab Workspace & User Settings (.codelab/settings.json)',
204
- type: 'object',
205
- properties,
206
- additionalProperties: true
207
- };
208
- }
209
-
210
- export const KEYBINDINGS_JSON_SCHEMA: JsonSchema = {
211
- $schema: 'http://json-schema.org/draft-07/schema#',
212
- title: 'CodeLab Keybindings (.codelab/keybindings.json)',
213
- type: 'array',
214
- items: {
215
- type: 'object',
216
- required: ['key', 'command'],
217
- properties: {
218
- key: { type: 'string', minLength: 1, description: 'Key chord such as Mod+Enter or Shift+Alt+F' },
219
- command: { type: 'string', minLength: 1, description: 'Command ID (prefix with - to unbind)' },
220
- when: { type: 'string', description: 'Optional context-key expression' }
221
- },
222
- additionalProperties: true
223
- }
224
- };
225
-
226
- export const TASKS_JSON_SCHEMA: JsonSchema = {
227
- $schema: 'http://json-schema.org/draft-07/schema#',
228
- title: 'CodeLab Workspace Tasks (.codelab/tasks.json)',
229
- type: 'object',
230
- required: ['version', 'tasks'],
231
- properties: {
232
- version: { type: 'string', enum: ['1.0', '2.0.0'] },
233
- tasks: {
234
- type: 'array',
235
- items: {
236
- type: 'object',
237
- required: ['label', 'command'],
238
- properties: {
239
- id: { type: 'string' },
240
- label: { type: 'string', minLength: 1 },
241
- command: { type: 'string', minLength: 1 },
242
- group: { type: 'string', enum: ['run', 'build', 'test', 'dev'] },
243
- runOn: { type: 'string', enum: ['manual', 'folderOpen'] },
244
- cwd: { type: 'string' }
245
- },
246
- additionalProperties: true
247
- }
248
- }
249
- },
250
- additionalProperties: true
251
- };
252
-
253
- export const EXTENSIONS_JSON_SCHEMA: JsonSchema = {
254
- $schema: 'http://json-schema.org/draft-07/schema#',
255
- title: 'CodeLab Workspace Extensions (.codelab/extensions.json)',
256
- type: 'object',
257
- properties: {
258
- recommendations: { type: 'array', items: { type: 'string' } },
259
- autoActivate: { type: 'array', items: { type: 'string' } }
260
- },
261
- additionalProperties: true
262
- };