@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.
Files changed (64) hide show
  1. package/ARCHITECTURE.md +2 -2
  2. package/CHANGELOG.md +21 -0
  3. package/README.md +4 -28
  4. package/dist/code-lab-sql.esm.js +1 -1
  5. package/dist/code-lab-sql.umd.js +2 -2
  6. package/dist/code-lab.css +1553 -98
  7. package/dist/code-lab.d.ts +1 -1
  8. package/dist/code-lab.esm.js +11883 -1619
  9. package/dist/code-lab.js +11882 -1618
  10. package/dist/code-lab.umd.js +11882 -1618
  11. package/dist/diagnostics.d.ts +3 -0
  12. package/dist/extensions/cpp.esm.js +27 -29
  13. package/dist/extensions/cpp.js +27 -29
  14. package/dist/extensions/python.esm.js +27 -28
  15. package/dist/extensions/python.js +27 -28
  16. package/dist/index.d.ts +1 -1
  17. package/dist/packages/settings/src/configuration-service.d.ts +7 -0
  18. package/dist/packages/settings/src/index.d.ts +1 -1
  19. package/dist/packages/ui/src/index.d.ts +2 -2
  20. package/dist/packages/ui/src/plugin-registry.d.ts +1 -0
  21. package/dist/packages/ui/src/settings-dialog.d.ts +31 -3
  22. package/dist/packages/ui/src/themes.d.ts +5 -0
  23. package/dist/preview-sw.js +1 -1
  24. package/dist/runtime.esm.js +1 -1
  25. package/dist/runtime.js +1 -1
  26. package/dist/schemas.d.ts +1 -1
  27. package/dist/scm.d.ts +92 -11
  28. package/dist/shell.esm.js +937 -113
  29. package/dist/shell.js +937 -113
  30. package/dist/storage.d.ts +47 -0
  31. package/dist/terminal.esm.js +1 -1
  32. package/dist/terminal.js +1 -1
  33. package/dist/workbench/index.d.ts +1 -1
  34. package/dist/workbench/styles.d.ts +1 -1
  35. package/package.json +2 -2
  36. package/packages/commands/package.json +1 -1
  37. package/packages/core/package.json +1 -1
  38. package/packages/editor/package.json +1 -1
  39. package/packages/fs/package.json +1 -1
  40. package/packages/preview/package.json +1 -1
  41. package/packages/runtime/package.json +1 -1
  42. package/packages/settings/package.json +1 -1
  43. package/packages/settings/src/builtin-schemas.ts +17 -6
  44. package/packages/settings/src/configuration-service.ts +72 -6
  45. package/packages/settings/src/index.ts +1 -0
  46. package/packages/sql/package.json +1 -1
  47. package/packages/terminal/package.json +1 -1
  48. package/packages/ui/package.json +1 -1
  49. package/packages/ui/src/index.ts +4 -0
  50. package/packages/ui/src/plugin-registry.ts +17 -2
  51. package/packages/ui/src/settings-dialog.ts +374 -92
  52. package/packages/ui/src/themes.ts +105 -12
  53. package/src/code-lab.css +1553 -98
  54. package/src/diagnostics.ts +139 -7
  55. package/src/extensions/cpp.ts +33 -33
  56. package/src/extensions/python.ts +33 -32
  57. package/src/index.ts +1 -1
  58. package/src/schemas.ts +1 -1
  59. package/src/scm.ts +781 -58
  60. package/src/shell.ts +936 -112
  61. package/src/storage.ts +336 -3
  62. package/src/workbench/icons.ts +8 -1
  63. package/src/workbench/styles.ts +25 -19
  64. package/src/workbench.ts +12010 -3814
@@ -24,6 +24,7 @@ export interface DiagnosticItem {
24
24
  tags?: string[];
25
25
  }
26
26
  export type DiagnosticListener = (items: DiagnosticItem[]) => void;
27
+ export declare function normalizeDiagnosticFilePath(rawFile: string): string;
27
28
  export declare class DiagnosticsStore {
28
29
  private readonly items;
29
30
  private readonly listeners;
@@ -31,6 +32,7 @@ export declare class DiagnosticsStore {
31
32
  private batchDirty;
32
33
  private normalizeItem;
33
34
  add(item: DiagnosticItem): void;
35
+ setFileDiagnostics(file: string, sourceOrDiags: string | ReadonlyArray<Partial<DiagnosticItem>>, diagsOrSource?: ReadonlyArray<Partial<DiagnosticItem>> | string): DiagnosticItem[];
34
36
  setMany(items: ReadonlyArray<DiagnosticItem>, clearSource?: string): void;
35
37
  batch(fn: () => void): void;
36
38
  remove(id: string): void;
@@ -44,5 +46,6 @@ export declare function createDiagnosticsStore(): DiagnosticsStore;
44
46
  declare const _default: {
45
47
  DiagnosticsStore: typeof DiagnosticsStore;
46
48
  createDiagnosticsStore: typeof createDiagnosticsStore;
49
+ normalizeDiagnosticFilePath: typeof normalizeDiagnosticFilePath;
47
50
  };
48
51
  export default _default;
@@ -21881,35 +21881,33 @@ function installCppExtension(workbench, options = {}) {
21881
21881
  seedCppHeadersIntoVfs(workbench.vfs, toolchain.options.extraHeaders);
21882
21882
  }
21883
21883
  workbench.hasMultipleLanguages = workbench.enabledLanguages.size > 1;
21884
- if (workbench._diagnosticsStore) {
21885
- let lintTimer = null;
21886
- const originalOnCodeChange = workbench.options?.onCodeChange;
21887
- workbench._cppLintHandler = (file2, code) => {
21888
- if (!file2 || !/\.(?:cpp|cc|cxx|hpp|h)$/.test(file2)) return;
21889
- if (lintTimer) clearTimeout(lintTimer);
21890
- lintTimer = setTimeout(() => {
21891
- const diags = analyzeCppSource(code, file2, workbench.vfs);
21892
- workbench._diagnosticsStore.clear("cpp-linter");
21893
- for (const d of diags) {
21894
- workbench._diagnosticsStore.add(d);
21895
- }
21896
- if (typeof window !== "undefined" && window.monaco) {
21897
- const model = workbench.models && typeof workbench.models.get === "function" && workbench.models.get(file2) || (workbench.activeFile === file2 && workbench.editor ? workbench.editor.getModel() : null);
21898
- if (model) {
21899
- const markers = diags.map((d) => ({
21900
- startLineNumber: d.line,
21901
- startColumn: d.col || 1,
21902
- endLineNumber: d.line,
21903
- endColumn: (d.col || 1) + 20,
21904
- message: d.message,
21905
- severity: d.severity === "error" ? window.monaco.MarkerSeverity.Error : window.monaco.MarkerSeverity.Warning
21906
- }));
21907
- window.monaco.editor.setModelMarkers(model, "cpp-linter", markers);
21908
- }
21909
- }
21910
- }, 180);
21911
- };
21912
- }
21884
+ workbench._cppLintHandler = (file2, code) => {
21885
+ if (!file2 || !/\.(?:cpp|cc|cxx|hpp|h)$/i.test(file2)) return;
21886
+ const diags = analyzeCppSource(String(code ?? ""), file2, workbench ? workbench.vfs : void 0);
21887
+ const store = workbench ? workbench._diagnosticsStore : null;
21888
+ if (store && typeof store.setFileDiagnostics === "function") {
21889
+ store.setFileDiagnostics(file2, "cpp-linter", diags);
21890
+ } else if (store && typeof store.clear === "function" && typeof store.add === "function") {
21891
+ store.clear("cpp-linter");
21892
+ for (const d of diags) {
21893
+ store.add(d);
21894
+ }
21895
+ }
21896
+ if (typeof window !== "undefined" && window.monaco) {
21897
+ const model = workbench.models && typeof workbench.models.get === "function" && workbench.models.get(file2) || (workbench.activeFile === file2 && workbench.editor ? workbench.editor.getModel() : null);
21898
+ if (model) {
21899
+ const markers = diags.map((d) => ({
21900
+ startLineNumber: d.line,
21901
+ startColumn: d.col || 1,
21902
+ endLineNumber: d.endLine || d.line,
21903
+ endColumn: d.endCol || (d.col || 1) + 20,
21904
+ message: d.message,
21905
+ severity: d.severity === "error" ? window.monaco.MarkerSeverity.Error : window.monaco.MarkerSeverity.Warning
21906
+ }));
21907
+ window.monaco.editor.setModelMarkers(model, "cpp-linter", markers);
21908
+ }
21909
+ }
21910
+ };
21913
21911
  if (options.preload) {
21914
21912
  toolchain.ensureLoaded().catch((err) => {
21915
21913
  if (typeof workbench._appendTerminalOutput === "function") {
@@ -21917,35 +21917,33 @@ inline void assertBool(bool cond, bool expected, const char* expr, int line) {
21917
21917
  seedCppHeadersIntoVfs(workbench.vfs, toolchain.options.extraHeaders);
21918
21918
  }
21919
21919
  workbench.hasMultipleLanguages = workbench.enabledLanguages.size > 1;
21920
- if (workbench._diagnosticsStore) {
21921
- let lintTimer = null;
21922
- const originalOnCodeChange = workbench.options?.onCodeChange;
21923
- workbench._cppLintHandler = (file2, code) => {
21924
- if (!file2 || !/\.(?:cpp|cc|cxx|hpp|h)$/.test(file2)) return;
21925
- if (lintTimer) clearTimeout(lintTimer);
21926
- lintTimer = setTimeout(() => {
21927
- const diags = analyzeCppSource(code, file2, workbench.vfs);
21928
- workbench._diagnosticsStore.clear("cpp-linter");
21929
- for (const d of diags) {
21930
- workbench._diagnosticsStore.add(d);
21931
- }
21932
- if (typeof window !== "undefined" && window.monaco) {
21933
- const model = workbench.models && typeof workbench.models.get === "function" && workbench.models.get(file2) || (workbench.activeFile === file2 && workbench.editor ? workbench.editor.getModel() : null);
21934
- if (model) {
21935
- const markers = diags.map((d) => ({
21936
- startLineNumber: d.line,
21937
- startColumn: d.col || 1,
21938
- endLineNumber: d.line,
21939
- endColumn: (d.col || 1) + 20,
21940
- message: d.message,
21941
- severity: d.severity === "error" ? window.monaco.MarkerSeverity.Error : window.monaco.MarkerSeverity.Warning
21942
- }));
21943
- window.monaco.editor.setModelMarkers(model, "cpp-linter", markers);
21944
- }
21945
- }
21946
- }, 180);
21947
- };
21948
- }
21920
+ workbench._cppLintHandler = (file2, code) => {
21921
+ if (!file2 || !/\.(?:cpp|cc|cxx|hpp|h)$/i.test(file2)) return;
21922
+ const diags = analyzeCppSource(String(code ?? ""), file2, workbench ? workbench.vfs : void 0);
21923
+ const store = workbench ? workbench._diagnosticsStore : null;
21924
+ if (store && typeof store.setFileDiagnostics === "function") {
21925
+ store.setFileDiagnostics(file2, "cpp-linter", diags);
21926
+ } else if (store && typeof store.clear === "function" && typeof store.add === "function") {
21927
+ store.clear("cpp-linter");
21928
+ for (const d of diags) {
21929
+ store.add(d);
21930
+ }
21931
+ }
21932
+ if (typeof window !== "undefined" && window.monaco) {
21933
+ const model = workbench.models && typeof workbench.models.get === "function" && workbench.models.get(file2) || (workbench.activeFile === file2 && workbench.editor ? workbench.editor.getModel() : null);
21934
+ if (model) {
21935
+ const markers = diags.map((d) => ({
21936
+ startLineNumber: d.line,
21937
+ startColumn: d.col || 1,
21938
+ endLineNumber: d.endLine || d.line,
21939
+ endColumn: d.endCol || (d.col || 1) + 20,
21940
+ message: d.message,
21941
+ severity: d.severity === "error" ? window.monaco.MarkerSeverity.Error : window.monaco.MarkerSeverity.Warning
21942
+ }));
21943
+ window.monaco.editor.setModelMarkers(model, "cpp-linter", markers);
21944
+ }
21945
+ }
21946
+ };
21949
21947
  if (options.preload) {
21950
21948
  toolchain.ensureLoaded().catch((err) => {
21951
21949
  if (typeof workbench._appendTerminalOutput === "function") {
@@ -21211,34 +21211,33 @@ function installPythonExtension(workbench, options = {}) {
21211
21211
  seedPythonModulesIntoVfs(workbench.vfs);
21212
21212
  }
21213
21213
  workbench.hasMultipleLanguages = workbench.enabledLanguages.size > 1;
21214
- if (workbench._diagnosticsStore) {
21215
- let pyLintTimer = null;
21216
- workbench._pyLintHandler = (file2, code) => {
21217
- if (!file2 || !file2.endsWith(".py")) return;
21218
- if (pyLintTimer) clearTimeout(pyLintTimer);
21219
- pyLintTimer = setTimeout(() => {
21220
- const diags = analyzePythonSource(code, file2);
21221
- workbench._diagnosticsStore.clear("python-linter");
21222
- for (const d of diags) {
21223
- workbench._diagnosticsStore.add(d);
21224
- }
21225
- if (typeof window !== "undefined" && window.monaco) {
21226
- const model = workbench.models && typeof workbench.models.get === "function" && workbench.models.get(file2) || (workbench.activeFile === file2 && workbench.editor ? workbench.editor.getModel() : null);
21227
- if (model) {
21228
- const markers = diags.map((d) => ({
21229
- startLineNumber: d.line,
21230
- startColumn: d.col || 1,
21231
- endLineNumber: d.line,
21232
- endColumn: (d.col || 1) + 20,
21233
- message: d.message,
21234
- severity: d.severity === "error" ? window.monaco.MarkerSeverity.Error : window.monaco.MarkerSeverity.Warning
21235
- }));
21236
- window.monaco.editor.setModelMarkers(model, "python-linter", markers);
21237
- }
21238
- }
21239
- }, 180);
21240
- };
21241
- }
21214
+ workbench._pyLintHandler = (file2, code) => {
21215
+ if (!file2 || !/\.py$/i.test(file2)) return;
21216
+ const diags = analyzePythonSource(String(code ?? ""), file2);
21217
+ const store = workbench ? workbench._diagnosticsStore : null;
21218
+ if (store && typeof store.setFileDiagnostics === "function") {
21219
+ store.setFileDiagnostics(file2, "python-linter", diags);
21220
+ } else if (store && typeof store.clear === "function" && typeof store.add === "function") {
21221
+ store.clear("python-linter");
21222
+ for (const d of diags) {
21223
+ store.add(d);
21224
+ }
21225
+ }
21226
+ if (typeof window !== "undefined" && window.monaco) {
21227
+ const model = workbench.models && typeof workbench.models.get === "function" && workbench.models.get(file2) || (workbench.activeFile === file2 && workbench.editor ? workbench.editor.getModel() : null);
21228
+ if (model) {
21229
+ const markers = diags.map((d) => ({
21230
+ startLineNumber: d.line,
21231
+ startColumn: d.col || 1,
21232
+ endLineNumber: d.endLine || d.line,
21233
+ endColumn: d.endCol || (d.col || 1) + 20,
21234
+ message: d.message,
21235
+ severity: d.severity === "error" ? window.monaco.MarkerSeverity.Error : window.monaco.MarkerSeverity.Warning
21236
+ }));
21237
+ window.monaco.editor.setModelMarkers(model, "python-linter", markers);
21238
+ }
21239
+ }
21240
+ };
21242
21241
  if (options.preload) {
21243
21242
  toolchain.ensureLoaded().catch((err) => {
21244
21243
  if (typeof workbench._appendTerminalOutput === "function") {
@@ -21244,34 +21244,33 @@ finally:
21244
21244
  seedPythonModulesIntoVfs(workbench.vfs);
21245
21245
  }
21246
21246
  workbench.hasMultipleLanguages = workbench.enabledLanguages.size > 1;
21247
- if (workbench._diagnosticsStore) {
21248
- let pyLintTimer = null;
21249
- workbench._pyLintHandler = (file2, code) => {
21250
- if (!file2 || !file2.endsWith(".py")) return;
21251
- if (pyLintTimer) clearTimeout(pyLintTimer);
21252
- pyLintTimer = setTimeout(() => {
21253
- const diags = analyzePythonSource(code, file2);
21254
- workbench._diagnosticsStore.clear("python-linter");
21255
- for (const d of diags) {
21256
- workbench._diagnosticsStore.add(d);
21257
- }
21258
- if (typeof window !== "undefined" && window.monaco) {
21259
- const model = workbench.models && typeof workbench.models.get === "function" && workbench.models.get(file2) || (workbench.activeFile === file2 && workbench.editor ? workbench.editor.getModel() : null);
21260
- if (model) {
21261
- const markers = diags.map((d) => ({
21262
- startLineNumber: d.line,
21263
- startColumn: d.col || 1,
21264
- endLineNumber: d.line,
21265
- endColumn: (d.col || 1) + 20,
21266
- message: d.message,
21267
- severity: d.severity === "error" ? window.monaco.MarkerSeverity.Error : window.monaco.MarkerSeverity.Warning
21268
- }));
21269
- window.monaco.editor.setModelMarkers(model, "python-linter", markers);
21270
- }
21271
- }
21272
- }, 180);
21273
- };
21274
- }
21247
+ workbench._pyLintHandler = (file2, code) => {
21248
+ if (!file2 || !/\.py$/i.test(file2)) return;
21249
+ const diags = analyzePythonSource(String(code ?? ""), file2);
21250
+ const store = workbench ? workbench._diagnosticsStore : null;
21251
+ if (store && typeof store.setFileDiagnostics === "function") {
21252
+ store.setFileDiagnostics(file2, "python-linter", diags);
21253
+ } else if (store && typeof store.clear === "function" && typeof store.add === "function") {
21254
+ store.clear("python-linter");
21255
+ for (const d of diags) {
21256
+ store.add(d);
21257
+ }
21258
+ }
21259
+ if (typeof window !== "undefined" && window.monaco) {
21260
+ const model = workbench.models && typeof workbench.models.get === "function" && workbench.models.get(file2) || (workbench.activeFile === file2 && workbench.editor ? workbench.editor.getModel() : null);
21261
+ if (model) {
21262
+ const markers = diags.map((d) => ({
21263
+ startLineNumber: d.line,
21264
+ startColumn: d.col || 1,
21265
+ endLineNumber: d.endLine || d.line,
21266
+ endColumn: d.endCol || (d.col || 1) + 20,
21267
+ message: d.message,
21268
+ severity: d.severity === "error" ? window.monaco.MarkerSeverity.Error : window.monaco.MarkerSeverity.Warning
21269
+ }));
21270
+ window.monaco.editor.setModelMarkers(model, "python-linter", markers);
21271
+ }
21272
+ }
21273
+ };
21275
21274
  if (options.preload) {
21276
21275
  toolchain.ensureLoaded().catch((err) => {
21277
21276
  if (typeof workbench._appendTerminalOutput === "function") {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @innovatorved/code-lab v0.4.0
2
+ * @innovatorved/code-lab v0.5.0
3
3
  * Browser-native IDE, POSIX Shell, Web Worker Node.js/Bun Runtime, WASI C++20 Toolchain, Python 3.12 WebAssembly, and Git Engine.
4
4
  */
5
5
  export * from './schemas';
@@ -2,6 +2,7 @@ import { type Event, type IDisposable } from '@code-lab/core';
2
2
  import { type SettingDescriptor } from './builtin-schemas';
3
3
  import { type JsonSchema } from './schema';
4
4
  export type ConfigurationTarget = 'default' | 'user' | 'workspace' | 'override';
5
+ export type ConfigurationResetScope = 'user' | 'workspace' | 'all';
5
6
  export interface SettingDiagnostic {
6
7
  readonly file: string;
7
8
  readonly key?: string;
@@ -46,8 +47,11 @@ export interface IConfigurationService extends IDisposable {
46
47
  get<T = unknown>(key: string, fallback?: T): T;
47
48
  inspect<T = unknown>(key: string): SettingInspection<T>;
48
49
  getDiagnostics(): readonly SettingDiagnostic[];
50
+ getWorkspaceSettings(): Record<string, unknown>;
49
51
  setUserSetting(key: string, value: unknown): boolean;
50
52
  resetSetting(key: string): void;
53
+ resetScopedSetting(key: string, scope: ConfigurationResetScope): Promise<void>;
54
+ resetAllSettings(scope?: ConfigurationResetScope): Promise<void>;
51
55
  setWorkspaceSetting(key: string, value: unknown): boolean;
52
56
  loadWorkspaceSettingsJson(rawJsonc: string, filePath?: string): readonly SettingDiagnostic[];
53
57
  setOverrides(overrides: Readonly<Record<string, unknown>>): void;
@@ -79,6 +83,9 @@ export declare class ConfigurationService implements IConfigurationService {
79
83
  setUserSetting(key: string, value: unknown): boolean;
80
84
  setWorkspaceSetting(key: string, value: unknown): boolean;
81
85
  resetSetting(key: string): void;
86
+ getWorkspaceSettings(): Record<string, unknown>;
87
+ resetScopedSetting(key: string, scope: ConfigurationResetScope): Promise<void>;
88
+ resetAllSettings(scope?: ConfigurationResetScope): Promise<void>;
82
89
  loadWorkspaceSettingsJson(rawJsonc: string, filePath?: string): readonly SettingDiagnostic[];
83
90
  setOverrides(overrides: Readonly<Record<string, unknown>>): void;
84
91
  toWorkspaceJsonString(): string;
@@ -1,4 +1,4 @@
1
1
  export { type JsoncParseError, type JsoncParseResult, stripJsonCommentsAndTrailingCommas, parseJsonc } from './jsonc';
2
2
  export { type JsonSchemaType, type JsonSchema, type SchemaValidationIssue, validateJsonSchema } from './schema';
3
3
  export { type SettingCategory, type SettingDescriptor, BUILTIN_SETTINGS, buildSettingsJsonSchema, KEYBINDINGS_JSON_SCHEMA, TASKS_JSON_SCHEMA, EXTENSIONS_JSON_SCHEMA } from './builtin-schemas';
4
- export { type ConfigurationTarget, type SettingDiagnostic, type ConfigurationChangeEvent, type SettingInspection, type WorkspaceTaskDefinition, type WorkspaceExtensionsConfig, type IConfigurationService, IConfigurationServiceId, ConfigurationService, parseTasksConfig, parseExtensionsConfig } from './configuration-service';
4
+ export { type ConfigurationTarget, type ConfigurationResetScope, type SettingDiagnostic, type ConfigurationChangeEvent, type SettingInspection, type WorkspaceTaskDefinition, type WorkspaceExtensionsConfig, type IConfigurationService, IConfigurationServiceId, ConfigurationService, parseTasksConfig, parseExtensionsConfig } from './configuration-service';
@@ -1,4 +1,4 @@
1
- export { type ThemeKind, type ThemeDefinition, type IThemeService, DARK_THEME, LIGHT_THEME, HIGH_CONTRAST_THEME, IThemeServiceId, parseCustomTheme, ThemeService } from './themes';
1
+ export { type ThemeKind, type ThemeDefinition, type IThemeService, DARK_THEME, LIGHT_THEME, HIGH_CONTRAST_THEME, IThemeServiceId, pickContrastingFg, parseCustomTheme, ThemeService } from './themes';
2
2
  export { type PanelContribution, type LanguageContribution, type PluginContributions, type PluginActivationContext, type CodeLabPluginManifest, type RegisteredPluginInfo, type IPluginRegistry, IPluginRegistryId, PluginRegistry } from './plugin-registry';
3
- export { type SettingsDialogOptions, SettingsDialogController } from './settings-dialog';
3
+ export { type SettingsScope, type SettingsInlineMountOptions, type SettingsOpenOptions, type SettingsDialogOptions, SettingsDialogController } from './settings-dialog';
4
4
  export { type ObservabilitySnapshotInput, scoreFuzzyFileMatch, rankWorkspaceFiles, renderObservabilityPanelHtml, WorkbenchErrorBoundary } from './observability';
@@ -34,6 +34,7 @@ export interface PluginActivationContext {
34
34
  readonly keybindings: IKeybindingService;
35
35
  readonly themes: IThemeService;
36
36
  readonly logger: ILogger;
37
+ readonly registerPanel?: (panel: PanelContribution) => IDisposable;
37
38
  }
38
39
  export interface CodeLabPluginManifest {
39
40
  readonly id: string;
@@ -1,23 +1,51 @@
1
1
  import { type IDisposable } from '@code-lab/core';
2
2
  import type { IConfigurationService } from '@code-lab/settings';
3
+ export type SettingsScope = 'user' | 'workspace';
4
+ export interface SettingsInlineMountOptions {
5
+ readonly scope?: SettingsScope;
6
+ readonly onOpenJson?: () => void;
7
+ readonly onOpenSettingsJson?: () => void;
8
+ readonly onWorkspaceSettingsMutated?: (nextWorkspaceSettings: Record<string, unknown>) => void;
9
+ }
10
+ export type SettingsOpenOptions = SettingsInlineMountOptions;
3
11
  export interface SettingsDialogOptions {
4
12
  readonly configuration: IConfigurationService;
13
+ readonly scope?: SettingsScope;
5
14
  readonly onOpenSettingsJson?: () => void;
15
+ readonly onOpenJson?: () => void;
6
16
  readonly onExportSettings?: (json: string) => void;
7
17
  readonly onImportSettings?: () => void;
18
+ readonly onWorkspaceSettingsMutated?: (nextWorkspaceSettings: Record<string, unknown>) => void;
8
19
  }
9
20
  export declare class SettingsDialogController implements IDisposable {
10
- private readonly disposables;
21
+ private readonly dialogDisposables;
22
+ private readonly inlineDisposables;
11
23
  private readonly config;
12
24
  private readonly options;
25
+ private hostRoot;
13
26
  private dialogEl;
27
+ private inlineRootEl;
28
+ private runtimeCallbacks;
29
+ private inlineCallbacks;
30
+ private activeScope;
14
31
  private activeCategory;
15
32
  private searchQuery;
16
33
  constructor(hostRoot: HTMLElement, options: SettingsDialogOptions);
17
- private mount;
34
+ constructor(options: SettingsDialogOptions);
35
+ private buildSurfaceInnerHtml;
36
+ private getWorkspaceSnapshot;
37
+ private notifyWorkspaceMutated;
38
+ private invokeOpenJsonCallback;
39
+ private bindSurfaceEvents;
40
+ private mountDialog;
18
41
  get isOpen(): boolean;
19
- open(): void;
42
+ get isInlineMounted(): boolean;
43
+ open(options?: SettingsOpenOptions): void;
20
44
  close(): void;
45
+ mountInline(container: HTMLElement, options?: SettingsInlineMountOptions): void;
46
+ unmountInline(): void;
47
+ private renderAllActiveSurfaces;
48
+ private renderScopes;
21
49
  private renderCategories;
22
50
  private renderControl;
23
51
  private renderItems;
@@ -10,6 +10,11 @@ export interface ThemeDefinition {
10
10
  export declare const DARK_THEME: ThemeDefinition;
11
11
  export declare const LIGHT_THEME: ThemeDefinition;
12
12
  export declare const HIGH_CONTRAST_THEME: ThemeDefinition;
13
+ /**
14
+ * Picks `'#ffffff'` or `'#000000'` to maximize WCAG 2.1 contrast (>= 4.58:1)
15
+ * against a solid hex/rgb background color, returning `fallback` for dynamic CSS expressions.
16
+ */
17
+ export declare function pickContrastingFg(color: string, fallback?: string): string;
13
18
  export declare function parseCustomTheme(rawJsonc: string): ThemeDefinition;
14
19
  export interface IThemeService extends IDisposable {
15
20
  readonly activeTheme: ThemeDefinition;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.4.0 — Standalone Browser Code IDE & Virtual Runtime
3
+ * @innovatorved/code-lab v0.5.0 — Standalone Browser Code IDE & Virtual Runtime
4
4
  * ============================================================
5
5
  * Features:
6
6
  * - Sandboxed Web Worker Execution Engine with Multi-Instance Isolation & Watchdog Timer
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.4.0 — Standalone Browser Code IDE & Virtual Runtime
3
+ * @innovatorved/code-lab v0.5.0 — Standalone Browser Code IDE & Virtual Runtime
4
4
  * ============================================================
5
5
  * Features:
6
6
  * - Sandboxed Web Worker Execution Engine with Multi-Instance Isolation & Watchdog Timer
package/dist/runtime.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.4.0 — Standalone Browser Code IDE & Virtual Runtime
3
+ * @innovatorved/code-lab v0.5.0 — Standalone Browser Code IDE & Virtual Runtime
4
4
  * ============================================================
5
5
  * Features:
6
6
  * - Sandboxed Web Worker Execution Engine with Multi-Instance Isolation & Watchdog Timer
package/dist/schemas.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  /**
3
- * Zod Schemas and Inferred TypeScript Types for code-lab v0.4.0
3
+ * Zod Schemas and Inferred TypeScript Types for code-lab v0.5.0
4
4
  */
5
5
  export declare const GuidedStepSchema: z.ZodObject<{
6
6
  id: z.ZodString;
package/dist/scm.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * @innovatorved/code-lab — Interactive Git Source Control (SCM) Engine
3
3
  * ============================================================================
4
- * Pure TypeScript in-browser Git status, staging, unstaging, and commit engine
5
- * backed by workspace VFS state. Powers both the interactive Source Control UI
6
- * and shell/CLI Git operations.
4
+ * Pure TypeScript in-browser Git status, staging, unstaging, discard, and
5
+ * commit engine backed by workspace VFS state. Powers both the interactive
6
+ * Source Control UI and shell/CLI Git operations with a unified GitState schema.
7
7
  *
8
8
  * Strict leaf module: fully typed, zero explicit any, zero empty catches.
9
9
  */
@@ -15,20 +15,50 @@ export interface GitFileStatus {
15
15
  oldContent?: string;
16
16
  newContent?: string;
17
17
  }
18
+ export interface GitVfsLike {
19
+ existsSync?(path: string): boolean;
20
+ statSync?(path: string): {
21
+ isDirectory(): boolean;
22
+ };
23
+ readdirSync?(path: string): string[];
24
+ readFileSync?(path: string, encoding?: string): string | Uint8Array;
25
+ writeFileSync?(path: string, data: string): void;
26
+ mkdirSync?(path: string, options?: {
27
+ recursive?: boolean;
28
+ }): unknown;
29
+ unlinkSync?(path: string): void;
30
+ rmSync?(path: string, options?: {
31
+ recursive?: boolean;
32
+ force?: boolean;
33
+ }): void;
34
+ files?: Map<string, unknown>;
35
+ }
36
+ export interface GitShellLike {
37
+ cwd?: string;
38
+ vfs?: GitVfsLike | null;
39
+ gitState?: GitState | null;
40
+ _emitVfsMutation?(type: string, absPath: string): void;
41
+ }
18
42
  export interface GitCommitRecord {
19
43
  hash: string;
20
44
  message: string;
21
45
  timestamp: number;
22
46
  author?: string;
23
- files: Record<string, string>;
47
+ date?: string;
48
+ files?: Record<string, string>;
24
49
  }
25
50
  export interface GitState {
51
+ initialized?: boolean;
52
+ repoRoot?: string;
26
53
  branch: string;
27
- branches?: string[];
54
+ branches?: string[] | Set<string>;
55
+ remoteUrl?: string | null;
56
+ remotes?: Record<string, string>;
28
57
  headCommit: string;
29
58
  headFiles: Record<string, string>;
30
59
  headSnapshot?: Record<string, string>;
31
60
  staged: Map<string, string | null> | Set<string>;
61
+ stagedFiles?: Map<string, string | null>;
32
62
  commits: GitCommitRecord[];
33
63
  }
34
64
  export interface GitStatusEntry {
@@ -50,14 +80,40 @@ export interface GitStatusResult {
50
80
  hasChanges: boolean;
51
81
  isClean: boolean;
52
82
  }
83
+ export interface CreateGitStateOptions {
84
+ initialized?: boolean;
85
+ repoRoot?: string;
86
+ }
87
+ export interface InitRepositoryOptions {
88
+ branch?: string;
89
+ repoRoot?: string;
90
+ snapshotExisting?: boolean;
91
+ initialFiles?: Record<string, string>;
92
+ }
53
93
  /**
54
94
  * Computes a deterministic 7-character short hash for a commit payload.
55
95
  */
56
96
  export declare function computeShortCommitHash(input: string): string;
97
+ export declare function isIgnoredScmPath(relPath: string): boolean;
98
+ export declare function normalizeScmRelPath(rawPath: string, repoRoot?: string): string;
99
+ export declare function isUnbornGitHead(gitState: GitState | null | undefined): boolean;
100
+ export declare function isEffectiveStagedChange(gitState: GitState | null | undefined, relPath: string, stagedVal: string | null | undefined, resolvedHeadFiles?: Record<string, string>): boolean;
101
+ /**
102
+ * Synchronizes `gitState.headFiles` and `gitState.headSnapshot` so both
103
+ * properties reference the exact same clean `Record<string, string>` object.
104
+ */
105
+ export declare function syncGitHead(gitState: GitState, nextHead?: Record<string, string>): Record<string, string>;
106
+ /**
107
+ * Initializes an in-memory Git repository state from initial VFS files,
108
+ * keeping `headFiles` / `headSnapshot` and `staged` / `stagedFiles` synchronized.
109
+ */
110
+ export declare function createGitState(initialFiles?: Record<string, string>, branch?: string, options?: CreateGitStateOptions): GitState;
57
111
  /**
58
- * Initializes a fresh in-memory Git repository state from initial VFS files.
112
+ * Initializes a Git repository on a `PosixShell` (writing `.git/HEAD` & `.git/config`)
113
+ * or directly on a `GitState` object. Defaults `snapshotExisting` to `false` so
114
+ * existing workspace files appear as untracked until staged and committed.
59
115
  */
60
- export declare function createGitState(initialFiles?: Record<string, string>, branch?: string): GitState;
116
+ export declare function initRepository(target: GitShellLike | GitState, options?: InitRepositoryOptions): GitState;
61
117
  /**
62
118
  * Computes working-tree and staging-area Git status against `gitState`.
63
119
  * Supports both `computeGitStatus(vfsFiles, repoRoot, gitState)` and
@@ -68,21 +124,46 @@ export declare function computeGitStatus(arg1: Record<string, string> | GitState
68
124
  * Stages a file addition, modification, or deletion (`currentContent === null`).
69
125
  */
70
126
  export declare function stageFile(gitState: GitState, relativePath: string, currentContent: string | null): void;
127
+ /**
128
+ * Stages all modified, untracked (non-ignored), and deleted tracked files.
129
+ */
130
+ export declare function stageAll(gitState: GitState, vfsFiles: Record<string, string>, repoRoot?: string): void;
71
131
  /**
72
132
  * Removes a file from the staging index.
73
133
  */
74
134
  export declare function unstageFile(gitState: GitState, relativePath: string): void;
75
135
  /**
76
- * Commits all staged changes to `gitState`, advancing `headCommit` and `headFiles`,
77
- * and clearing the staging area. Throws if message is empty or staging area is empty.
136
+ * Clears all staged entries from `gitState`.
137
+ */
138
+ export declare function unstageAll(gitState: GitState): void;
139
+ /**
140
+ * Commits all staged changes to `gitState`, advancing `headCommit` and
141
+ * synchronizing `headFiles` & `headSnapshot`, prepending the new commit record,
142
+ * and clearing the staging area. Throws if message or staging area is empty.
78
143
  */
79
- export declare function commitChanges(gitState: GitState, message: string): string;
144
+ export declare function commitChanges(gitState: GitState, message: string, author?: string): string;
145
+ /**
146
+ * Discards working-tree (and staged) changes for `filePath`:
147
+ * - If tracked in `HEAD`, restores `headFiles[relPath]` to `shell.vfs` (creating
148
+ * parent directories first) and optional `workspaceFiles`.
149
+ * - If untracked, deletes the file from `shell.vfs` and optional `workspaceFiles`.
150
+ */
151
+ export declare function discardChanges(shell: GitShellLike, filePath: string, workspaceFiles?: Record<string, string>): boolean;
80
152
  declare const _default: {
153
+ computeShortCommitHash: typeof computeShortCommitHash;
154
+ isIgnoredScmPath: typeof isIgnoredScmPath;
155
+ normalizeScmRelPath: typeof normalizeScmRelPath;
156
+ isUnbornGitHead: typeof isUnbornGitHead;
157
+ isEffectiveStagedChange: typeof isEffectiveStagedChange;
158
+ syncGitHead: typeof syncGitHead;
81
159
  createGitState: typeof createGitState;
160
+ initRepository: typeof initRepository;
82
161
  computeGitStatus: typeof computeGitStatus;
83
162
  stageFile: typeof stageFile;
163
+ stageAll: typeof stageAll;
84
164
  unstageFile: typeof unstageFile;
165
+ unstageAll: typeof unstageAll;
85
166
  commitChanges: typeof commitChanges;
86
- computeShortCommitHash: typeof computeShortCommitHash;
167
+ discardChanges: typeof discardChanges;
87
168
  };
88
169
  export default _default;