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.rel = 'stylesheet';
|
||||||
link.href = cssPath;
|
link.href = cssPath;
|
||||||
link.onload = () => {
|
link.onload = () => {
|
||||||
console.log(`Module Loader - Loaded CSS for ${moduleHandle}: ${cssFile}`);
|
console.log(`[Core][Module Loader] - Loaded CSS for ${moduleHandle}: ${cssFile}`);
|
||||||
};
|
};
|
||||||
link.onerror = () => {
|
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);
|
document.head.appendChild(link);
|
||||||
}
|
}
|
||||||
@@ -73,47 +73,48 @@ export async function initializeModules(app: App): Promise<void> {
|
|||||||
|
|
||||||
for (const [moduleId, moduleInfo] of Object.entries(availableModules)) {
|
for (const [moduleId, moduleInfo] of Object.entries(availableModules)) {
|
||||||
if (!moduleInfo) {
|
if (!moduleInfo) {
|
||||||
console.warn(`Module ${moduleId} has no configuration, skipping`);
|
console.warn(`[Core][Module Loader] - Module ${moduleId} has no configuration, skipping`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (moduleInfo.handle && moduleInfo.boot && !moduleInfo.booted) {
|
if (moduleInfo.handle && moduleInfo.boot && !moduleInfo.booted) {
|
||||||
const moduleHandle = moduleInfo.handle;
|
const moduleHandle = moduleInfo.handle;
|
||||||
const moduleUrl = `/modules/${moduleInfo.handle}/${moduleInfo.boot}`;
|
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)
|
const loadPromise = import(/* @vite-ignore */ moduleUrl)
|
||||||
.then(async (module) => {
|
.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)
|
// Load CSS if module explicitly exports css path(s)
|
||||||
if (module.css) {
|
if (module.css) {
|
||||||
|
console.log(`[Core][Module Loader] - Installing CSS ${moduleInfo.handle}`);
|
||||||
installModuleCSS(moduleInfo.handle, module.css);
|
installModuleCSS(moduleInfo.handle, module.css);
|
||||||
}
|
}
|
||||||
// Load translation catalogs if module explicitly exports l10n flag
|
// Load translation catalogs if module explicitly exports l10n flag
|
||||||
if (module.l10n) {
|
if (module.l10n) {
|
||||||
console.log(`Module Loader - Installing Catalogs ${moduleInfo.handle}`);
|
console.log(`[Core][Module Loader] - Installing Localizations ${moduleInfo.handle}`);
|
||||||
await installModuleLocalizations(moduleHandle);
|
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) => {
|
.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);
|
loadPromises.push(loadPromise);
|
||||||
} else if (!moduleInfo.boot) {
|
} 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