UNPKG

kt-extendscript-builder

Version:

Vite based builder for transpile TypeScript to ExtendScript

51 lines (50 loc) 1.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OptionsPresetsResolver = void 0; const optionsPresets_1 = require("./optionsPresets"); const ConfigLoader_1 = require("../config/ConfigLoader"); /** * Class responsible for resolving preset build options. * * This class maintains a collection of named preset configurations that can be * applied to build options. Each preset is a partial specification of BuildOptions * that can be retrieved by name. */ class OptionsPresetsResolver { /** * Initializes a new instance of the OptionsPresetsResolver class * with predefined presets. */ constructor() { /** * Map of preset names to their corresponding partial build options */ this.presets = {}; this.presets = optionsPresets_1.presets; } /** * Retrieves a preset by name * * @param presetName - The name of the preset to retrieve * @returns The partial build options corresponding to the requested preset * @throws Error if the specified preset name is not found */ resolvePreset(presetName) { const preset = this.presets[presetName]; if (!preset) { return this.presets['default']; } return preset; } getUserPresets(userConfigPath) { const loader = new ConfigLoader_1.ConfigLoader(); const userPresets = loader.load(userConfigPath); for (const [key, value] of Object.entries(userPresets)) { const preset = value; if (preset && !this.presets[key]) { this.presets[key] = preset; } } } } exports.OptionsPresetsResolver = OptionsPresetsResolver;