@innovatorved/code-lab 0.4.0 → 0.5.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 +2 -2
- package/CHANGELOG.md +21 -0
- package/README.md +4 -28
- package/dist/code-lab-sql.esm.js +1 -1
- package/dist/code-lab-sql.umd.js +2 -2
- package/dist/code-lab.css +1553 -98
- package/dist/code-lab.d.ts +1 -1
- package/dist/code-lab.esm.js +11883 -1619
- package/dist/code-lab.js +11882 -1618
- package/dist/code-lab.umd.js +11882 -1618
- package/dist/diagnostics.d.ts +3 -0
- package/dist/extensions/cpp.esm.js +27 -29
- package/dist/extensions/cpp.js +27 -29
- package/dist/extensions/python.esm.js +27 -28
- package/dist/extensions/python.js +27 -28
- package/dist/index.d.ts +1 -1
- package/dist/packages/settings/src/configuration-service.d.ts +7 -0
- package/dist/packages/settings/src/index.d.ts +1 -1
- package/dist/packages/ui/src/index.d.ts +2 -2
- package/dist/packages/ui/src/plugin-registry.d.ts +1 -0
- package/dist/packages/ui/src/settings-dialog.d.ts +31 -3
- package/dist/packages/ui/src/themes.d.ts +5 -0
- package/dist/preview-sw.js +1 -1
- package/dist/runtime.esm.js +1 -1
- package/dist/runtime.js +1 -1
- package/dist/schemas.d.ts +1 -1
- package/dist/scm.d.ts +92 -11
- package/dist/shell.esm.js +937 -113
- package/dist/shell.js +937 -113
- package/dist/storage.d.ts +47 -0
- package/dist/terminal.esm.js +1 -1
- package/dist/terminal.js +1 -1
- package/dist/workbench/index.d.ts +1 -1
- package/dist/workbench/styles.d.ts +1 -1
- package/package.json +2 -2
- package/packages/commands/package.json +1 -1
- package/packages/core/package.json +1 -1
- package/packages/editor/package.json +1 -1
- package/packages/fs/package.json +1 -1
- package/packages/preview/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/settings/package.json +1 -1
- package/packages/settings/src/builtin-schemas.ts +17 -6
- package/packages/settings/src/configuration-service.ts +72 -6
- package/packages/settings/src/index.ts +1 -0
- package/packages/sql/package.json +1 -1
- package/packages/terminal/package.json +1 -1
- package/packages/ui/package.json +1 -1
- package/packages/ui/src/index.ts +4 -0
- package/packages/ui/src/plugin-registry.ts +17 -2
- package/packages/ui/src/settings-dialog.ts +374 -92
- package/packages/ui/src/themes.ts +105 -12
- package/src/code-lab.css +1553 -98
- package/src/diagnostics.ts +139 -7
- package/src/extensions/cpp.ts +33 -33
- package/src/extensions/python.ts +33 -32
- package/src/index.ts +1 -1
- package/src/schemas.ts +1 -1
- package/src/scm.ts +781 -58
- package/src/shell.ts +936 -112
- package/src/storage.ts +336 -3
- package/src/workbench/icons.ts +8 -1
- package/src/workbench/styles.ts +25 -19
- package/src/workbench.ts +12010 -3814
|
@@ -28,8 +28,10 @@ export const DARK_THEME: ThemeDefinition = {
|
|
|
28
28
|
'--cl-surface': '#0a0a0a',
|
|
29
29
|
'--cl-fg': '#f5f5f5',
|
|
30
30
|
'--cl-muted': '#8e8e93',
|
|
31
|
+
'--cl-fg-muted': '#8e8e93',
|
|
31
32
|
'--cl-border': '#262626',
|
|
32
|
-
'--cl-accent': '#
|
|
33
|
+
'--cl-accent': '#0ea5e9',
|
|
34
|
+
'--cl-accent-fg': '#000000'
|
|
33
35
|
}
|
|
34
36
|
};
|
|
35
37
|
|
|
@@ -42,9 +44,11 @@ export const LIGHT_THEME: ThemeDefinition = {
|
|
|
42
44
|
'--cl-bg': '#ffffff',
|
|
43
45
|
'--cl-surface': '#f8fafc',
|
|
44
46
|
'--cl-fg': '#0f172a',
|
|
45
|
-
'--cl-muted': '#
|
|
46
|
-
'--cl-
|
|
47
|
-
'--cl-
|
|
47
|
+
'--cl-muted': '#475569',
|
|
48
|
+
'--cl-fg-muted': '#475569',
|
|
49
|
+
'--cl-border': '#cbd5e1',
|
|
50
|
+
'--cl-accent': '#0369a1',
|
|
51
|
+
'--cl-accent-fg': '#ffffff'
|
|
48
52
|
}
|
|
49
53
|
};
|
|
50
54
|
|
|
@@ -58,11 +62,64 @@ export const HIGH_CONTRAST_THEME: ThemeDefinition = {
|
|
|
58
62
|
'--cl-surface': '#000000',
|
|
59
63
|
'--cl-fg': '#ffffff',
|
|
60
64
|
'--cl-muted': '#e5e5e5',
|
|
65
|
+
'--cl-fg-muted': '#e5e5e5',
|
|
61
66
|
'--cl-border': '#facc15',
|
|
62
|
-
'--cl-accent': '#38bdf8'
|
|
67
|
+
'--cl-accent': '#38bdf8',
|
|
68
|
+
'--cl-accent-fg': '#000000'
|
|
63
69
|
}
|
|
64
70
|
};
|
|
65
71
|
|
|
72
|
+
function parseColorRgb(raw: string): [number, number, number] | null {
|
|
73
|
+
const s = raw.trim();
|
|
74
|
+
if (s.startsWith('#')) {
|
|
75
|
+
const hex = s.slice(1);
|
|
76
|
+
if (hex.length === 3 || hex.length === 4) {
|
|
77
|
+
const r = Number.parseInt(hex[0] + hex[0], 16);
|
|
78
|
+
const g = Number.parseInt(hex[1] + hex[1], 16);
|
|
79
|
+
const b = Number.parseInt(hex[2] + hex[2], 16);
|
|
80
|
+
if (Number.isFinite(r) && Number.isFinite(g) && Number.isFinite(b)) return [r, g, b];
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
if (hex.length === 6 || hex.length === 8) {
|
|
84
|
+
const r = Number.parseInt(hex.slice(0, 2), 16);
|
|
85
|
+
const g = Number.parseInt(hex.slice(2, 4), 16);
|
|
86
|
+
const b = Number.parseInt(hex.slice(4, 6), 16);
|
|
87
|
+
if (Number.isFinite(r) && Number.isFinite(g) && Number.isFinite(b)) return [r, g, b];
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
const rgbMatch = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})/i.exec(s);
|
|
93
|
+
if (rgbMatch) {
|
|
94
|
+
const r = Math.min(255, Number.parseInt(rgbMatch[1], 10));
|
|
95
|
+
const g = Math.min(255, Number.parseInt(rgbMatch[2], 10));
|
|
96
|
+
const b = Math.min(255, Number.parseInt(rgbMatch[3], 10));
|
|
97
|
+
return [r, g, b];
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function toLinearChannel(channel8Bit: number): number {
|
|
103
|
+
const srgb = channel8Bit / 255;
|
|
104
|
+
return srgb <= 0.04045 ? srgb / 12.92 : Math.pow((srgb + 0.055) / 1.055, 2.4);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Picks `'#ffffff'` or `'#000000'` to maximize WCAG 2.1 contrast (>= 4.58:1)
|
|
109
|
+
* against a solid hex/rgb background color, returning `fallback` for dynamic CSS expressions.
|
|
110
|
+
*/
|
|
111
|
+
export function pickContrastingFg(color: string, fallback = '#ffffff'): string {
|
|
112
|
+
const rgb = parseColorRgb(color);
|
|
113
|
+
if (!rgb) return fallback;
|
|
114
|
+
const lum =
|
|
115
|
+
0.2126 * toLinearChannel(rgb[0]) +
|
|
116
|
+
0.7152 * toLinearChannel(rgb[1]) +
|
|
117
|
+
0.0722 * toLinearChannel(rgb[2]);
|
|
118
|
+
const whiteContrast = 1.05 / (lum + 0.05);
|
|
119
|
+
const blackContrast = (lum + 0.05) / 0.05;
|
|
120
|
+
return whiteContrast >= blackContrast ? '#ffffff' : '#000000';
|
|
121
|
+
}
|
|
122
|
+
|
|
66
123
|
export function parseCustomTheme(rawJsonc: string): ThemeDefinition {
|
|
67
124
|
const parsed = parseJsonc<Record<string, unknown>>(rawJsonc);
|
|
68
125
|
if (!parsed.value || typeof parsed.value !== 'object' || Array.isArray(parsed.value)) {
|
|
@@ -73,18 +130,36 @@ export function parseCustomTheme(rawJsonc: string): ThemeDefinition {
|
|
|
73
130
|
const label = typeof obj.label === 'string' && obj.label.trim() ? obj.label.trim() : id;
|
|
74
131
|
const kind: ThemeKind =
|
|
75
132
|
obj.kind === 'light' ? 'light' : obj.kind === 'high-contrast' ? 'high-contrast' : 'dark';
|
|
133
|
+
const rawPaletteCandidate = obj.colors ?? obj.tokens;
|
|
76
134
|
const rawColors =
|
|
77
|
-
typeof
|
|
78
|
-
? (
|
|
135
|
+
typeof rawPaletteCandidate === 'object' && rawPaletteCandidate !== null && !Array.isArray(rawPaletteCandidate)
|
|
136
|
+
? (rawPaletteCandidate as Record<string, unknown>)
|
|
79
137
|
: {};
|
|
80
138
|
const base = kind === 'light' ? LIGHT_THEME : kind === 'high-contrast' ? HIGH_CONTRAST_THEME : DARK_THEME;
|
|
81
139
|
const colors: Record<string, string> = { ...base.colors };
|
|
140
|
+
let explicitAccentFg = false;
|
|
141
|
+
let explicitFgMuted = false;
|
|
142
|
+
let explicitMuted = false;
|
|
82
143
|
for (const [k, v] of Object.entries(rawColors)) {
|
|
83
144
|
if (typeof v === 'string') {
|
|
84
145
|
const cssVar = k.startsWith('--') ? k : `--cl-${k.replace(/\./g, '-')}`;
|
|
85
146
|
colors[cssVar] = v;
|
|
147
|
+
if (cssVar === '--cl-accent-fg') explicitAccentFg = true;
|
|
148
|
+
if (cssVar === '--cl-fg-muted') explicitFgMuted = true;
|
|
149
|
+
if (cssVar === '--cl-muted') explicitMuted = true;
|
|
86
150
|
}
|
|
87
151
|
}
|
|
152
|
+
if (!explicitAccentFg && colors['--cl-accent']) {
|
|
153
|
+
colors['--cl-accent-fg'] = pickContrastingFg(
|
|
154
|
+
colors['--cl-accent'],
|
|
155
|
+
base.colors['--cl-accent-fg'] ?? '#ffffff'
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
if (explicitMuted && !explicitFgMuted && colors['--cl-muted']) {
|
|
159
|
+
colors['--cl-fg-muted'] = colors['--cl-muted'];
|
|
160
|
+
} else if (explicitFgMuted && !explicitMuted && colors['--cl-fg-muted']) {
|
|
161
|
+
colors['--cl-muted'] = colors['--cl-fg-muted'];
|
|
162
|
+
}
|
|
88
163
|
return {
|
|
89
164
|
id,
|
|
90
165
|
label,
|
|
@@ -158,14 +233,32 @@ export class ThemeService implements IThemeService {
|
|
|
158
233
|
target.classList.toggle('cl-theme-dark', t.kind === 'dark');
|
|
159
234
|
target.classList.toggle('cl-theme-hc', t.kind === 'high-contrast');
|
|
160
235
|
|
|
236
|
+
const setCssVar = (prop: string, val: string): void => {
|
|
237
|
+
if (target.style && typeof target.style.setProperty === 'function') {
|
|
238
|
+
target.style.setProperty(prop, val);
|
|
239
|
+
} else if (target.style) {
|
|
240
|
+
(target.style as unknown as Record<string, string>)[prop] = val;
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
|
|
161
244
|
for (const [cssVar, val] of Object.entries(t.colors)) {
|
|
162
|
-
|
|
245
|
+
setCssVar(cssVar, val);
|
|
246
|
+
}
|
|
247
|
+
const accent = t.colors['--cl-accent'];
|
|
248
|
+
const accentFg = t.colors['--cl-accent-fg'] ?? (accent ? pickContrastingFg(accent) : '#ffffff');
|
|
249
|
+
setCssVar('--cl-accent-fg', accentFg);
|
|
250
|
+
const fgMuted = t.colors['--cl-fg-muted'] ?? t.colors['--cl-muted'];
|
|
251
|
+
if (fgMuted) {
|
|
252
|
+
setCssVar('--cl-fg-muted', fgMuted);
|
|
163
253
|
}
|
|
254
|
+
|
|
164
255
|
// Pair color-scheme with explicit background/color/accent-color per Modern Web Guidance
|
|
165
|
-
target.style
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
256
|
+
if (target.style) {
|
|
257
|
+
target.style.colorScheme = t.kind === 'light' ? 'light' : 'dark';
|
|
258
|
+
if (t.colors['--cl-bg']) target.style.backgroundColor = t.colors['--cl-bg'];
|
|
259
|
+
if (t.colors['--cl-fg']) target.style.color = t.colors['--cl-fg'];
|
|
260
|
+
if (accent) target.style.accentColor = accent;
|
|
261
|
+
}
|
|
169
262
|
}
|
|
170
263
|
|
|
171
264
|
public dispose(): void {
|