@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.
- package/ARCHITECTURE.md +2 -2
- package/CHANGELOG.md +20 -0
- package/README.md +2 -2
- package/dist/apps/web/src/index.d.ts +0 -9
- package/dist/code-lab-sql.esm.js +19 -19
- package/dist/code-lab-sql.umd.js +20 -20
- package/dist/code-lab.css +1 -1
- package/dist/code-lab.d.ts +1 -1
- package/dist/code-lab.esm.js +679 -1439
- package/dist/code-lab.js +678 -1438
- package/dist/extensions/cpp.esm.js +132 -8760
- package/dist/extensions/cpp.js +124 -8770
- package/dist/extensions/guided-lab.esm.js +33 -6836
- package/dist/extensions/guided-lab.js +33 -6854
- package/dist/extensions/javascript.esm.js +1 -36
- package/dist/extensions/javascript.js +1 -58
- package/dist/extensions/python.esm.js +79 -8118
- package/dist/extensions/python.js +79 -8136
- package/dist/extensions/typescript.esm.js +1 -55
- package/dist/extensions/typescript.js +1 -77
- package/dist/modular-kernel.d.ts +0 -4
- package/dist/preview-sw.js +1 -1
- package/dist/runtime.esm.js +77 -77
- package/dist/runtime.js +77 -77
- package/dist/schemas.d.ts +9 -0
- package/dist/schemas.esm.js +33 -6815
- package/dist/schemas.js +33 -6831
- package/dist/shell.esm.js +33 -33
- package/dist/shell.js +33 -33
- package/dist/terminal.esm.js +8 -6
- package/dist/terminal.js +6 -6
- package/dist/workbench/command-palette.d.ts +0 -4
- package/dist/workbench/index.d.ts +0 -20
- package/dist/workbench/intellisense.d.ts +1 -7
- package/package.json +3 -10
- package/src/code-lab.css +4 -502
- package/src/extensions/cpp.ts +11 -29
- package/src/extensions/guided-lab.ts +6 -2
- package/src/extensions/python.ts +9 -3
- package/src/modular-kernel.ts +0 -4
- package/src/runtime.ts +124 -39
- package/src/schemas.ts +2 -2
- package/src/shell.ts +3 -0
- package/src/terminal.ts +4 -2
- package/src/workbench/command-palette.ts +22 -302
- package/src/workbench/diff-editor.ts +2 -0
- package/src/workbench/icons.ts +1 -1
- package/src/workbench/index.ts +0 -15
- package/src/workbench/intellisense.ts +17 -4
- package/src/workbench.ts +68 -375
- package/dist/code-lab.umd.js +0 -6117
- package/dist/packages/editor/src/index.d.ts +0 -118
- package/dist/packages/preview/src/index.d.ts +0 -34
- package/dist/packages/runtime/src/index.d.ts +0 -47
- package/dist/packages/terminal/src/index.d.ts +0 -54
- package/dist/workbench/drawer.d.ts +0 -18
- package/dist/workbench/file-tree.d.ts +0 -11
- package/dist/workbench/guided-pane.d.ts +0 -11
- package/dist/workbench/styles.d.ts +0 -4
- package/dist/workbench/toolbar.d.ts +0 -17
- package/packages/commands/README.md +0 -7
- package/packages/commands/package.json +0 -16
- package/packages/commands/src/index.ts +0 -467
- package/packages/commands/tsconfig.json +0 -22
- package/packages/core/README.md +0 -12
- package/packages/core/package.json +0 -13
- package/packages/core/src/di.ts +0 -147
- package/packages/core/src/disposable.ts +0 -112
- package/packages/core/src/errors.ts +0 -205
- package/packages/core/src/events.ts +0 -157
- package/packages/core/src/index.ts +0 -49
- package/packages/core/src/path.ts +0 -118
- package/packages/core/src/registry.ts +0 -61
- package/packages/core/tsconfig.json +0 -19
- package/packages/editor/README.md +0 -9
- package/packages/editor/package.json +0 -18
- package/packages/editor/src/index.ts +0 -344
- package/packages/editor/tsconfig.json +0 -24
- package/packages/fs/README.md +0 -7
- package/packages/fs/package.json +0 -16
- package/packages/fs/src/backends.ts +0 -301
- package/packages/fs/src/index.ts +0 -18
- package/packages/fs/src/types.ts +0 -44
- package/packages/fs/src/vfs-service.ts +0 -257
- package/packages/fs/tsconfig.json +0 -22
- package/packages/preview/README.md +0 -3
- package/packages/preview/package.json +0 -16
- package/packages/preview/src/index.ts +0 -125
- package/packages/preview/tsconfig.json +0 -22
- package/packages/runtime/README.md +0 -3
- package/packages/runtime/package.json +0 -17
- package/packages/runtime/src/index.ts +0 -134
- package/packages/runtime/tsconfig.json +0 -23
- package/packages/settings/README.md +0 -7
- package/packages/settings/package.json +0 -16
- package/packages/settings/src/builtin-schemas.ts +0 -262
- package/packages/settings/src/configuration-service.ts +0 -609
- package/packages/settings/src/index.ts +0 -38
- package/packages/settings/src/jsonc.ts +0 -189
- package/packages/settings/src/schema.ts +0 -164
- package/packages/settings/tsconfig.json +0 -22
- package/packages/sql/README.md +0 -12
- package/packages/sql/package.json +0 -13
- package/packages/sql/src/completions.ts +0 -359
- package/packages/sql/src/diagnostics.ts +0 -200
- package/packages/sql/src/formatter.ts +0 -271
- package/packages/sql/src/index.ts +0 -54
- package/packages/sql/src/sql-editor.ts +0 -802
- package/packages/sql/src/styles.ts +0 -524
- package/packages/sql/src/tokenizer.ts +0 -457
- package/packages/sql/src/types.ts +0 -148
- package/packages/sql/tsconfig.json +0 -19
- package/packages/terminal/README.md +0 -3
- package/packages/terminal/package.json +0 -16
- package/packages/terminal/src/index.ts +0 -183
- package/packages/terminal/tsconfig.json +0 -22
- package/packages/ui/README.md +0 -8
- package/packages/ui/package.json +0 -18
- package/packages/ui/src/index.ts +0 -40
- package/packages/ui/src/observability.ts +0 -173
- package/packages/ui/src/plugin-registry.ts +0 -289
- package/packages/ui/src/settings-dialog.ts +0 -939
- package/packages/ui/src/themes.ts +0 -333
- package/packages/ui/tsconfig.json +0 -24
- package/src/workbench/drawer.ts +0 -157
- package/src/workbench/file-tree.ts +0 -51
- package/src/workbench/guided-pane.ts +0 -43
- package/src/workbench/styles.ts +0 -211
- package/src/workbench/toolbar.ts +0 -182
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CodeLabError,
|
|
3
|
-
createServiceId,
|
|
4
|
-
Emitter,
|
|
5
|
-
type Event,
|
|
6
|
-
type IDisposable,
|
|
7
|
-
toDisposable
|
|
8
|
-
} from '@code-lab/core';
|
|
9
|
-
import { parseJsonc } from '@code-lab/settings';
|
|
10
|
-
|
|
11
|
-
export type ThemeKind = 'dark' | 'light' | 'high-contrast';
|
|
12
|
-
|
|
13
|
-
export interface ThemeDefinition {
|
|
14
|
-
readonly id: string;
|
|
15
|
-
readonly label: string;
|
|
16
|
-
readonly kind: ThemeKind;
|
|
17
|
-
readonly colors: Readonly<Record<string, string>>;
|
|
18
|
-
readonly monacoBase: 'vs-dark' | 'vs' | 'hc-black';
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const DARK_THEME: ThemeDefinition = {
|
|
22
|
-
id: 'dark',
|
|
23
|
-
label: 'Charcoal Ink',
|
|
24
|
-
kind: 'dark',
|
|
25
|
-
monacoBase: 'vs-dark',
|
|
26
|
-
colors: {
|
|
27
|
-
'--cl-bg': '#0f0f10',
|
|
28
|
-
'--cl-editor-bg': '#0f0f10',
|
|
29
|
-
'--cl-surface': '#141415',
|
|
30
|
-
'--cl-chrome-bg': '#141415',
|
|
31
|
-
'--cl-widget-bg': '#18181a',
|
|
32
|
-
'--cl-input-bg': '#141415',
|
|
33
|
-
'--cl-input-border': '#27272a',
|
|
34
|
-
'--cl-fg': '#f4f4f5',
|
|
35
|
-
'--cl-fg-active': '#ffffff',
|
|
36
|
-
'--cl-muted': '#a1a1aa',
|
|
37
|
-
'--cl-fg-muted': '#a1a1aa',
|
|
38
|
-
'--cl-border': '#27272a',
|
|
39
|
-
'--cl-accent': '#f4f4f5',
|
|
40
|
-
'--cl-accent-fg': '#0f0f10',
|
|
41
|
-
'--cl-btn-primary-bg': '#f4f4f5',
|
|
42
|
-
'--cl-btn-primary-hover': '#ffffff',
|
|
43
|
-
'--cl-btn-primary-fg': '#0f0f10',
|
|
44
|
-
'--cl-focus-border': '#a1a1aa',
|
|
45
|
-
'--cl-list-hover': '#1f1f22',
|
|
46
|
-
'--cl-list-active': '#28282b',
|
|
47
|
-
'--cl-list-active-fg': '#f4f4f5',
|
|
48
|
-
'--cl-badge-bg': '#28282b',
|
|
49
|
-
'--cl-badge-fg': '#f4f4f5',
|
|
50
|
-
'--cl-git-modified': '#fbbf24',
|
|
51
|
-
'--cl-git-added': '#34d399',
|
|
52
|
-
'--cl-git-untracked': '#34d399',
|
|
53
|
-
'--cl-git-deleted': '#f87171',
|
|
54
|
-
'--cl-error': '#f87171',
|
|
55
|
-
'--cl-warning': '#fbbf24',
|
|
56
|
-
'--cl-info': '#e4e4e7'
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export const LIGHT_THEME: ThemeDefinition = {
|
|
61
|
-
id: 'light',
|
|
62
|
-
label: 'Warm Paper',
|
|
63
|
-
kind: 'light',
|
|
64
|
-
monacoBase: 'vs',
|
|
65
|
-
colors: {
|
|
66
|
-
'--cl-bg': '#ffffff',
|
|
67
|
-
'--cl-editor-bg': '#ffffff',
|
|
68
|
-
'--cl-surface': '#f7f7f5',
|
|
69
|
-
'--cl-chrome-bg': '#f7f7f5',
|
|
70
|
-
'--cl-widget-bg': '#f1f1ee',
|
|
71
|
-
'--cl-input-bg': '#ffffff',
|
|
72
|
-
'--cl-input-border': '#d3d0c9',
|
|
73
|
-
'--cl-fg': '#18181b',
|
|
74
|
-
'--cl-fg-active': '#09090b',
|
|
75
|
-
'--cl-muted': '#52525b',
|
|
76
|
-
'--cl-fg-muted': '#52525b',
|
|
77
|
-
'--cl-border': '#e6e4df',
|
|
78
|
-
'--cl-accent': '#18181b',
|
|
79
|
-
'--cl-accent-fg': '#ffffff',
|
|
80
|
-
'--cl-btn-primary-bg': '#18181b',
|
|
81
|
-
'--cl-btn-primary-hover': '#27272a',
|
|
82
|
-
'--cl-btn-primary-fg': '#ffffff',
|
|
83
|
-
'--cl-focus-border': '#3f3f46',
|
|
84
|
-
'--cl-list-hover': '#f1f1ee',
|
|
85
|
-
'--cl-list-active': '#ecebe7',
|
|
86
|
-
'--cl-list-active-fg': '#18181b',
|
|
87
|
-
'--cl-badge-bg': '#ecebe7',
|
|
88
|
-
'--cl-badge-fg': '#18181b',
|
|
89
|
-
'--cl-git-modified': '#b54708',
|
|
90
|
-
'--cl-git-added': '#067647',
|
|
91
|
-
'--cl-git-untracked': '#067647',
|
|
92
|
-
'--cl-git-deleted': '#b42318',
|
|
93
|
-
'--cl-error': '#b42318',
|
|
94
|
-
'--cl-warning': '#b54708',
|
|
95
|
-
'--cl-info': '#18181b'
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
export const HIGH_CONTRAST_THEME: ThemeDefinition = {
|
|
100
|
-
id: 'high-contrast',
|
|
101
|
-
label: 'High Contrast Ink',
|
|
102
|
-
kind: 'high-contrast',
|
|
103
|
-
monacoBase: 'hc-black',
|
|
104
|
-
colors: {
|
|
105
|
-
'--cl-bg': '#000000',
|
|
106
|
-
'--cl-editor-bg': '#000000',
|
|
107
|
-
'--cl-surface': '#000000',
|
|
108
|
-
'--cl-chrome-bg': '#000000',
|
|
109
|
-
'--cl-widget-bg': '#0f0f10',
|
|
110
|
-
'--cl-input-bg': '#000000',
|
|
111
|
-
'--cl-input-border': '#ffffff',
|
|
112
|
-
'--cl-fg': '#ffffff',
|
|
113
|
-
'--cl-fg-active': '#ffffff',
|
|
114
|
-
'--cl-muted': '#e4e4e7',
|
|
115
|
-
'--cl-fg-muted': '#e4e4e7',
|
|
116
|
-
'--cl-border': '#ffffff',
|
|
117
|
-
'--cl-accent': '#ffffff',
|
|
118
|
-
'--cl-accent-fg': '#000000',
|
|
119
|
-
'--cl-btn-primary-bg': '#ffffff',
|
|
120
|
-
'--cl-btn-primary-hover': '#e4e4e7',
|
|
121
|
-
'--cl-btn-primary-fg': '#000000',
|
|
122
|
-
'--cl-focus-border': '#fbbf24',
|
|
123
|
-
'--cl-list-hover': '#18181a',
|
|
124
|
-
'--cl-list-active': '#27272a',
|
|
125
|
-
'--cl-list-active-fg': '#ffffff',
|
|
126
|
-
'--cl-badge-bg': '#ffffff',
|
|
127
|
-
'--cl-badge-fg': '#000000',
|
|
128
|
-
'--cl-git-modified': '#fbbf24',
|
|
129
|
-
'--cl-git-added': '#34d399',
|
|
130
|
-
'--cl-git-untracked': '#34d399',
|
|
131
|
-
'--cl-git-deleted': '#f87171',
|
|
132
|
-
'--cl-error': '#f87171',
|
|
133
|
-
'--cl-warning': '#fbbf24',
|
|
134
|
-
'--cl-info': '#ffffff'
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
function parseColorRgb(raw: string): [number, number, number] | null {
|
|
139
|
-
const s = raw.trim();
|
|
140
|
-
if (s.startsWith('#')) {
|
|
141
|
-
const hex = s.slice(1);
|
|
142
|
-
if (hex.length === 3 || hex.length === 4) {
|
|
143
|
-
const r = Number.parseInt(hex[0] + hex[0], 16);
|
|
144
|
-
const g = Number.parseInt(hex[1] + hex[1], 16);
|
|
145
|
-
const b = Number.parseInt(hex[2] + hex[2], 16);
|
|
146
|
-
if (Number.isFinite(r) && Number.isFinite(g) && Number.isFinite(b)) return [r, g, b];
|
|
147
|
-
return null;
|
|
148
|
-
}
|
|
149
|
-
if (hex.length === 6 || hex.length === 8) {
|
|
150
|
-
const r = Number.parseInt(hex.slice(0, 2), 16);
|
|
151
|
-
const g = Number.parseInt(hex.slice(2, 4), 16);
|
|
152
|
-
const b = Number.parseInt(hex.slice(4, 6), 16);
|
|
153
|
-
if (Number.isFinite(r) && Number.isFinite(g) && Number.isFinite(b)) return [r, g, b];
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
return null;
|
|
157
|
-
}
|
|
158
|
-
const rgbMatch = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})/i.exec(s);
|
|
159
|
-
if (rgbMatch) {
|
|
160
|
-
const r = Math.min(255, Number.parseInt(rgbMatch[1], 10));
|
|
161
|
-
const g = Math.min(255, Number.parseInt(rgbMatch[2], 10));
|
|
162
|
-
const b = Math.min(255, Number.parseInt(rgbMatch[3], 10));
|
|
163
|
-
return [r, g, b];
|
|
164
|
-
}
|
|
165
|
-
return null;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function toLinearChannel(channel8Bit: number): number {
|
|
169
|
-
const srgb = channel8Bit / 255;
|
|
170
|
-
return srgb <= 0.04045 ? srgb / 12.92 : Math.pow((srgb + 0.055) / 1.055, 2.4);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Picks `'#ffffff'` or `'#000000'` to maximize WCAG 2.1 contrast (>= 4.58:1)
|
|
175
|
-
* against a solid hex/rgb background color, returning `fallback` for dynamic CSS expressions.
|
|
176
|
-
*/
|
|
177
|
-
export function pickContrastingFg(color: string, fallback = '#ffffff'): string {
|
|
178
|
-
const rgb = parseColorRgb(color);
|
|
179
|
-
if (!rgb) return fallback;
|
|
180
|
-
const lum =
|
|
181
|
-
0.2126 * toLinearChannel(rgb[0]) +
|
|
182
|
-
0.7152 * toLinearChannel(rgb[1]) +
|
|
183
|
-
0.0722 * toLinearChannel(rgb[2]);
|
|
184
|
-
const whiteContrast = 1.05 / (lum + 0.05);
|
|
185
|
-
const blackContrast = (lum + 0.05) / 0.05;
|
|
186
|
-
return whiteContrast >= blackContrast ? '#ffffff' : '#000000';
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export function parseCustomTheme(rawJsonc: string): ThemeDefinition {
|
|
190
|
-
const parsed = parseJsonc<Record<string, unknown>>(rawJsonc);
|
|
191
|
-
if (!parsed.value || typeof parsed.value !== 'object' || Array.isArray(parsed.value)) {
|
|
192
|
-
throw new CodeLabError('ERR_CONFIG_PARSE', parsed.errors[0]?.message ?? 'Invalid custom theme JSON');
|
|
193
|
-
}
|
|
194
|
-
const obj = parsed.value;
|
|
195
|
-
const id = typeof obj.id === 'string' && obj.id.trim() ? obj.id.trim() : 'custom-theme';
|
|
196
|
-
const label = typeof obj.label === 'string' && obj.label.trim() ? obj.label.trim() : id;
|
|
197
|
-
const kind: ThemeKind =
|
|
198
|
-
obj.kind === 'light' ? 'light' : obj.kind === 'high-contrast' ? 'high-contrast' : 'dark';
|
|
199
|
-
const rawPaletteCandidate = obj.colors ?? obj.tokens;
|
|
200
|
-
const rawColors =
|
|
201
|
-
typeof rawPaletteCandidate === 'object' && rawPaletteCandidate !== null && !Array.isArray(rawPaletteCandidate)
|
|
202
|
-
? (rawPaletteCandidate as Record<string, unknown>)
|
|
203
|
-
: {};
|
|
204
|
-
const base = kind === 'light' ? LIGHT_THEME : kind === 'high-contrast' ? HIGH_CONTRAST_THEME : DARK_THEME;
|
|
205
|
-
const colors: Record<string, string> = { ...base.colors };
|
|
206
|
-
let explicitAccentFg = false;
|
|
207
|
-
let explicitFgMuted = false;
|
|
208
|
-
let explicitMuted = false;
|
|
209
|
-
for (const [k, v] of Object.entries(rawColors)) {
|
|
210
|
-
if (typeof v === 'string') {
|
|
211
|
-
const cssVar = k.startsWith('--') ? k : `--cl-${k.replace(/\./g, '-')}`;
|
|
212
|
-
colors[cssVar] = v;
|
|
213
|
-
if (cssVar === '--cl-accent-fg') explicitAccentFg = true;
|
|
214
|
-
if (cssVar === '--cl-fg-muted') explicitFgMuted = true;
|
|
215
|
-
if (cssVar === '--cl-muted') explicitMuted = true;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
if (!explicitAccentFg && colors['--cl-accent']) {
|
|
219
|
-
colors['--cl-accent-fg'] = pickContrastingFg(
|
|
220
|
-
colors['--cl-accent'],
|
|
221
|
-
base.colors['--cl-accent-fg'] ?? '#ffffff'
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
if (explicitMuted && !explicitFgMuted && colors['--cl-muted']) {
|
|
225
|
-
colors['--cl-fg-muted'] = colors['--cl-muted'];
|
|
226
|
-
} else if (explicitFgMuted && !explicitMuted && colors['--cl-fg-muted']) {
|
|
227
|
-
colors['--cl-muted'] = colors['--cl-fg-muted'];
|
|
228
|
-
}
|
|
229
|
-
return {
|
|
230
|
-
id,
|
|
231
|
-
label,
|
|
232
|
-
kind,
|
|
233
|
-
monacoBase: kind === 'light' ? 'vs' : kind === 'high-contrast' ? 'hc-black' : 'vs-dark',
|
|
234
|
-
colors
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
export interface IThemeService extends IDisposable {
|
|
239
|
-
readonly activeTheme: ThemeDefinition;
|
|
240
|
-
readonly onDidChangeTheme: Event<ThemeDefinition>;
|
|
241
|
-
registerTheme(theme: ThemeDefinition): IDisposable;
|
|
242
|
-
getThemes(): ThemeDefinition[];
|
|
243
|
-
setTheme(themeId: string): ThemeDefinition;
|
|
244
|
-
applyToElement(target: HTMLElement): void;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
export const IThemeServiceId = createServiceId<IThemeService>('code-lab.theme');
|
|
248
|
-
|
|
249
|
-
export class ThemeService implements IThemeService {
|
|
250
|
-
private readonly themes = new Map<string, ThemeDefinition>();
|
|
251
|
-
private current: ThemeDefinition = DARK_THEME;
|
|
252
|
-
private readonly changeEmitter = new Emitter<ThemeDefinition>({ name: 'theme.change' });
|
|
253
|
-
|
|
254
|
-
public constructor() {
|
|
255
|
-
this.themes.set(DARK_THEME.id, DARK_THEME);
|
|
256
|
-
this.themes.set(LIGHT_THEME.id, LIGHT_THEME);
|
|
257
|
-
this.themes.set(HIGH_CONTRAST_THEME.id, HIGH_CONTRAST_THEME);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
public get activeTheme(): ThemeDefinition {
|
|
261
|
-
return this.current;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
public get onDidChangeTheme(): Event<ThemeDefinition> {
|
|
265
|
-
return this.changeEmitter.event;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
public registerTheme(theme: ThemeDefinition): IDisposable {
|
|
269
|
-
this.themes.set(theme.id, theme);
|
|
270
|
-
return toDisposable(() => {
|
|
271
|
-
if (theme.id !== 'dark' && theme.id !== 'light' && theme.id !== 'high-contrast') {
|
|
272
|
-
this.themes.delete(theme.id);
|
|
273
|
-
if (this.current.id === theme.id) {
|
|
274
|
-
this.setTheme('dark');
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
public getThemes(): ThemeDefinition[] {
|
|
281
|
-
return Array.from(this.themes.values());
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
public setTheme(themeId: string): ThemeDefinition {
|
|
285
|
-
const next = this.themes.get(themeId) ?? DARK_THEME;
|
|
286
|
-
if (this.current.id === next.id && this.current === next) {
|
|
287
|
-
return this.current;
|
|
288
|
-
}
|
|
289
|
-
this.current = next;
|
|
290
|
-
this.changeEmitter.fire(next);
|
|
291
|
-
return next;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
public applyToElement(target: HTMLElement): void {
|
|
295
|
-
const t = this.current;
|
|
296
|
-
target.setAttribute('data-cl-theme', t.kind);
|
|
297
|
-
target.setAttribute('data-cl-theme-id', t.id);
|
|
298
|
-
target.classList.toggle('cl-theme-light', t.kind === 'light');
|
|
299
|
-
target.classList.toggle('cl-theme-dark', t.kind === 'dark');
|
|
300
|
-
target.classList.toggle('cl-theme-hc', t.kind === 'high-contrast');
|
|
301
|
-
|
|
302
|
-
const setCssVar = (prop: string, val: string): void => {
|
|
303
|
-
if (target.style && typeof target.style.setProperty === 'function') {
|
|
304
|
-
target.style.setProperty(prop, val);
|
|
305
|
-
} else if (target.style) {
|
|
306
|
-
(target.style as unknown as Record<string, string>)[prop] = val;
|
|
307
|
-
}
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
for (const [cssVar, val] of Object.entries(t.colors)) {
|
|
311
|
-
setCssVar(cssVar, val);
|
|
312
|
-
}
|
|
313
|
-
const accent = t.colors['--cl-accent'];
|
|
314
|
-
const accentFg = t.colors['--cl-accent-fg'] ?? (accent ? pickContrastingFg(accent) : '#ffffff');
|
|
315
|
-
setCssVar('--cl-accent-fg', accentFg);
|
|
316
|
-
const fgMuted = t.colors['--cl-fg-muted'] ?? t.colors['--cl-muted'];
|
|
317
|
-
if (fgMuted) {
|
|
318
|
-
setCssVar('--cl-fg-muted', fgMuted);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
// Pair color-scheme with explicit background/color/accent-color per Modern Web Guidance
|
|
322
|
-
if (target.style) {
|
|
323
|
-
target.style.colorScheme = t.kind === 'light' ? 'light' : 'dark';
|
|
324
|
-
if (t.colors['--cl-bg']) target.style.backgroundColor = t.colors['--cl-bg'];
|
|
325
|
-
if (t.colors['--cl-fg']) target.style.color = t.colors['--cl-fg'];
|
|
326
|
-
if (accent) target.style.accentColor = accent;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
public dispose(): void {
|
|
331
|
-
this.changeEmitter.dispose();
|
|
332
|
-
}
|
|
333
|
-
}
|
|
@@ -1,24 +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/settings": ["../settings/src/index.ts"],
|
|
20
|
-
"@code-lab/commands": ["../commands/src/index.ts"]
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"include": ["src/**/*.ts"]
|
|
24
|
-
}
|
package/src/workbench/drawer.ts
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @innovatorved/code-lab — Resizable Bottom Drawer, Contextual Tabs & Telemetry HUD
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { CL_ICONS } from './icons';
|
|
6
|
-
|
|
7
|
-
function escapeHtml(str: unknown): string {
|
|
8
|
-
return String(str ?? '')
|
|
9
|
-
.replace(/&/g, '&')
|
|
10
|
-
.replace(/</g, '<')
|
|
11
|
-
.replace(/>/g, '>')
|
|
12
|
-
.replace(/"/g, '"')
|
|
13
|
-
.replace(/'/g, ''');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface DrawerTabOptions {
|
|
17
|
-
workbench: any;
|
|
18
|
-
drawerTab: string;
|
|
19
|
-
hasGuidedLab: boolean;
|
|
20
|
-
mode: string;
|
|
21
|
-
hasWebContent: boolean;
|
|
22
|
-
problemsCount: number;
|
|
23
|
-
testSuiteVisible: boolean;
|
|
24
|
-
lastDurationMs: number | null;
|
|
25
|
-
lastPeakMemoryBytes: number | null;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function formatTelemetryHud(durationMs: number | null, memoryBytes: number | null, lang: string): string {
|
|
29
|
-
if (durationMs === null && memoryBytes === null) return '';
|
|
30
|
-
|
|
31
|
-
const timeStr = durationMs !== null
|
|
32
|
-
? (durationMs < 1000 ? `${durationMs.toFixed(1)} ms` : `${(durationMs / 1000).toFixed(2)} s`)
|
|
33
|
-
: '';
|
|
34
|
-
|
|
35
|
-
let memStr = '';
|
|
36
|
-
if (memoryBytes !== null && memoryBytes > 0) {
|
|
37
|
-
const mb = memoryBytes / (1024 * 1024);
|
|
38
|
-
const suffix = lang === 'cpp' ? 'Wasm' : lang === 'py' ? 'Heap' : 'Mem';
|
|
39
|
-
memStr = `${mb < 0.1 ? (memoryBytes / 1024).toFixed(1) + ' KB' : mb.toFixed(1) + ' MB'} ${suffix}`;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return `
|
|
43
|
-
<div class="codelab-hud-pill" id="cl-telemetry-hud" title="Last Execution Telemetry">
|
|
44
|
-
${timeStr ? `<span class="codelab-hud-pill__metric">${CL_ICONS.clock} <span>${timeStr}</span></span>` : ''}
|
|
45
|
-
${timeStr && memStr ? `<span style="opacity:0.4;">·</span>` : ''}
|
|
46
|
-
${memStr ? `<span class="codelab-hud-pill__metric">${CL_ICONS.memory} <span>${memStr}</span></span>` : ''}
|
|
47
|
-
</div>
|
|
48
|
-
`;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function renderDrawerTabsHtml(opts: DrawerTabOptions): string {
|
|
52
|
-
const { workbench, drawerTab, hasGuidedLab, mode, hasWebContent, problemsCount, testSuiteVisible, lastDurationMs, lastPeakMemoryBytes } = opts;
|
|
53
|
-
const isGuided = Boolean(hasGuidedLab && mode === 'guided');
|
|
54
|
-
const showTests = isGuided || testSuiteVisible || drawerTab === 'tests';
|
|
55
|
-
|
|
56
|
-
return `
|
|
57
|
-
<div class="codelab-drawer__header">
|
|
58
|
-
<div class="codelab-drawer__tabs" role="tablist" aria-label="Terminal & Diagnostics Panels">
|
|
59
|
-
<button type="button" role="tab" aria-selected="${drawerTab === 'terminal'}" class="codelab-drawer__tab ${drawerTab === 'terminal' ? 'active' : ''}" data-cl-drawertab="terminal">
|
|
60
|
-
${CL_ICONS.terminal}
|
|
61
|
-
<span>Terminal & REPL</span>
|
|
62
|
-
</button>
|
|
63
|
-
|
|
64
|
-
<button type="button" role="tab" aria-selected="${drawerTab === 'problems'}" class="codelab-drawer__tab ${drawerTab === 'problems' ? 'active' : ''}" data-cl-drawertab="problems" title="Compiler & Runtime Problems">
|
|
65
|
-
${CL_ICONS.warning}
|
|
66
|
-
<span>Problems</span>
|
|
67
|
-
<span class="codelab-badge ${problemsCount > 0 ? 'codelab-badge--warn' : ''}" id="cl-problems-count">${problemsCount}</span>
|
|
68
|
-
</button>
|
|
69
|
-
|
|
70
|
-
<button type="button" role="tab" aria-selected="${drawerTab === 'tests'}" class="codelab-drawer__tab ${drawerTab === 'tests' ? 'active' : ''}" data-cl-drawertab="tests">
|
|
71
|
-
${CL_ICONS.check}
|
|
72
|
-
<span>Test Suite</span>
|
|
73
|
-
</button>
|
|
74
|
-
|
|
75
|
-
<button type="button" role="tab" aria-selected="${drawerTab === 'stdin'}" class="codelab-drawer__tab ${drawerTab === 'stdin' ? 'active' : ''}" data-cl-drawertab="stdin" title="Standard Input / Competitive Programming Custom Input">
|
|
76
|
-
${CL_ICONS.keyboard}
|
|
77
|
-
<span>Stdin</span>
|
|
78
|
-
</button>
|
|
79
|
-
|
|
80
|
-
<button type="button" role="tab" aria-selected="${drawerTab === 'ports'}" class="codelab-drawer__tab ${drawerTab === 'ports' ? 'active' : ''}" data-cl-drawertab="ports">
|
|
81
|
-
${CL_ICONS.radio}
|
|
82
|
-
<span>Ports</span>
|
|
83
|
-
</button>
|
|
84
|
-
|
|
85
|
-
<button type="button" role="tab" aria-selected="${drawerTab === 'preview'}" class="codelab-drawer__tab ${drawerTab === 'preview' ? 'active' : ''}" data-cl-drawertab="preview" title="In-browser Web Preview">
|
|
86
|
-
${CL_ICONS.externalLink || CL_ICONS.globe}
|
|
87
|
-
<span>Web Preview</span>
|
|
88
|
-
</button>
|
|
89
|
-
|
|
90
|
-
<button type="button" role="tab" aria-selected="${drawerTab === 'network'}" class="codelab-drawer__tab ${drawerTab === 'network' ? 'active' : ''}" data-cl-drawertab="network">
|
|
91
|
-
${CL_ICONS.activity}
|
|
92
|
-
<span>Network</span>
|
|
93
|
-
</button>
|
|
94
|
-
|
|
95
|
-
<button type="button" role="tab" aria-selected="${drawerTab === 'inspector'}" class="codelab-drawer__tab ${drawerTab === 'inspector' ? 'active' : ''}" data-cl-drawertab="inspector">
|
|
96
|
-
${CL_ICONS.database}
|
|
97
|
-
<span>Virtual Disk & HTTP</span>
|
|
98
|
-
</button>
|
|
99
|
-
</div>
|
|
100
|
-
|
|
101
|
-
${formatTelemetryHud(lastDurationMs, lastPeakMemoryBytes, workbench.lang || 'js')}
|
|
102
|
-
|
|
103
|
-
<div class="codelab-drawer__actions">
|
|
104
|
-
<button type="button" class="codelab-btn codelab-btn--icon" data-cl-action="toggle-drawer" title="Minimize/Expand Drawer" aria-label="Minimize or Expand Drawer">
|
|
105
|
-
${CL_ICONS.chevronsUpDown}
|
|
106
|
-
</button>
|
|
107
|
-
</div>
|
|
108
|
-
</div>
|
|
109
|
-
`;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function renderProblemsPanelHtml(workbench: any): string {
|
|
113
|
-
const store = workbench._diagnosticsStore;
|
|
114
|
-
const items = store ? store.getAll() : [];
|
|
115
|
-
|
|
116
|
-
if (items.length === 0) {
|
|
117
|
-
return `
|
|
118
|
-
<div class="cl-ui-empty-center">
|
|
119
|
-
${CL_ICONS.check}
|
|
120
|
-
<span>No problems detected in workspace.</span>
|
|
121
|
-
</div>
|
|
122
|
-
`;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return `
|
|
126
|
-
<div class="codelab-problems-list">
|
|
127
|
-
${items.map((item: any) => {
|
|
128
|
-
const icon = item.severity === 'error' ? '✗' : (item.severity === 'warning' ? '⚠' : 'ℹ');
|
|
129
|
-
const cls = item.severity === 'error' ? 'codelab-problem-item--error' : (item.severity === 'warning' ? 'codelab-problem-item--warning' : 'codelab-problem-item--info');
|
|
130
|
-
const safeFile = escapeHtml(item.file);
|
|
131
|
-
const safeMsg = escapeHtml(item.message);
|
|
132
|
-
const safeLine = Number(item.line) || 1;
|
|
133
|
-
const safeCol = Number(item.col) || 1;
|
|
134
|
-
return `
|
|
135
|
-
<div class="codelab-problem-item ${cls}" data-cl-problem-file="${safeFile}" data-cl-problem-line="${safeLine}" data-cl-problem-col="${safeCol}">
|
|
136
|
-
<span style="font-weight:bold;">${icon}</span>
|
|
137
|
-
<span>${safeMsg}</span>
|
|
138
|
-
<span class="codelab-problem-item__location">${safeFile}:${safeLine}:${safeCol}</span>
|
|
139
|
-
</div>
|
|
140
|
-
`;
|
|
141
|
-
}).join('')}
|
|
142
|
-
</div>
|
|
143
|
-
`;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export function renderStdinPanelHtml(workbench: any): string {
|
|
147
|
-
const val = escapeHtml(workbench.customStdin || '');
|
|
148
|
-
return `
|
|
149
|
-
<div class="codelab-stdin-panel">
|
|
150
|
-
<div class="codelab-stdin-panel__header">
|
|
151
|
-
<span>Standard Input (std::cin / sys.stdin / process.stdin)</span>
|
|
152
|
-
<button type="button" class="codelab-btn codelab-btn--sm" id="cl-stdin-clear-btn">Clear</button>
|
|
153
|
-
</div>
|
|
154
|
-
<textarea class="codelab-stdin-panel__textarea" id="cl-stdin-textarea" placeholder="Paste custom input lines here for DSA / competitive programming...">${val}</textarea>
|
|
155
|
-
</div>
|
|
156
|
-
`;
|
|
157
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @innovatorved/code-lab — Explorer File Tree & CRUD Utilities
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { CL_ICONS } from './icons';
|
|
6
|
-
|
|
7
|
-
export interface FileNode {
|
|
8
|
-
name: string;
|
|
9
|
-
fullPath: string;
|
|
10
|
-
isFolder: boolean;
|
|
11
|
-
children: FileNode[];
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function buildFileHierarchy(files: Record<string, string>, creatingItem?: any): FileNode {
|
|
15
|
-
const root: FileNode = { name: '', fullPath: '', isFolder: true, children: [] };
|
|
16
|
-
|
|
17
|
-
const paths = Object.keys(files).sort();
|
|
18
|
-
for (const p of paths) {
|
|
19
|
-
const parts = p.split('/').filter(Boolean);
|
|
20
|
-
let curr = root;
|
|
21
|
-
let accPath = '';
|
|
22
|
-
|
|
23
|
-
for (let i = 0; i < parts.length; i++) {
|
|
24
|
-
const part = parts[i];
|
|
25
|
-
accPath = accPath ? `${accPath}/${part}` : part;
|
|
26
|
-
const isLast = i === parts.length - 1;
|
|
27
|
-
|
|
28
|
-
let child = curr.children.find((c) => c.name === part);
|
|
29
|
-
if (!child) {
|
|
30
|
-
child = {
|
|
31
|
-
name: part,
|
|
32
|
-
fullPath: accPath,
|
|
33
|
-
isFolder: !isLast,
|
|
34
|
-
children: []
|
|
35
|
-
};
|
|
36
|
-
curr.children.push(child);
|
|
37
|
-
}
|
|
38
|
-
curr = child;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return root;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function getFileIcon(filename: string): string {
|
|
46
|
-
if (filename.endsWith('.json')) return CL_ICONS.database;
|
|
47
|
-
if (filename.endsWith('.md')) return CL_ICONS.book;
|
|
48
|
-
if (filename.endsWith('.cpp') || filename.endsWith('.hpp') || filename.endsWith('.h')) return CL_ICONS.code;
|
|
49
|
-
if (filename.endsWith('.py')) return CL_ICONS.code;
|
|
50
|
-
return CL_ICONS.file;
|
|
51
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @innovatorved/code-lab — Guided Pane: Walkthrough Stepper, Hints & Verification
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { CL_ICONS } from './icons';
|
|
6
|
-
|
|
7
|
-
function escapeHtml(str: unknown): string {
|
|
8
|
-
return String(str ?? '')
|
|
9
|
-
.replace(/&/g, '&')
|
|
10
|
-
.replace(/</g, '<')
|
|
11
|
-
.replace(/>/g, '>')
|
|
12
|
-
.replace(/"/g, '"')
|
|
13
|
-
.replace(/'/g, ''');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface GuidedStepData {
|
|
17
|
-
id: string;
|
|
18
|
-
title: string;
|
|
19
|
-
instructions: string | string[];
|
|
20
|
-
hint?: string;
|
|
21
|
-
testNames?: string[];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function renderStepPillsHtml(steps: GuidedStepData[], activeIndex: number, completedStepIds: Set<string>): string {
|
|
25
|
-
if (!steps || steps.length === 0) return '';
|
|
26
|
-
|
|
27
|
-
return `
|
|
28
|
-
<div class="codelab-stepper" role="tablist" aria-label="Step progress">
|
|
29
|
-
${steps.map((step, idx) => {
|
|
30
|
-
const isPassed = completedStepIds.has(step.id);
|
|
31
|
-
const isActive = idx === activeIndex;
|
|
32
|
-
const cls = `codelab-step-pill ${isActive ? 'active' : ''} ${isPassed ? 'passed' : ''}`;
|
|
33
|
-
const safeTitle = escapeHtml(step.title);
|
|
34
|
-
return `
|
|
35
|
-
<button type="button" role="tab" aria-selected="${isActive}" class="${cls}" data-cl-step="${idx}" title="Step ${idx + 1}: ${safeTitle}">
|
|
36
|
-
<span class="codelab-step-pill__num">${isPassed ? CL_ICONS.check : idx + 1}</span>
|
|
37
|
-
<span class="codelab-step-pill__label">${safeTitle}</span>
|
|
38
|
-
</button>
|
|
39
|
-
`;
|
|
40
|
-
}).join('')}
|
|
41
|
-
</div>
|
|
42
|
-
`;
|
|
43
|
-
}
|