@mdfriday/foundry
Version:
The core engine of MDFriday. Convert Markdown and shortcodes into fully themed static sites – Hugo-style, powered by TypeScript.
49 lines • 2.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createModules = createModules;
exports.createModulesWithProgress = createModulesWithProgress;
const module_1 = require("../entity/module");
const type_1 = require("../type");
const httpclient_1 = require("../vo/httpclient");
const zipextractor_1 = require("../vo/zipextractor");
const cache_1 = require("../vo/cache");
const log_1 = require("../../../../pkg/log");
// Create domain-specific logger for module factory
const log = (0, log_1.getDomainLogger)('module', { component: 'factory' });
/**
* Factory function to create a complete Modules instance with default dependencies
*/
async function createModules(info) {
try {
const httpClient = (0, httpclient_1.newHttpClient)(info.osFs());
const zipExtractor = (0, zipextractor_1.newZipExtractor)(info.osFs());
const moduleCache = (0, cache_1.newModuleCache)(info.osFs(), info.moduleCacheDir());
const modules = (0, module_1.newModules)(info, httpClient, zipExtractor, moduleCache);
await modules.load();
return modules;
}
catch (error) {
const message = error instanceof Error ? error.message : String(error);
log.error(`Failed to create modules: ${message}`);
throw new type_1.ModuleError(`Failed to create modules: ${message}`, 'FACTORY_FAILED');
}
}
/**
* Factory function to create a complete Modules instance with progress tracking
*/
async function createModulesWithProgress(info, onProgress) {
try {
const httpClient = (0, httpclient_1.newHttpClient)(info.osFs());
const zipExtractor = (0, zipextractor_1.newZipExtractor)(info.osFs());
const moduleCache = (0, cache_1.newModuleCache)(info.osFs(), info.moduleCacheDir());
const modules = (0, module_1.newModules)(info, httpClient, zipExtractor, moduleCache);
await modules.load(onProgress);
return modules;
}
catch (error) {
const message = error instanceof Error ? error.message : String(error);
log.error(`Failed to create modules: ${message}`);
throw new type_1.ModuleError(`Failed to create modules: ${message}`, 'FACTORY_FAILED');
}
}
//# sourceMappingURL=module.js.map