@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.
Files changed (131) hide show
  1. package/ARCHITECTURE.md +2 -2
  2. package/CHANGELOG.md +35 -0
  3. package/README.md +38 -1
  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 +19 -1
  9. package/dist/code-lab.esm.js +933 -1685
  10. package/dist/code-lab.js +932 -1684
  11. package/dist/extensions/cpp.esm.js +132 -8751
  12. package/dist/extensions/cpp.js +124 -8761
  13. package/dist/extensions/guided-lab.esm.js +33 -6827
  14. package/dist/extensions/guided-lab.js +33 -6845
  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 -8109
  18. package/dist/extensions/python.js +79 -8127
  19. package/dist/extensions/typescript.esm.js +1 -55
  20. package/dist/extensions/typescript.js +1 -77
  21. package/dist/index.d.ts +1 -1
  22. package/dist/modular-kernel.d.ts +0 -4
  23. package/dist/preview-sw.js +1 -1
  24. package/dist/runtime.esm.js +79 -79
  25. package/dist/runtime.js +79 -79
  26. package/dist/schemas.d.ts +22 -1
  27. package/dist/schemas.esm.js +33 -6806
  28. package/dist/schemas.js +33 -6822
  29. package/dist/shell.esm.js +248 -242
  30. package/dist/shell.js +248 -242
  31. package/dist/terminal.esm.js +8 -6
  32. package/dist/terminal.js +6 -6
  33. package/dist/workbench/command-palette.d.ts +0 -4
  34. package/dist/workbench/index.d.ts +0 -20
  35. package/dist/workbench/intellisense.d.ts +1 -7
  36. package/package.json +3 -10
  37. package/src/code-lab.css +11 -503
  38. package/src/extensions/cpp.ts +11 -29
  39. package/src/extensions/guided-lab.ts +6 -2
  40. package/src/extensions/python.ts +9 -3
  41. package/src/index.ts +1 -1
  42. package/src/modular-kernel.ts +0 -4
  43. package/src/runtime.ts +153 -42
  44. package/src/schemas.ts +12 -3
  45. package/src/shell.ts +109 -16
  46. package/src/terminal.ts +4 -2
  47. package/src/workbench/command-palette.ts +22 -302
  48. package/src/workbench/diff-editor.ts +2 -0
  49. package/src/workbench/icons.ts +1 -1
  50. package/src/workbench/index.ts +0 -15
  51. package/src/workbench/intellisense.ts +17 -4
  52. package/src/workbench.ts +432 -456
  53. package/dist/code-lab.umd.js +0 -6109
  54. package/dist/packages/editor/src/index.d.ts +0 -118
  55. package/dist/packages/preview/src/index.d.ts +0 -34
  56. package/dist/packages/runtime/src/index.d.ts +0 -47
  57. package/dist/packages/terminal/src/index.d.ts +0 -54
  58. package/dist/workbench/drawer.d.ts +0 -18
  59. package/dist/workbench/file-tree.d.ts +0 -11
  60. package/dist/workbench/guided-pane.d.ts +0 -11
  61. package/dist/workbench/styles.d.ts +0 -4
  62. package/dist/workbench/toolbar.d.ts +0 -17
  63. package/packages/commands/README.md +0 -7
  64. package/packages/commands/package.json +0 -16
  65. package/packages/commands/src/index.ts +0 -467
  66. package/packages/commands/tsconfig.json +0 -22
  67. package/packages/core/README.md +0 -12
  68. package/packages/core/package.json +0 -13
  69. package/packages/core/src/di.ts +0 -147
  70. package/packages/core/src/disposable.ts +0 -112
  71. package/packages/core/src/errors.ts +0 -205
  72. package/packages/core/src/events.ts +0 -157
  73. package/packages/core/src/index.ts +0 -49
  74. package/packages/core/src/path.ts +0 -118
  75. package/packages/core/src/registry.ts +0 -61
  76. package/packages/core/tsconfig.json +0 -19
  77. package/packages/editor/README.md +0 -9
  78. package/packages/editor/package.json +0 -18
  79. package/packages/editor/src/index.ts +0 -344
  80. package/packages/editor/tsconfig.json +0 -24
  81. package/packages/fs/README.md +0 -7
  82. package/packages/fs/package.json +0 -16
  83. package/packages/fs/src/backends.ts +0 -301
  84. package/packages/fs/src/index.ts +0 -18
  85. package/packages/fs/src/types.ts +0 -44
  86. package/packages/fs/src/vfs-service.ts +0 -257
  87. package/packages/fs/tsconfig.json +0 -22
  88. package/packages/preview/README.md +0 -3
  89. package/packages/preview/package.json +0 -16
  90. package/packages/preview/src/index.ts +0 -125
  91. package/packages/preview/tsconfig.json +0 -22
  92. package/packages/runtime/README.md +0 -3
  93. package/packages/runtime/package.json +0 -17
  94. package/packages/runtime/src/index.ts +0 -134
  95. package/packages/runtime/tsconfig.json +0 -23
  96. package/packages/settings/README.md +0 -7
  97. package/packages/settings/package.json +0 -16
  98. package/packages/settings/src/builtin-schemas.ts +0 -246
  99. package/packages/settings/src/configuration-service.ts +0 -609
  100. package/packages/settings/src/index.ts +0 -38
  101. package/packages/settings/src/jsonc.ts +0 -189
  102. package/packages/settings/src/schema.ts +0 -164
  103. package/packages/settings/tsconfig.json +0 -22
  104. package/packages/sql/README.md +0 -12
  105. package/packages/sql/package.json +0 -13
  106. package/packages/sql/src/completions.ts +0 -359
  107. package/packages/sql/src/diagnostics.ts +0 -200
  108. package/packages/sql/src/formatter.ts +0 -271
  109. package/packages/sql/src/index.ts +0 -54
  110. package/packages/sql/src/sql-editor.ts +0 -802
  111. package/packages/sql/src/styles.ts +0 -524
  112. package/packages/sql/src/tokenizer.ts +0 -457
  113. package/packages/sql/src/types.ts +0 -148
  114. package/packages/sql/tsconfig.json +0 -19
  115. package/packages/terminal/README.md +0 -3
  116. package/packages/terminal/package.json +0 -16
  117. package/packages/terminal/src/index.ts +0 -183
  118. package/packages/terminal/tsconfig.json +0 -22
  119. package/packages/ui/README.md +0 -8
  120. package/packages/ui/package.json +0 -18
  121. package/packages/ui/src/index.ts +0 -40
  122. package/packages/ui/src/observability.ts +0 -173
  123. package/packages/ui/src/plugin-registry.ts +0 -289
  124. package/packages/ui/src/settings-dialog.ts +0 -911
  125. package/packages/ui/src/themes.ts +0 -333
  126. package/packages/ui/tsconfig.json +0 -24
  127. package/src/workbench/drawer.ts +0 -157
  128. package/src/workbench/file-tree.ts +0 -51
  129. package/src/workbench/guided-pane.ts +0 -43
  130. package/src/workbench/styles.ts +0 -211
  131. package/src/workbench/toolbar.ts +0 -182
@@ -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.6.1",
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.6.1",
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,246 +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.panel.defaultTab',
88
- category: 'Workbench',
89
- title: 'Default Bottom Panel Tab',
90
- description: 'Default active tab in the bottom panel.',
91
- defaultValue: 'terminal',
92
- schema: {
93
- type: 'string',
94
- enum: [
95
- 'terminal',
96
- 'problems',
97
- 'tests',
98
- 'stdin',
99
- 'ports',
100
- 'preview',
101
- 'network',
102
- 'inspector',
103
- 'observability',
104
- 'sql-results'
105
- ],
106
- default: 'terminal'
107
- }
108
- },
109
- {
110
- key: 'files.autoSave',
111
- category: 'Files',
112
- title: 'Auto Save',
113
- description: 'Controls automatic persistence of dirty files.',
114
- defaultValue: 'afterDelay',
115
- schema: { type: 'string', enum: ['afterDelay', 'off'], default: 'afterDelay' }
116
- },
117
- {
118
- key: 'files.autoSaveDelay',
119
- category: 'Files',
120
- title: 'Auto Save Delay (ms)',
121
- description: 'Controls the delay in milliseconds after which a dirty file is saved automatically.',
122
- defaultValue: 300,
123
- schema: { type: 'integer', minimum: 50, maximum: 30000, default: 300 }
124
- },
125
- {
126
- key: 'files.exclude',
127
- category: 'Files',
128
- title: 'Excluded File Globs',
129
- description: 'Configure glob patterns for excluding files and folders from the explorer and search.',
130
- defaultValue: ['**/node_modules/**', '**/.git/**'],
131
- schema: { type: 'array', items: { type: 'string' }, default: ['**/node_modules/**', '**/.git/**'] }
132
- },
133
- {
134
- key: 'terminal.fontSize',
135
- category: 'Terminal',
136
- title: 'Terminal Font Size',
137
- description: 'Controls the font size in pixels of the integrated PTY terminal.',
138
- defaultValue: 13,
139
- schema: { type: 'integer', minimum: 10, maximum: 28, default: 13 }
140
- },
141
- {
142
- key: 'terminal.scrollback',
143
- category: 'Terminal',
144
- title: 'Terminal Scrollback',
145
- description: 'Controls the maximum amount of lines the terminal keeps in its buffer.',
146
- defaultValue: 1000,
147
- schema: { type: 'integer', minimum: 100, maximum: 50000, default: 1000 }
148
- },
149
- {
150
- key: 'preview.autoReload',
151
- category: 'Preview',
152
- title: 'Preview Auto Reload',
153
- description: 'Automatically refresh the web preview iframe when workspace files change.',
154
- defaultValue: true,
155
- schema: { type: 'boolean', default: true }
156
- },
157
- {
158
- key: 'runtime.timeoutMs',
159
- category: 'Runtime',
160
- title: 'Execution Watchdog Timeout (ms)',
161
- description: 'Maximum execution time in milliseconds before terminating runaway sandbox workers.',
162
- defaultValue: 8000,
163
- schema: { type: 'integer', minimum: 500, maximum: 120000, default: 8000 }
164
- },
165
- {
166
- key: 'sql.defaultDialect',
167
- category: 'SQL',
168
- title: 'Default SQL Dialect',
169
- description: 'Default SQL dialect used for highlighting, formatting, and completions.',
170
- defaultValue: 'postgres',
171
- schema: { type: 'string', enum: ['postgres', 'sqlite'], default: 'postgres' }
172
- }
173
- ];
174
-
175
- export function buildSettingsJsonSchema(descriptors: readonly SettingDescriptor[]): JsonSchema {
176
- const properties: Record<string, JsonSchema> = {};
177
- for (const d of descriptors) {
178
- properties[d.key] = {
179
- ...d.schema,
180
- title: d.title,
181
- description: d.description,
182
- default: d.defaultValue
183
- };
184
- }
185
- return {
186
- $schema: 'http://json-schema.org/draft-07/schema#',
187
- title: 'CodeLab Workspace & User Settings (.codelab/settings.json)',
188
- type: 'object',
189
- properties,
190
- additionalProperties: true
191
- };
192
- }
193
-
194
- export const KEYBINDINGS_JSON_SCHEMA: JsonSchema = {
195
- $schema: 'http://json-schema.org/draft-07/schema#',
196
- title: 'CodeLab Keybindings (.codelab/keybindings.json)',
197
- type: 'array',
198
- items: {
199
- type: 'object',
200
- required: ['key', 'command'],
201
- properties: {
202
- key: { type: 'string', minLength: 1, description: 'Key chord such as Mod+Enter or Shift+Alt+F' },
203
- command: { type: 'string', minLength: 1, description: 'Command ID (prefix with - to unbind)' },
204
- when: { type: 'string', description: 'Optional context-key expression' }
205
- },
206
- additionalProperties: true
207
- }
208
- };
209
-
210
- export const TASKS_JSON_SCHEMA: JsonSchema = {
211
- $schema: 'http://json-schema.org/draft-07/schema#',
212
- title: 'CodeLab Workspace Tasks (.codelab/tasks.json)',
213
- type: 'object',
214
- required: ['version', 'tasks'],
215
- properties: {
216
- version: { type: 'string', enum: ['1.0', '2.0.0'] },
217
- tasks: {
218
- type: 'array',
219
- items: {
220
- type: 'object',
221
- required: ['label', 'command'],
222
- properties: {
223
- id: { type: 'string' },
224
- label: { type: 'string', minLength: 1 },
225
- command: { type: 'string', minLength: 1 },
226
- group: { type: 'string', enum: ['run', 'build', 'test', 'dev'] },
227
- runOn: { type: 'string', enum: ['manual', 'folderOpen'] },
228
- cwd: { type: 'string' }
229
- },
230
- additionalProperties: true
231
- }
232
- }
233
- },
234
- additionalProperties: true
235
- };
236
-
237
- export const EXTENSIONS_JSON_SCHEMA: JsonSchema = {
238
- $schema: 'http://json-schema.org/draft-07/schema#',
239
- title: 'CodeLab Workspace Extensions (.codelab/extensions.json)',
240
- type: 'object',
241
- properties: {
242
- recommendations: { type: 'array', items: { type: 'string' } },
243
- autoActivate: { type: 'array', items: { type: 'string' } }
244
- },
245
- additionalProperties: true
246
- };