refactor: console messages
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
+23
-22
@@ -15,10 +15,10 @@ function installModuleCSS(moduleHandle: string, cssPaths: string | string[]): vo
|
||||
link.rel = 'stylesheet';
|
||||
link.href = cssPath;
|
||||
link.onload = () => {
|
||||
console.log(`Module Loader - Loaded CSS for ${moduleHandle}: ${cssFile}`);
|
||||
console.log(`[Core][Module Loader] - Loaded CSS for ${moduleHandle}: ${cssFile}`);
|
||||
};
|
||||
link.onerror = () => {
|
||||
console.error(`Module Loader - Failed to load CSS for ${moduleHandle}: ${cssPath}`);
|
||||
console.error(`[Core][Module Loader] - Failed to load CSS for ${moduleHandle}: ${cssPath}`);
|
||||
};
|
||||
document.head.appendChild(link);
|
||||
}
|
||||
@@ -73,47 +73,48 @@ export async function initializeModules(app: App): Promise<void> {
|
||||
|
||||
for (const [moduleId, moduleInfo] of Object.entries(availableModules)) {
|
||||
if (!moduleInfo) {
|
||||
console.warn(`Module ${moduleId} has no configuration, skipping`);
|
||||
console.warn(`[Core][Module Loader] - Module ${moduleId} has no configuration, skipping`);
|
||||
continue;
|
||||
}
|
||||
if (moduleInfo.handle && moduleInfo.boot && !moduleInfo.booted) {
|
||||
const moduleHandle = moduleInfo.handle;
|
||||
const moduleUrl = `/modules/${moduleInfo.handle}/${moduleInfo.boot}`;
|
||||
console.log(`Module Loader - Loading ${moduleInfo.handle} from ${moduleUrl}`);
|
||||
console.log(`[Core][Module Loader] - Loading ${moduleInfo.handle} from ${moduleUrl}`);
|
||||
|
||||
const loadPromise = import(/* @vite-ignore */ moduleUrl)
|
||||
.then(async (module) => {
|
||||
// install module
|
||||
if (module.default && typeof module.default.install === 'function') {
|
||||
console.log(`[Core][Module Loader] - Installing ${moduleInfo.handle}`);
|
||||
app.use(module.default);
|
||||
}
|
||||
// prefix routes with /m/{moduleHandle}
|
||||
if (module.routes) {
|
||||
console.log(`[Core][Module Loader] - Installing Routes ${moduleInfo.handle}`);
|
||||
installModuleRoutes(moduleHandle, module.routes);
|
||||
}
|
||||
// register integrations
|
||||
if (module.integrations) {
|
||||
console.log(`[Core][Module Loader] - Installing Integrations ${moduleInfo.handle}`);
|
||||
installModuleIntegrations(moduleHandle, module.integrations);
|
||||
}
|
||||
// Load CSS if module explicitly exports css path(s)
|
||||
if (module.css) {
|
||||
console.log(`[Core][Module Loader] - Installing CSS ${moduleInfo.handle}`);
|
||||
installModuleCSS(moduleInfo.handle, module.css);
|
||||
}
|
||||
// Load translation catalogs if module explicitly exports l10n flag
|
||||
if (module.l10n) {
|
||||
console.log(`Module Loader - Installing Catalogs ${moduleInfo.handle}`);
|
||||
console.log(`[Core][Module Loader] - Installing Localizations ${moduleInfo.handle}`);
|
||||
await installModuleLocalizations(moduleHandle);
|
||||
}
|
||||
// install module
|
||||
console.log(`Module Loader - Installing ${moduleInfo.handle}`);
|
||||
if (module.default && typeof module.default.install === 'function') {
|
||||
app.use(module.default);
|
||||
}
|
||||
// prefix routes with /m/{moduleHandle}
|
||||
console.log(`Module Loader - Installing Routes ${moduleInfo.handle}`);
|
||||
if (module.routes) {
|
||||
installModuleRoutes(moduleHandle, module.routes);
|
||||
}
|
||||
// register integrations
|
||||
console.log(`Module Loader - Installing Integrations ${moduleInfo.handle}`);
|
||||
if (module.integrations) {
|
||||
installModuleIntegrations(moduleHandle, module.integrations);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(`Failed to load module ${moduleId} from ${moduleUrl}:`, error);
|
||||
console.error(`[Core][Module Loader] - Failed to load module ${moduleId} from ${moduleUrl}:`, error);
|
||||
});
|
||||
loadPromises.push(loadPromise);
|
||||
} else if (!moduleInfo.boot) {
|
||||
console.warn(`No boot path specified for module: ${moduleId}`);
|
||||
console.warn(`[Core][Module Loader] - No boot path specified for module: ${moduleId}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user