mnfst 0.5.39 → 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.icons.js +6 -0
- package/dist/manifest.router.js +41 -1
- package/dist/manifest.utilities.js +19 -0
- package/package.json +1 -1
package/dist/manifest.icons.js
CHANGED
|
@@ -91,6 +91,12 @@ function initializeIconPlugin() {
|
|
|
91
91
|
const iconValue = expression;
|
|
92
92
|
if (!iconValue) return;
|
|
93
93
|
|
|
94
|
+
// Prerender (or static HTML) already inlined an Iconify SVG; leave it alone. Otherwise Alpine
|
|
95
|
+
// evaluates stale expressions like `module.icon` from templating and throws ReferenceError.
|
|
96
|
+
if (el.querySelector('svg[data-icon]')) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
94
100
|
// Check if it's a raw icon name (should contain a colon for icon format like 'lucide:house')
|
|
95
101
|
const isRawIconName = iconValue.includes(':') &&
|
|
96
102
|
!iconValue.includes("'") &&
|
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);
|
|
@@ -394,8 +398,20 @@ window.ManifestRoutingNavigation = {
|
|
|
394
398
|
|
|
395
399
|
// Router visibility
|
|
396
400
|
|
|
401
|
+
function isPrerenderedStaticMPA() {
|
|
402
|
+
try {
|
|
403
|
+
return document.querySelector('meta[name="manifest:prerendered"][content="1"]') !== null;
|
|
404
|
+
} catch (e) {
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
397
409
|
// Process visibility for all elements with x-route
|
|
398
410
|
function processRouteVisibility(normalizedPath) {
|
|
411
|
+
// Static prerender output already contains only this route's sections; x-cloak + toggling here
|
|
412
|
+
// causes a visible flash (content → hidden via x-cloak → shown when Alpine boots).
|
|
413
|
+
if (isPrerenderedStaticMPA()) return;
|
|
414
|
+
|
|
399
415
|
const routeElements = document.querySelectorAll('[x-route]');
|
|
400
416
|
|
|
401
417
|
// First pass: collect all defined routes (excluding !* and other negative conditions)
|
|
@@ -511,6 +527,7 @@ function processRouteVisibility(normalizedPath) {
|
|
|
511
527
|
|
|
512
528
|
// Add x-cloak to route elements that don't have it
|
|
513
529
|
function addXCloakToRouteElements() {
|
|
530
|
+
if (isPrerenderedStaticMPA()) return;
|
|
514
531
|
const routeElements = document.querySelectorAll('[x-route]:not([x-cloak])');
|
|
515
532
|
routeElements.forEach(element => {
|
|
516
533
|
element.setAttribute('x-cloak', '');
|
|
@@ -529,11 +546,13 @@ function initializeVisibility() {
|
|
|
529
546
|
|
|
530
547
|
// Listen for route changes
|
|
531
548
|
window.addEventListener('manifest:route-change', (event) => {
|
|
549
|
+
if (isPrerenderedStaticMPA()) return;
|
|
532
550
|
processRouteVisibility(event.detail.normalizedPath);
|
|
533
551
|
});
|
|
534
552
|
|
|
535
553
|
// Listen for component processing to ensure visibility is applied after components load
|
|
536
554
|
window.addEventListener('manifest:components-processed', () => {
|
|
555
|
+
if (isPrerenderedStaticMPA()) return;
|
|
537
556
|
// Add x-cloak to any new route elements
|
|
538
557
|
addXCloakToRouteElements();
|
|
539
558
|
|
|
@@ -559,11 +578,23 @@ if (document.readyState === 'loading') {
|
|
|
559
578
|
// Export visibility interface
|
|
560
579
|
window.ManifestRoutingVisibility = {
|
|
561
580
|
initialize: initializeVisibility,
|
|
562
|
-
processRouteVisibility
|
|
581
|
+
processRouteVisibility,
|
|
582
|
+
isPrerenderedStaticMPA
|
|
563
583
|
};
|
|
564
584
|
|
|
565
585
|
// Router head
|
|
566
586
|
|
|
587
|
+
function isPrerenderedStaticMPA() {
|
|
588
|
+
try {
|
|
589
|
+
if (window.ManifestRoutingVisibility && typeof window.ManifestRoutingVisibility.isPrerenderedStaticMPA === 'function') {
|
|
590
|
+
return window.ManifestRoutingVisibility.isPrerenderedStaticMPA();
|
|
591
|
+
}
|
|
592
|
+
return document.querySelector('meta[name="manifest:prerendered"][content="1"]') !== null;
|
|
593
|
+
} catch (e) {
|
|
594
|
+
return false;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
|
|
567
598
|
// Track injected head content to prevent duplicates
|
|
568
599
|
const injectedHeadContent = new Set();
|
|
569
600
|
|
|
@@ -713,6 +744,7 @@ function processElementHeadContent(element, normalizedPath) {
|
|
|
713
744
|
|
|
714
745
|
// Process all head content in the DOM
|
|
715
746
|
function processAllHeadContent(normalizedPath) {
|
|
747
|
+
if (isPrerenderedStaticMPA()) return;
|
|
716
748
|
|
|
717
749
|
// Find all elements with head templates
|
|
718
750
|
const elementsWithHead = document.querySelectorAll('template[data-head]');
|
|
@@ -791,6 +823,7 @@ function initializeHeadContent() {
|
|
|
791
823
|
function processHeadContentAfterComponentsReady() {
|
|
792
824
|
// Process initial head content after a longer delay to let components settle
|
|
793
825
|
setTimeout(() => {
|
|
826
|
+
if (isPrerenderedStaticMPA()) return;
|
|
794
827
|
const currentPath = window.ManifestRoutingNavigation?.getCurrentRoute() ?? window.location.pathname;
|
|
795
828
|
const normalizedPath = currentPath === '/' ? '/' : currentPath.replace(/^\/|\/$/g, '');
|
|
796
829
|
|
|
@@ -810,6 +843,7 @@ function initializeHeadContent() {
|
|
|
810
843
|
|
|
811
844
|
// Function to process head content immediately (for projects without components)
|
|
812
845
|
function processHeadContentImmediately() {
|
|
846
|
+
if (isPrerenderedStaticMPA()) return;
|
|
813
847
|
const currentPath = window.ManifestRoutingNavigation?.getCurrentRoute() ?? window.location.pathname;
|
|
814
848
|
const normalizedPath = currentPath === '/' ? '/' : currentPath.replace(/^\/|\/$/g, '');
|
|
815
849
|
processAllHeadContent(normalizedPath);
|
|
@@ -843,6 +877,7 @@ function initializeHeadContent() {
|
|
|
843
877
|
|
|
844
878
|
// Wait a bit for components to settle after route change
|
|
845
879
|
setTimeout(() => {
|
|
880
|
+
if (isPrerenderedStaticMPA()) return;
|
|
846
881
|
// Process head content immediately to catch components before they're reverted
|
|
847
882
|
const currentPath = window.ManifestRoutingNavigation?.getCurrentRoute() ?? window.location.pathname;
|
|
848
883
|
const normalizedPath = currentPath === '/' ? '/' : currentPath.replace(/^\/|\/$/g, '');
|
|
@@ -1261,6 +1296,8 @@ function initializeRouterMagic() {
|
|
|
1261
1296
|
console.error('[Manifest Router Magic] Alpine is not available');
|
|
1262
1297
|
return;
|
|
1263
1298
|
}
|
|
1299
|
+
if (window.__manifestRouterMagicInitialized) return;
|
|
1300
|
+
window.__manifestRouterMagicInitialized = true;
|
|
1264
1301
|
|
|
1265
1302
|
// Create a reactive object for route data (use logical path when app is in a subpath)
|
|
1266
1303
|
const route = Alpine.reactive({
|
|
@@ -1305,6 +1342,9 @@ function initializeRouterMagic() {
|
|
|
1305
1342
|
window.addEventListener('manifest:route-change', updateRoute);
|
|
1306
1343
|
window.addEventListener('popstate', updateRoute);
|
|
1307
1344
|
|
|
1345
|
+
// Align with navigation + locale stripping; initial reactive value can be wrong if magic ran before DOMContentLoaded.
|
|
1346
|
+
updateRoute();
|
|
1347
|
+
|
|
1308
1348
|
// Register $route magic property - return the route string directly
|
|
1309
1349
|
Alpine.magic('route', () => route.current);
|
|
1310
1350
|
}
|
|
@@ -452,6 +452,16 @@ class TailwindCompiler {
|
|
|
452
452
|
this.compileTimeout = null;
|
|
453
453
|
this.cache = new Map();
|
|
454
454
|
this.hasInitialized = true;
|
|
455
|
+
// manifest.code.js (and others) may still register ignore rules; mirror full constructor defaults.
|
|
456
|
+
this.ignoredClassPatterns = [
|
|
457
|
+
/^hljs/, /^language-/, /^copy$/, /^copied$/, /^lines$/, /^selected$/
|
|
458
|
+
];
|
|
459
|
+
this.ignoredElementSelectors = [
|
|
460
|
+
'pre', 'code', 'x-code', 'x-code-group'
|
|
461
|
+
];
|
|
462
|
+
this.significantChangeSelectors = [
|
|
463
|
+
'[data-component]', '[x-data]'
|
|
464
|
+
];
|
|
455
465
|
return;
|
|
456
466
|
}
|
|
457
467
|
|
|
@@ -600,6 +610,9 @@ class TailwindCompiler {
|
|
|
600
610
|
|
|
601
611
|
// Public API for other plugins to configure behavior
|
|
602
612
|
addIgnoredClassPattern(pattern) {
|
|
613
|
+
if (!Array.isArray(this.ignoredClassPatterns)) {
|
|
614
|
+
this.ignoredClassPatterns = [];
|
|
615
|
+
}
|
|
603
616
|
if (pattern instanceof RegExp) {
|
|
604
617
|
this.ignoredClassPatterns.push(pattern);
|
|
605
618
|
} else if (typeof pattern === 'string') {
|
|
@@ -608,12 +621,18 @@ class TailwindCompiler {
|
|
|
608
621
|
}
|
|
609
622
|
|
|
610
623
|
addIgnoredElementSelector(selector) {
|
|
624
|
+
if (!Array.isArray(this.ignoredElementSelectors)) {
|
|
625
|
+
this.ignoredElementSelectors = [];
|
|
626
|
+
}
|
|
611
627
|
if (typeof selector === 'string') {
|
|
612
628
|
this.ignoredElementSelectors.push(selector);
|
|
613
629
|
}
|
|
614
630
|
}
|
|
615
631
|
|
|
616
632
|
addSignificantChangeSelector(selector) {
|
|
633
|
+
if (!Array.isArray(this.significantChangeSelectors)) {
|
|
634
|
+
this.significantChangeSelectors = [];
|
|
635
|
+
}
|
|
617
636
|
if (typeof selector === 'string') {
|
|
618
637
|
this.significantChangeSelectors.push(selector);
|
|
619
638
|
}
|