Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
48 lines
1.7 KiB
JavaScript
48 lines
1.7 KiB
JavaScript
// Start of the interface: texts, icons, capabilities of the shell, theme, frame, events, router.
|
|
|
|
import { api, initCarried, setAccess } from './core/api.js';
|
|
import { caps, setCapabilities } from './core/context.js';
|
|
import { loadIcons, h, fill } from './core/dom.js';
|
|
import { startEvents } from './core/engine.js';
|
|
import { buildShell, startRouter } from './core/shell.js';
|
|
import { loadTexts, t } from './core/text.js';
|
|
import { initTheme } from './core/theme.js';
|
|
import { showProblems } from './pages/problems.js';
|
|
|
|
async function boot() {
|
|
initCarried();
|
|
const root = document.getElementById('app');
|
|
try {
|
|
await Promise.all([loadTexts(document.documentElement.lang || 'it'), loadIcons()]);
|
|
} catch {
|
|
fill(root, h('p', { style: { padding: '24px' } }, 'Febe non riesce a caricare i testi dell\'interfaccia. Ricarica la pagina.'));
|
|
return;
|
|
}
|
|
try {
|
|
const capabilities = await api('/api/capabilities');
|
|
setCapabilities(capabilities);
|
|
setAccess(capabilities.access);
|
|
if (capabilities.demo) document.documentElement.dataset.dimostrazione = '';
|
|
} catch {
|
|
// the defaults describe a plain browser
|
|
}
|
|
initTheme();
|
|
const problems = caps().problems || [];
|
|
if (problems.length) {
|
|
// Spec §8.2, §11: with a configuration problem the interface shows only the page that explains it.
|
|
showProblems(root, problems);
|
|
document.documentElement.removeAttribute('aria-busy');
|
|
return;
|
|
}
|
|
buildShell(root);
|
|
startEvents();
|
|
startRouter();
|
|
document.documentElement.removeAttribute('aria-busy');
|
|
window.addEventListener('unhandledrejection', (e) => {
|
|
if (e.reason && e.reason.name === 'AbortError') e.preventDefault();
|
|
});
|
|
void t;
|
|
}
|
|
|
|
boot();
|