mnfst 0.5.40 → 0.5.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/manifest.router.js +9 -0
- package/package.json +1 -1
package/dist/manifest.router.js
CHANGED
|
@@ -376,6 +376,10 @@ function initializeNavigation() {
|
|
|
376
376
|
handleRouteChange();
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
+
// Match the browser URL as soon as this module loads. Later chunks in the same bundle (e.g. router magic)
|
|
380
|
+
// may initialize before DOMContentLoaded; getCurrentRoute() must not stay at '/' or $route breaks article pages.
|
|
381
|
+
currentRoute = pathnameToLogical(window.location.pathname);
|
|
382
|
+
|
|
379
383
|
// Run immediately if DOM is ready, otherwise wait
|
|
380
384
|
if (document.readyState === 'loading') {
|
|
381
385
|
document.addEventListener('DOMContentLoaded', initializeNavigation);
|
|
@@ -1292,6 +1296,8 @@ function initializeRouterMagic() {
|
|
|
1292
1296
|
console.error('[Manifest Router Magic] Alpine is not available');
|
|
1293
1297
|
return;
|
|
1294
1298
|
}
|
|
1299
|
+
if (window.__manifestRouterMagicInitialized) return;
|
|
1300
|
+
window.__manifestRouterMagicInitialized = true;
|
|
1295
1301
|
|
|
1296
1302
|
// Create a reactive object for route data (use logical path when app is in a subpath)
|
|
1297
1303
|
const route = Alpine.reactive({
|
|
@@ -1336,6 +1342,9 @@ function initializeRouterMagic() {
|
|
|
1336
1342
|
window.addEventListener('manifest:route-change', updateRoute);
|
|
1337
1343
|
window.addEventListener('popstate', updateRoute);
|
|
1338
1344
|
|
|
1345
|
+
// Align with navigation + locale stripping; initial reactive value can be wrong if magic ran before DOMContentLoaded.
|
|
1346
|
+
updateRoute();
|
|
1347
|
+
|
|
1339
1348
|
// Register $route magic property - return the route string directly
|
|
1340
1349
|
Alpine.magic('route', () => route.current);
|
|
1341
1350
|
}
|