From 26ed170932696cf9019ee46fec79d76c43ed5c25 Mon Sep 17 00:00:00 2001 From: znetsixe <73483679+znetsixe@users.noreply.github.com> Date: Tue, 10 Jun 2025 12:45:35 +0200 Subject: [PATCH] update --- index.js | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/index.js b/index.js index 9e2c039..ac75563 100644 --- a/index.js +++ b/index.js @@ -6,28 +6,27 @@ */ // Core helper modules -export * as menuUtils from './src/helper/menuUtils.js'; -export * as logger from './src/helper/logger.js'; -export * as validation from './src/helper/validationUtils.js'; +const menuUtils = require('./src/helper/menuUtils.js'); +const logger = require('./src/helper/logger.js'); +const validation = require('./src/helper/validationUtils.js'); // Domain-specific modules -export * as measurements from './src/measurements/index.js'; -export * as nrmse from './src/nrmse/index.js'; -export * as state from './src/state/index.js'; +const measurements = require('./src/measurements/index.js'); +const nrmse = require('./src/nrmse/index.js'); +const state = require('./src/state/index.js'); // Configuration loader with error handling -async function loadConfig(path) { +function loadConfig(path) { try { - const module = await import(path, { assert: { type: 'json' } }); - return module.default; + return require(path); } catch (error) { console.warn(`Failed to load config: ${path}`, error); return null; } } -// Lazy-loaded configurations -export const configs = { +// Configurations +const configs = { get projectSettings() { return loadConfig('./configs/projectSettings.json'); }, @@ -37,24 +36,35 @@ export const configs = { }; // Dynamic loaders with validation -export async function loadHelper(name) { +function loadHelper(name) { if (!name || typeof name !== 'string') { throw new Error('Helper name must be a non-empty string'); } try { - return await import(`./src/helper/${name}.js`); + return require(`./src/helper/${name}.js`); } catch (error) { throw new Error(`Failed to load helper "${name}": ${error.message}`); } } -export async function loadAssetDatasets() { +function loadAssetDatasets() { try { - return await import('./datasets/assetData/suppliers.json', { - assert: { type: 'json' } - }); + return require('./datasets/assetData/suppliers.json'); } catch (error) { throw new Error(`Failed to load asset datasets: ${error.message}`); } } + +// Export everything +module.exports = { + menuUtils, + logger, + validation, + measurements, + nrmse, + state, + configs, + loadHelper, + loadAssetDatasets +}; \ No newline at end of file