Final modularization layout (user-chosen): every page is a self-contained folder under components/<id>/ (controllers + CSS + its html fragment), and all shared/framework code folds into core/: core/kernel (feature-registry, lifecycle, services, spa) core/boot (auth, system-loader/orchestrator, setup, loaders) core/lib (data-loader, router, helpers, the task kernel, shared modules) core/ui (topbar, modal, notifications, … + topbar.html) core/css (all shared stylesheets) core/icons Top level is now just: components/, core/, themes/, index.html (+ runtime data/). Every path reference rewritten (index.html, scripts arrays, fetch()/ loadFragment()/loadScript() literals, system-loader + config-manager controller paths, kernel manifest URL, feature.json, backend FEATURES_DIR). The /api/features/list endpoint NAME is unchanged (it now scans components/). Deleted 3 dead files (app-content.html, apps-content.html, html-cache.js). Verified: 0 stale prefixes, 0 double-rewrites, all JS/JSON valid. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: librelad <librelad@digitalangels.vip>
47 lines
1.9 KiB
JavaScript
47 lines
1.9 KiB
JavaScript
// features/apps/index.js — the App Center grid (/apps, /apps/<category>).
|
|
//
|
|
// window.appsManager is a system-loader singleton (created by
|
|
// initializeComponents); mount() calls .initialize(), never `new`. Routes
|
|
// '/apps' and '/apps*' are registered BEFORE the app-detail feature's '/app*'
|
|
// so findRouteHandler's longest-prefix wildcard match resolves /apps* here
|
|
// (the manifest order guarantees this). unmount() is a no-op: the singleton and
|
|
// its constructor-time taskRefresh registrations are shared with app-detail and
|
|
// the dashboard and must outlive this view.
|
|
LP.features.register({
|
|
id: 'apps',
|
|
routes: ['/apps', '/apps*'],
|
|
|
|
async mount(ctx) {
|
|
// Category from the path (/apps/<category>), else legacy ?=<cat> / ?apps=.
|
|
const seg = window.location.pathname.replace(/^\/apps\/?/, '').split('/')[0];
|
|
if (seg) {
|
|
window.appsCategory = decodeURIComponent(seg);
|
|
} else {
|
|
const search = window.location.search || '';
|
|
if (search.includes('?=')) {
|
|
window.appsCategory = (window.location.pathname + search).split('?=')[1] || 'all';
|
|
} else {
|
|
window.appsCategory = new URLSearchParams(search).get('apps') || 'all';
|
|
}
|
|
}
|
|
|
|
// Load the unified layout only if it isn't already present — preserves grid
|
|
// state when moving between categories / back from app-detail (legacy behaviour).
|
|
if (!document.querySelector('.apps-layout')) {
|
|
const html = await ctx.loadFragment('/components/apps/apps-unified-layout.html');
|
|
ctx.setContent(html, 'Applications');
|
|
}
|
|
|
|
if (!window.appsManager) {
|
|
throw new Error('AppsManager not initialized by SystemLoader');
|
|
}
|
|
await window.appsManager.initialize();
|
|
},
|
|
|
|
async unmount() {
|
|
// Nothing to release — AppsManager is a shared system-loader singleton.
|
|
// The dirty-config nav guard (window.__appConfigNavGuard) fires in
|
|
// navigate() BEFORE unmount and is owned by AppsManager, so we leave it.
|
|
},
|
|
});
|