Introduces kernel/services.js (window.LP.services): an additive, typed,
LAZY view onto the existing cross-cutting singletons — tasks{bus,refresh,
route}, live, auth, data, notify, theme, modal, router. It constructs
nothing (pure getters onto the live globals), so there's no double-init and
the globals stay authoritative. MountContext now injects it as ctx.services.
Slot names/globals were verified against the real code (workflow map): the
design doc's §4 list was wrong in several places — no window.taskManager
(client slot dropped), tasks.route lives on tasksManager.router, auth has no
status(), DataLoader isn't a window prop (lexical fallback), modal/router are
split surfaces (grouped/bound objects).
Migrated the 4 cross-cutting refs in the feature modules onto ctx.services
(admin: router.adminCategoryFromPath + tasks.refresh; backup: tasks.refresh;
app-detail: router.appPath). Page-owned controllers stay feature-globals.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: librelad <librelad@digitalangels.vip>
59 lines
2.5 KiB
JavaScript
59 lines
2.5 KiB
JavaScript
// features/app-detail/index.js — the per-app detail page (/app/<name>[/<tab>]).
|
|
//
|
|
// Shares the apps-unified-layout fragment with the App Center grid but renders
|
|
// via window.appTabbedManager (a system-loader singleton; call .initialize(),
|
|
// never `new`). Registered AFTER the apps feature so '/apps*' wins the wildcard
|
|
// match and only true /app* paths land here. mount() mirrors handleAppDetail
|
|
// exactly, including the legacy ?app= / ?=name parsing and the ?tab=/?config=
|
|
// → path rewrite. unmount() is a no-op for now (the singleton is shared); the
|
|
// known unguarded popstate/task-listener re-bind in app-tabbed-manager is
|
|
// addressed in a follow-up (it predates this migration).
|
|
LP.features.register({
|
|
id: 'app-detail',
|
|
routes: ['/app', '/app*'],
|
|
|
|
async mount(ctx) {
|
|
const url = new URL(window.location);
|
|
let appName = url.pathname.replace(/^\/app\/?/, '').split('/')[0];
|
|
appName = appName ? decodeURIComponent(appName) : '';
|
|
if (!appName) appName = url.searchParams.get('app');
|
|
|
|
// Old format ?=appname&tab=tabname
|
|
if (!appName && url.search.includes('?=')) {
|
|
const queryPart = url.search.replace('?', '');
|
|
for (const part of queryPart.split('&')) {
|
|
if (part.startsWith('=')) { appName = part.substring(1); break; }
|
|
}
|
|
}
|
|
|
|
if (!appName) { return ctx.nav('/apps', false); }
|
|
|
|
// Back-compat: rewrite legacy ?tab=/?config= to the canonical path shape
|
|
// before the page reads URL state (replaceState — no extra history entry).
|
|
const legacyTab = url.searchParams.get('tab');
|
|
const legacyConfig = url.searchParams.get('config');
|
|
if (legacyTab || legacyConfig) {
|
|
const tab = legacyTab === 'logs' ? 'tasks' : (legacyTab || 'config');
|
|
const sub = (tab === 'config') ? legacyConfig : null;
|
|
const taskId = url.searchParams.get('task');
|
|
const canonical = ctx.services.router.appPath(appName, tab, sub, taskId);
|
|
if (canonical !== url.pathname + url.search) {
|
|
window.history.replaceState({ route: canonical }, '', canonical);
|
|
}
|
|
}
|
|
|
|
const html = await ctx.loadFragment('/html/apps-unified-layout.html');
|
|
ctx.setContent(html, appName);
|
|
|
|
if (!window.appTabbedManager) {
|
|
throw new Error('AppTabbedManager not initialized by SystemLoader');
|
|
}
|
|
await window.appTabbedManager.initialize();
|
|
},
|
|
|
|
async unmount() {
|
|
// No-op: AppTabbedManager is a shared system-loader singleton. Its
|
|
// listener-rebind leak is pre-existing and fixed separately.
|
|
},
|
|
});
|