crapifyme
Version:
Ultra-fast developer productivity CLI tools - remove comments, logs, and more
56 lines • 2.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SVG_PRESETS = exports.DEFAULT_SVG_EXTENSIONS = void 0;
exports.isSupportedSvgExtension = isSupportedSvgExtension;
exports.getSvgPreset = getSvgPreset;
exports.createProcessingConfig = createProcessingConfig;
exports.DEFAULT_SVG_EXTENSIONS = ['svg'];
exports.SVG_PRESETS = {
minimal: {
name: 'minimal',
description: 'Light optimization, preserves most attributes and structure',
plugins: ['preset-default']
},
balanced: {
name: 'balanced',
description: 'Balanced optimization with good compression while maintaining usability',
plugins: ['preset-default'],
multipass: true,
precision: 2
},
aggressive: {
name: 'aggressive',
description: 'Maximum compression with potential loss of some functionality',
plugins: ['preset-default'],
multipass: true,
precision: 1
}
};
function isSupportedSvgExtension(ext) {
return exports.DEFAULT_SVG_EXTENSIONS.includes(ext.toLowerCase());
}
function getSvgPreset(name) {
const preset = exports.SVG_PRESETS[name];
if (!preset) {
throw new Error(`Unknown preset: ${name}. Available presets: ${Object.keys(exports.SVG_PRESETS).join(', ')}`);
}
return preset;
}
function createProcessingConfig(options) {
const preset = getSvgPreset(options.preset || 'balanced');
return {
preset,
customPlugins: options.plugins
? Array.isArray(options.plugins)
? options.plugins.map((p) => ({ name: p }))
: [{ name: options.plugins }]
: [],
precision: options.precision ?? preset.precision ?? 2,
multipass: options.multipass ?? preset.multipass ?? false,
keepIds: options.keepIds ?? false,
keepTitles: options.keepTitles ?? false,
validateInput: options.validateInput ?? true,
validateOutput: options.validateOutput ?? true
};
}
//# sourceMappingURL=types.js.map