Compare commits
No commits in common. "6ae85d8dd2157cd30d10c9fe8f6e8481a586f43e" and "76138ddcdd701d018e9311dcca7046ee42521d1a" have entirely different histories.
6ae85d8dd2
...
76138ddcdd
@ -13,8 +13,8 @@ class LibrePortalSPAClean {
|
|||||||
async init() {
|
async init() {
|
||||||
//console.log('🚀 Clean SPA: Initializing...');
|
//console.log('🚀 Clean SPA: Initializing...');
|
||||||
|
|
||||||
// Setup routes from the feature manifest (falls back to the built-in table)
|
// Setup routes immediately
|
||||||
await this.setupRoutesFromManifest();
|
this.setupRoutes();
|
||||||
|
|
||||||
// Wait for DOM to be ready
|
// Wait for DOM to be ready
|
||||||
if (document.readyState === 'loading') {
|
if (document.readyState === 'loading') {
|
||||||
@ -85,47 +85,6 @@ class LibrePortalSPAClean {
|
|||||||
//console.log('📍 Routes registered:', Array.from(this.routes.keys()));
|
//console.log('📍 Routes registered:', Array.from(this.routes.keys()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the route table from the feature manifest (window.LP.features) so
|
|
||||||
// "what pages exist" lives in one declarative place (features/manifest.dev.json)
|
|
||||||
// instead of being hardcoded here. Route insertion order is preserved from the
|
|
||||||
// manifest, which keeps the wildcard precedence findRouteHandler() relies on
|
|
||||||
// (e.g. '/apps*' must be inserted before '/app*'). Falls back to the built-in
|
|
||||||
// setupRoutes() table if the manifest is missing, empty, or names a handler
|
|
||||||
// this class doesn't define — routing must never be left half-wired.
|
|
||||||
async setupRoutesFromManifest() {
|
|
||||||
try {
|
|
||||||
const manifest = (window.LP && window.LP.features)
|
|
||||||
? await window.LP.features.loadManifest()
|
|
||||||
: null;
|
|
||||||
const entries = manifest && manifest.features;
|
|
||||||
if (!entries || !entries.length) {
|
|
||||||
this.setupRoutes();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// All-or-nothing: a single missing handler means we don't trust the
|
|
||||||
// manifest enough to route from it — use the known-good built-in table.
|
|
||||||
for (const f of entries) {
|
|
||||||
if (typeof this[f.handler] !== 'function') {
|
|
||||||
console.warn(`[spa] manifest handler "${f.handler}" (feature "${f.id}") not found — using built-in routes`);
|
|
||||||
this.setupRoutes();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.routes.clear();
|
|
||||||
for (const f of entries) {
|
|
||||||
const handler = () => this[f.handler]();
|
|
||||||
for (const route of (f.routes || [])) {
|
|
||||||
this.routes.set(route, handler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this._routesFromManifest = true;
|
|
||||||
//console.log('📍 Routes registered from manifest:', Array.from(this.routes.keys()));
|
|
||||||
} catch (err) {
|
|
||||||
console.error('[spa] manifest routing failed, using built-in routes:', err);
|
|
||||||
this.setupRoutes();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async loadCoreData() {
|
async loadCoreData() {
|
||||||
//console.log('📊 Loading core data...');
|
//console.log('📊 Loading core data...');
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user