vde-layout
Version:
Terminal multiplexer layout management tool for VDE (Vibe Coding Development Environment)
55 lines • 1.99 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PresetManager = void 0;
const loader_1 = require("../config/loader");
const validator_1 = require("../config/validator");
const errors_1 = require("../utils/errors");
class PresetManager {
config = null;
configLoaderOptions;
constructor(options = {}) {
this.configLoaderOptions = options;
}
async loadConfig() {
const loader = new loader_1.ConfigLoader(this.configLoaderOptions);
const yamlContent = await loader.loadYAML();
this.config = (0, validator_1.validateYAML)(yamlContent);
}
getPreset(name) {
if (!this.config) {
throw new errors_1.ConfigError("Configuration not loaded", errors_1.ErrorCodes.CONFIG_NOT_FOUND);
}
const preset = this.config.presets[name];
if (!preset) {
throw new errors_1.ConfigError(`Preset "${name}" not found`, errors_1.ErrorCodes.PRESET_NOT_FOUND, {
availablePresets: Object.keys(this.config.presets),
});
}
return preset;
}
listPresets() {
if (!this.config) {
return [];
}
return Object.entries(this.config.presets).map(([key, preset]) => ({
key,
name: preset.name,
description: preset.description,
}));
}
getDefaultPreset() {
if (!this.config) {
throw new errors_1.ConfigError("Configuration not loaded", errors_1.ErrorCodes.CONFIG_NOT_FOUND);
}
if (this.config.presets.default) {
return this.config.presets.default;
}
const firstKey = Object.keys(this.config.presets)[0];
if (firstKey === undefined) {
throw new errors_1.ConfigError("No presets defined", errors_1.ErrorCodes.PRESET_NOT_FOUND);
}
return this.config.presets[firstKey];
}
}
exports.PresetManager = PresetManager;
//# sourceMappingURL=preset.js.map