@innovatorved/code-lab 0.3.2 → 0.4.0
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 +5 -3
- package/CHANGELOG.md +20 -0
- package/README.md +70 -168
- package/dist/apps/web/src/index.d.ts +34 -0
- package/dist/code-lab-sql.css +482 -0
- package/dist/code-lab-sql.d.ts +179 -0
- package/dist/code-lab-sql.esm.js +542 -0
- package/dist/code-lab-sql.umd.js +531 -0
- package/dist/code-lab.css +246 -0
- package/dist/code-lab.d.ts +110 -15
- package/dist/code-lab.esm.js +34265 -18104
- package/dist/code-lab.js +33186 -17053
- package/dist/code-lab.umd.js +65502 -0
- package/dist/extensions/cpp.esm.js +19478 -3760
- package/dist/extensions/cpp.js +19475 -3757
- package/dist/extensions/guided-lab.esm.js +19401 -3725
- package/dist/extensions/guided-lab.js +19400 -3724
- package/dist/extensions/python.d.ts +1 -0
- package/dist/extensions/python.esm.js +19576 -3766
- package/dist/extensions/python.js +19576 -3766
- package/dist/extensions/umbrella.d.ts +5 -0
- package/dist/index.d.ts +1 -1
- package/dist/modular-kernel.d.ts +11 -0
- package/dist/packages/commands/src/index.d.ts +96 -0
- package/dist/packages/core/src/di.d.ts +36 -0
- package/dist/packages/core/src/disposable.d.ts +27 -0
- package/dist/packages/core/src/errors.d.ts +69 -0
- package/dist/packages/core/src/events.d.ts +38 -0
- package/dist/packages/core/src/index.d.ts +6 -0
- package/dist/packages/core/src/path.d.ts +14 -0
- package/dist/packages/core/src/registry.d.ts +23 -0
- package/dist/packages/editor/src/index.d.ts +118 -0
- package/dist/packages/fs/src/backends.d.ts +37 -0
- package/dist/packages/fs/src/index.d.ts +3 -0
- package/dist/packages/fs/src/types.d.ts +40 -0
- package/dist/packages/fs/src/vfs-service.d.ts +33 -0
- package/dist/packages/preview/src/index.d.ts +34 -0
- package/dist/packages/runtime/src/index.d.ts +47 -0
- package/dist/packages/settings/src/builtin-schemas.d.ts +15 -0
- package/dist/packages/settings/src/configuration-service.d.ts +100 -0
- package/dist/packages/settings/src/index.d.ts +4 -0
- package/dist/packages/settings/src/jsonc.d.ts +20 -0
- package/dist/packages/settings/src/schema.d.ts +28 -0
- package/dist/packages/sql/src/completions.d.ts +8 -0
- package/dist/packages/sql/src/diagnostics.d.ts +2 -0
- package/dist/packages/sql/src/formatter.d.ts +2 -0
- package/dist/packages/sql/src/index.d.ts +7 -0
- package/dist/packages/sql/src/sql-editor.d.ts +2 -0
- package/dist/packages/sql/src/styles.d.ts +2 -0
- package/dist/packages/sql/src/tokenizer.d.ts +13 -0
- package/dist/packages/sql/src/types.d.ts +130 -0
- package/dist/packages/terminal/src/index.d.ts +54 -0
- package/dist/packages/ui/src/index.d.ts +4 -0
- package/dist/packages/ui/src/observability.d.ts +22 -0
- package/dist/packages/ui/src/plugin-registry.d.ts +89 -0
- package/dist/packages/ui/src/settings-dialog.d.ts +25 -0
- package/dist/packages/ui/src/themes.d.ts +35 -0
- package/dist/preview-sw.js +53 -12
- package/dist/runtime.d.ts +3 -3
- package/dist/runtime.esm.js +467 -44
- package/dist/runtime.js +465 -44
- package/dist/schemas.d.ts +234 -814
- package/dist/schemas.esm.js +19401 -3725
- package/dist/schemas.js +19404 -3728
- package/dist/shell.d.ts +1 -1
- package/dist/shell.esm.js +364 -39
- package/dist/shell.js +364 -39
- package/dist/terminal.esm.js +62 -3
- package/dist/terminal.js +62 -3
- package/dist/workbench/diff-editor.d.ts +1 -0
- package/package.json +37 -8
- package/packages/commands/README.md +7 -0
- package/packages/commands/package.json +16 -0
- package/packages/commands/src/index.ts +467 -0
- package/packages/commands/tsconfig.json +22 -0
- package/packages/core/README.md +12 -0
- package/packages/core/package.json +13 -0
- package/packages/core/src/di.ts +147 -0
- package/packages/core/src/disposable.ts +112 -0
- package/packages/core/src/errors.ts +205 -0
- package/packages/core/src/events.ts +157 -0
- package/packages/core/src/index.ts +49 -0
- package/packages/core/src/path.ts +118 -0
- package/packages/core/src/registry.ts +61 -0
- package/packages/core/tsconfig.json +19 -0
- package/packages/editor/README.md +9 -0
- package/packages/editor/package.json +18 -0
- package/packages/editor/src/index.ts +344 -0
- package/packages/editor/tsconfig.json +24 -0
- package/packages/fs/README.md +7 -0
- package/packages/fs/package.json +16 -0
- package/packages/fs/src/backends.ts +301 -0
- package/packages/fs/src/index.ts +18 -0
- package/packages/fs/src/types.ts +44 -0
- package/packages/fs/src/vfs-service.ts +257 -0
- package/packages/fs/tsconfig.json +22 -0
- package/packages/preview/README.md +3 -0
- package/packages/preview/package.json +16 -0
- package/packages/preview/src/index.ts +125 -0
- package/packages/preview/tsconfig.json +22 -0
- package/packages/runtime/README.md +3 -0
- package/packages/runtime/package.json +17 -0
- package/packages/runtime/src/index.ts +134 -0
- package/packages/runtime/tsconfig.json +23 -0
- package/packages/settings/README.md +7 -0
- package/packages/settings/package.json +16 -0
- package/packages/settings/src/builtin-schemas.ts +235 -0
- package/packages/settings/src/configuration-service.ts +543 -0
- package/packages/settings/src/index.ts +37 -0
- package/packages/settings/src/jsonc.ts +189 -0
- package/packages/settings/src/schema.ts +164 -0
- package/packages/settings/tsconfig.json +22 -0
- package/packages/sql/README.md +12 -0
- package/packages/sql/package.json +13 -0
- package/packages/sql/src/completions.ts +359 -0
- package/packages/sql/src/diagnostics.ts +200 -0
- package/packages/sql/src/formatter.ts +271 -0
- package/packages/sql/src/index.ts +54 -0
- package/packages/sql/src/sql-editor.ts +802 -0
- package/packages/sql/src/styles.ts +501 -0
- package/packages/sql/src/tokenizer.ts +457 -0
- package/packages/sql/src/types.ts +148 -0
- package/packages/sql/tsconfig.json +19 -0
- package/packages/terminal/README.md +3 -0
- package/packages/terminal/package.json +16 -0
- package/packages/terminal/src/index.ts +183 -0
- package/packages/terminal/tsconfig.json +22 -0
- package/packages/ui/README.md +8 -0
- package/packages/ui/package.json +18 -0
- package/packages/ui/src/index.ts +36 -0
- package/packages/ui/src/observability.ts +175 -0
- package/packages/ui/src/plugin-registry.ts +274 -0
- package/packages/ui/src/settings-dialog.ts +293 -0
- package/packages/ui/src/themes.ts +174 -0
- package/packages/ui/tsconfig.json +24 -0
- package/src/code-lab.css +246 -0
- package/src/extensions/cpp.ts +58 -15
- package/src/extensions/python.ts +156 -24
- package/src/extensions/umbrella.ts +5 -0
- package/src/index.ts +1 -1
- package/src/modular-kernel.ts +11 -0
- package/src/preview-sw.js +52 -11
- package/src/runtime.ts +466 -46
- package/src/schemas.ts +62 -62
- package/src/shell.ts +363 -39
- package/src/terminal.ts +60 -2
- package/src/workbench/diff-editor.ts +66 -6
- package/src/workbench/icons.ts +5 -2
- package/src/workbench.ts +2410 -220
- package/dist/runtime/index.d.ts +0 -4
- package/dist/shell/coreutils/compilers-cli.d.ts +0 -24
- package/dist/shell/index.d.ts +0 -4
- package/src/runtime/index.ts +0 -5
- package/src/shell/coreutils/compilers-cli.ts +0 -103
- package/src/shell/index.ts +0 -5
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["ES2022"],
|
|
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
|
+
},
|
|
18
|
+
"include": ["src/**/*.ts"]
|
|
19
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# `@code-lab/editor`
|
|
2
|
+
|
|
3
|
+
Layer 2 (`services`) swappable editor abstraction (`IEditorAdapter` & `EditorService`).
|
|
4
|
+
|
|
5
|
+
## Included Adapters
|
|
6
|
+
|
|
7
|
+
- `MonacoEditorAdapter` — wraps a full Monaco `IStandaloneCodeEditor` instance.
|
|
8
|
+
- `SqlEditorAdapter` — wraps `@code-lab/sql`'s zero-WASM PostgreSQL 18 / SQLite 3 editor.
|
|
9
|
+
- `LightweightEditorAdapter` — minimal `<textarea>` fallback for headless tests and instant boot.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@code-lab/editor",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Swappable editor service and IEditorAdapter implementations (Monaco, SQL, Lightweight textarea) 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/settings": "workspace:*",
|
|
14
|
+
"@code-lab/sql": "workspace:*"
|
|
15
|
+
},
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"license": "MIT"
|
|
18
|
+
}
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createServiceId,
|
|
3
|
+
Emitter,
|
|
4
|
+
type Event,
|
|
5
|
+
type IDisposable,
|
|
6
|
+
toDisposable
|
|
7
|
+
} from '@code-lab/core';
|
|
8
|
+
import type { IConfigurationService } from '@code-lab/settings';
|
|
9
|
+
import {
|
|
10
|
+
createSqlEditor,
|
|
11
|
+
type SqlDiagnostic,
|
|
12
|
+
type SqlDialect,
|
|
13
|
+
type SqlEditorInstance,
|
|
14
|
+
type SqlSchema
|
|
15
|
+
} from '@code-lab/sql';
|
|
16
|
+
|
|
17
|
+
export interface EditorMarker {
|
|
18
|
+
readonly line: number;
|
|
19
|
+
readonly column: number;
|
|
20
|
+
readonly message: string;
|
|
21
|
+
readonly severity: 'error' | 'warning' | 'info';
|
|
22
|
+
readonly hint?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface EditorDisplayOptions {
|
|
26
|
+
readonly fontSize?: number;
|
|
27
|
+
readonly tabSize?: number;
|
|
28
|
+
readonly wordWrap?: 'off' | 'on' | 'wordWrapColumn';
|
|
29
|
+
readonly minimap?: boolean;
|
|
30
|
+
readonly lineNumbers?: 'on' | 'off' | 'relative';
|
|
31
|
+
readonly readOnly?: boolean;
|
|
32
|
+
readonly theme?: 'dark' | 'light' | 'high-contrast';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface IEditorAdapter extends IDisposable {
|
|
36
|
+
readonly kind: 'monaco' | 'sql' | 'lightweight';
|
|
37
|
+
readonly onDidChangeValue: Event<string>;
|
|
38
|
+
getValue(): string;
|
|
39
|
+
setValue(value: string): void;
|
|
40
|
+
getSelection(): string;
|
|
41
|
+
insertAtCursor(text: string): void;
|
|
42
|
+
setLanguage(languageId: string): void;
|
|
43
|
+
setMarkers(markers: readonly EditorMarker[]): void;
|
|
44
|
+
applyOptions(options: EditorDisplayOptions): void;
|
|
45
|
+
focus(): void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface MonacoEditorLike {
|
|
49
|
+
getValue(): string;
|
|
50
|
+
setValue(value: string): void;
|
|
51
|
+
getModel(): { getValueInRange?: (range: unknown) => string } | null;
|
|
52
|
+
getSelection(): unknown;
|
|
53
|
+
executeEdits(source: string, edits: Array<{ range: unknown; text: string }>): void;
|
|
54
|
+
updateOptions(opts: Record<string, unknown>): void;
|
|
55
|
+
focus(): void;
|
|
56
|
+
onDidChangeModelContent(cb: () => void): { dispose(): void };
|
|
57
|
+
dispose(): void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export class LightweightEditorAdapter implements IEditorAdapter {
|
|
61
|
+
public readonly kind = 'lightweight' as const;
|
|
62
|
+
private readonly textarea: HTMLTextAreaElement;
|
|
63
|
+
private readonly changeEmitter = new Emitter<string>({ name: 'editor.lightweight.change' });
|
|
64
|
+
private readonly cleanup: IDisposable;
|
|
65
|
+
|
|
66
|
+
public constructor(container: HTMLElement, initialValue = '') {
|
|
67
|
+
const doc = container.ownerDocument ?? document;
|
|
68
|
+
this.textarea = doc.createElement('textarea');
|
|
69
|
+
this.textarea.className = 'cl-lightweight-editor';
|
|
70
|
+
this.textarea.value = initialValue;
|
|
71
|
+
this.textarea.spellcheck = false;
|
|
72
|
+
container.innerHTML = '';
|
|
73
|
+
container.appendChild(this.textarea);
|
|
74
|
+
|
|
75
|
+
const onInput = (): void => {
|
|
76
|
+
this.changeEmitter.fire(this.textarea.value);
|
|
77
|
+
};
|
|
78
|
+
this.textarea.addEventListener('input', onInput);
|
|
79
|
+
this.cleanup = toDisposable(() => this.textarea.removeEventListener('input', onInput));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public get onDidChangeValue(): Event<string> {
|
|
83
|
+
return this.changeEmitter.event;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public getValue(): string {
|
|
87
|
+
return this.textarea.value;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public setValue(value: string): void {
|
|
91
|
+
this.textarea.value = value;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public getSelection(): string {
|
|
95
|
+
const start = this.textarea.selectionStart ?? 0;
|
|
96
|
+
const end = this.textarea.selectionEnd ?? 0;
|
|
97
|
+
return end > start ? this.textarea.value.slice(start, end) : '';
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public insertAtCursor(text: string): void {
|
|
101
|
+
const start = this.textarea.selectionStart ?? this.textarea.value.length;
|
|
102
|
+
const end = this.textarea.selectionEnd ?? start;
|
|
103
|
+
const cur = this.textarea.value;
|
|
104
|
+
this.textarea.value = cur.slice(0, start) + text + cur.slice(end);
|
|
105
|
+
const pos = start + text.length;
|
|
106
|
+
this.textarea.selectionStart = pos;
|
|
107
|
+
this.textarea.selectionEnd = pos;
|
|
108
|
+
this.changeEmitter.fire(this.textarea.value);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
public setLanguage(_languageId: string): void {
|
|
112
|
+
// Plain textarea has no syntax grammar
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
public setMarkers(_markers: readonly EditorMarker[]): void {
|
|
116
|
+
// Markers handled externally in Problems panel for plain textarea
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
public applyOptions(options: EditorDisplayOptions): void {
|
|
120
|
+
if (options.fontSize) {
|
|
121
|
+
this.textarea.style.fontSize = `${options.fontSize}px`;
|
|
122
|
+
}
|
|
123
|
+
if (options.wordWrap) {
|
|
124
|
+
this.textarea.style.whiteSpace = options.wordWrap === 'off' ? 'pre' : 'pre-wrap';
|
|
125
|
+
}
|
|
126
|
+
if (options.readOnly !== undefined) {
|
|
127
|
+
this.textarea.readOnly = options.readOnly;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public focus(): void {
|
|
132
|
+
this.textarea.focus();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public dispose(): void {
|
|
136
|
+
this.cleanup.dispose();
|
|
137
|
+
this.changeEmitter.dispose();
|
|
138
|
+
this.textarea.remove();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export class SqlEditorAdapter implements IEditorAdapter {
|
|
143
|
+
public readonly kind = 'sql' as const;
|
|
144
|
+
private readonly sqlEditor: SqlEditorInstance;
|
|
145
|
+
private readonly changeEmitter = new Emitter<string>({ name: 'editor.sql.change' });
|
|
146
|
+
|
|
147
|
+
public constructor(
|
|
148
|
+
container: HTMLElement,
|
|
149
|
+
options: {
|
|
150
|
+
value?: string;
|
|
151
|
+
dialect?: SqlDialect;
|
|
152
|
+
schema?: SqlSchema | null;
|
|
153
|
+
onRun?: (sql: string, effectiveSql: string) => void;
|
|
154
|
+
} = {}
|
|
155
|
+
) {
|
|
156
|
+
this.sqlEditor = createSqlEditor(container, {
|
|
157
|
+
value: options.value ?? '',
|
|
158
|
+
dialect: options.dialect ?? 'postgres',
|
|
159
|
+
mode: 'inline',
|
|
160
|
+
schema: options.schema ?? null,
|
|
161
|
+
onChange: (val) => this.changeEmitter.fire(val),
|
|
162
|
+
onRun: (payload) => options.onRun?.(payload.sql, payload.effectiveSql)
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
public get onDidChangeValue(): Event<string> {
|
|
167
|
+
return this.changeEmitter.event;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
public get underlying(): SqlEditorInstance {
|
|
171
|
+
return this.sqlEditor;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
public getValue(): string {
|
|
175
|
+
return this.sqlEditor.getValue();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
public setValue(value: string): void {
|
|
179
|
+
this.sqlEditor.setValue(value);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
public getSelection(): string {
|
|
183
|
+
return this.sqlEditor.getSelection();
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
public insertAtCursor(text: string): void {
|
|
187
|
+
this.sqlEditor.insertAtCursor(text);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
public setLanguage(languageId: string): void {
|
|
191
|
+
if (languageId === 'sqlite') {
|
|
192
|
+
this.sqlEditor.setDialect('sqlite');
|
|
193
|
+
} else if (languageId === 'postgres' || languageId === 'sql') {
|
|
194
|
+
this.sqlEditor.setDialect('postgres');
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
public setMarkers(markers: readonly EditorMarker[]): void {
|
|
199
|
+
const mapped: SqlDiagnostic[] = markers.map((m) => ({
|
|
200
|
+
severity: m.severity,
|
|
201
|
+
message: m.message,
|
|
202
|
+
hint: m.hint,
|
|
203
|
+
line: m.line,
|
|
204
|
+
column: m.column
|
|
205
|
+
}));
|
|
206
|
+
this.sqlEditor.setDiagnostics(mapped);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
public applyOptions(options: EditorDisplayOptions): void {
|
|
210
|
+
if (options.readOnly !== undefined) {
|
|
211
|
+
this.sqlEditor.setReadOnly(options.readOnly);
|
|
212
|
+
}
|
|
213
|
+
if (options.theme) {
|
|
214
|
+
this.sqlEditor.setTheme(options.theme === 'light' ? 'light' : 'dark');
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
public focus(): void {
|
|
219
|
+
this.sqlEditor.focus();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
public dispose(): void {
|
|
223
|
+
this.sqlEditor.destroy();
|
|
224
|
+
this.changeEmitter.dispose();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export class MonacoEditorAdapter implements IEditorAdapter {
|
|
229
|
+
public readonly kind = 'monaco' as const;
|
|
230
|
+
private readonly editor: MonacoEditorLike;
|
|
231
|
+
private readonly changeEmitter = new Emitter<string>({ name: 'editor.monaco.change' });
|
|
232
|
+
private readonly modelSub: { dispose(): void };
|
|
233
|
+
|
|
234
|
+
public constructor(editorInstance: MonacoEditorLike) {
|
|
235
|
+
this.editor = editorInstance;
|
|
236
|
+
this.modelSub = this.editor.onDidChangeModelContent(() => {
|
|
237
|
+
this.changeEmitter.fire(this.editor.getValue());
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
public get onDidChangeValue(): Event<string> {
|
|
242
|
+
return this.changeEmitter.event;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
public getValue(): string {
|
|
246
|
+
return this.editor.getValue();
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
public setValue(value: string): void {
|
|
250
|
+
if (this.editor.getValue() !== value) {
|
|
251
|
+
this.editor.setValue(value);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
public getSelection(): string {
|
|
256
|
+
const model = this.editor.getModel();
|
|
257
|
+
const sel = this.editor.getSelection();
|
|
258
|
+
if (model && typeof model.getValueInRange === 'function' && sel) {
|
|
259
|
+
return model.getValueInRange(sel);
|
|
260
|
+
}
|
|
261
|
+
return '';
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
public insertAtCursor(text: string): void {
|
|
265
|
+
const sel = this.editor.getSelection();
|
|
266
|
+
if (sel) {
|
|
267
|
+
this.editor.executeEdits('codelab', [{ range: sel, text }]);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
public setLanguage(_languageId: string): void {
|
|
272
|
+
// Language set on Monaco ITextModel via monaco.editor.setModelLanguage
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
public setMarkers(_markers: readonly EditorMarker[]): void {
|
|
276
|
+
// Markers synced via monaco.editor.setModelMarkers
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
public applyOptions(options: EditorDisplayOptions): void {
|
|
280
|
+
const opts: Record<string, unknown> = {};
|
|
281
|
+
if (options.fontSize !== undefined) opts.fontSize = options.fontSize;
|
|
282
|
+
if (options.tabSize !== undefined) opts.tabSize = options.tabSize;
|
|
283
|
+
if (options.wordWrap !== undefined) opts.wordWrap = options.wordWrap;
|
|
284
|
+
if (options.minimap !== undefined) opts.minimap = { enabled: options.minimap };
|
|
285
|
+
if (options.lineNumbers !== undefined) opts.lineNumbers = options.lineNumbers;
|
|
286
|
+
if (options.readOnly !== undefined) opts.readOnly = options.readOnly;
|
|
287
|
+
this.editor.updateOptions(opts);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
public focus(): void {
|
|
291
|
+
this.editor.focus();
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
public dispose(): void {
|
|
295
|
+
this.modelSub.dispose();
|
|
296
|
+
this.changeEmitter.dispose();
|
|
297
|
+
this.editor.dispose();
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export interface IEditorService extends IDisposable {
|
|
302
|
+
readonly activeAdapter: IEditorAdapter | undefined;
|
|
303
|
+
setActiveAdapter(adapter: IEditorAdapter): void;
|
|
304
|
+
syncFromConfiguration(config: IConfigurationService): void;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export const IEditorServiceId = createServiceId<IEditorService>('code-lab.editor');
|
|
308
|
+
|
|
309
|
+
export class EditorService implements IEditorService {
|
|
310
|
+
private current: IEditorAdapter | undefined;
|
|
311
|
+
|
|
312
|
+
public get activeAdapter(): IEditorAdapter | undefined {
|
|
313
|
+
return this.current;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
public setActiveAdapter(adapter: IEditorAdapter): void {
|
|
317
|
+
if (this.current && this.current !== adapter) {
|
|
318
|
+
this.current.dispose();
|
|
319
|
+
}
|
|
320
|
+
this.current = adapter;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
public syncFromConfiguration(config: IConfigurationService): void {
|
|
324
|
+
if (!this.current) return;
|
|
325
|
+
const themeRaw = config.get<string>('workbench.colorTheme', 'dark');
|
|
326
|
+
const theme =
|
|
327
|
+
themeRaw === 'light' ? 'light' : themeRaw === 'high-contrast' ? 'high-contrast' : 'dark';
|
|
328
|
+
this.current.applyOptions({
|
|
329
|
+
fontSize: config.get<number>('editor.fontSize', 13),
|
|
330
|
+
tabSize: config.get<number>('editor.tabSize', 2),
|
|
331
|
+
wordWrap: config.get<'off' | 'on' | 'wordWrapColumn'>('editor.wordWrap', 'off'),
|
|
332
|
+
minimap: config.get<boolean>('editor.minimap.enabled', false),
|
|
333
|
+
lineNumbers: config.get<'on' | 'off' | 'relative'>('editor.lineNumbers', 'on'),
|
|
334
|
+
theme
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
public dispose(): void {
|
|
339
|
+
if (this.current) {
|
|
340
|
+
this.current.dispose();
|
|
341
|
+
this.current = undefined;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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/settings": ["../settings/src/index.ts"],
|
|
20
|
+
"@code-lab/sql": ["../sql/src/index.ts"]
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"include": ["src/**/*.ts"]
|
|
24
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# `@code-lab/fs`
|
|
2
|
+
|
|
3
|
+
Layer 1 (`platform`) virtual filesystem service (`IFileSystemService`) with hot-swappable storage backends:
|
|
4
|
+
|
|
5
|
+
- `MemoryBackend` — fast deterministic in-memory `Uint8Array` storage for tests and ephemeral sandboxes.
|
|
6
|
+
- `IndexedDbBackend` — persistent browser IndexedDB storage with automatic in-memory fallback.
|
|
7
|
+
- `OpfsBackend` — Origin Private File System (`navigator.storage.getDirectory()`) backend for large workspace trees.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@code-lab/fs",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Pluggable virtual filesystem service for CodeLab with Memory, IndexedDB, and OPFS backends.",
|
|
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
|
+
}
|