mnfst 0.5.290 → 0.5.292
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/lib/manifest.appwrite.data.js +1 -1
- package/lib/manifest.components.js +123 -105
- package/lib/manifest.data.js +1 -1
- package/lib/manifest.integrity.json +6 -6
- package/lib/manifest.router.js +168 -123
- package/lib/manifest.sw.js +1 -1
- package/lib/manifest.utilities.js +223 -37
- package/lib/manifest.utilities.node.mjs +107 -2
- package/package.json +5 -1
|
@@ -610,6 +610,102 @@ window.ManifestComponentsProcessor = {
|
|
|
610
610
|
}
|
|
611
611
|
};
|
|
612
612
|
|
|
613
|
+
// Components routing gate
|
|
614
|
+
// The router may load before or after this plugin; never capture it once.
|
|
615
|
+
window.ManifestComponentsRouting = (function () {
|
|
616
|
+
const ROUTER_SRC = /(^|\/)manifest\.router(\.min)?\.js(\?|#|$)/;
|
|
617
|
+
const LATE_MS = 10000;
|
|
618
|
+
let givenUp = false;
|
|
619
|
+
let settled = null;
|
|
620
|
+
let rerunQueued = false;
|
|
621
|
+
|
|
622
|
+
function routerScripts() {
|
|
623
|
+
return Array.from(document.querySelectorAll('script[src]')).filter(s => ROUTER_SRC.test(s.getAttribute('src') || ''));
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
// No router yet, but a router script is still to run
|
|
627
|
+
function pending() {
|
|
628
|
+
if (window.ManifestRouting || givenUp) return false;
|
|
629
|
+
return routerScripts().some(s => !s.hasAttribute('data-mnfst-loaded'));
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
// Resolves once the router has arrived or is known not to be coming
|
|
633
|
+
function whenSettled() {
|
|
634
|
+
if (!pending()) return Promise.resolve();
|
|
635
|
+
if (settled) return settled;
|
|
636
|
+
settled = new Promise(resolve => {
|
|
637
|
+
const watched = new WeakSet();
|
|
638
|
+
let done = false;
|
|
639
|
+
const finish = () => {
|
|
640
|
+
if (done) return;
|
|
641
|
+
done = true;
|
|
642
|
+
window.removeEventListener('manifest:routing-ready', check);
|
|
643
|
+
window.removeEventListener('load', onLoad);
|
|
644
|
+
settled = null;
|
|
645
|
+
resolve();
|
|
646
|
+
};
|
|
647
|
+
const watch = () => routerScripts().forEach(s => {
|
|
648
|
+
if (watched.has(s)) return;
|
|
649
|
+
watched.add(s);
|
|
650
|
+
s.addEventListener('load', check);
|
|
651
|
+
s.addEventListener('error', check);
|
|
652
|
+
});
|
|
653
|
+
// A failed CDN tag is swapped for the next one: re-scan a tick later
|
|
654
|
+
function check() { setTimeout(() => { if (pending()) watch(); else finish(); }, 0); }
|
|
655
|
+
// Window load waits for in-flight scripts: a router not here by then isn't coming
|
|
656
|
+
function onLoad() { setTimeout(() => { if (done) return; if (pending()) givenUp = true; finish(); }, 0); }
|
|
657
|
+
watch();
|
|
658
|
+
window.addEventListener('manifest:routing-ready', check);
|
|
659
|
+
// Inserted after load (Manifest.loadPlugin): its own load/error decides, bounded
|
|
660
|
+
if (document.readyState === 'complete') setTimeout(onLoad, LATE_MS);
|
|
661
|
+
else window.addEventListener('load', onLoad);
|
|
662
|
+
});
|
|
663
|
+
return settled;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
// Same condition grammar as route visibility: comma list, ! negates
|
|
667
|
+
function matches(xRoute, path) {
|
|
668
|
+
const routing = window.ManifestRouting;
|
|
669
|
+
if (!xRoute || !routing) return true;
|
|
670
|
+
const conditions = xRoute.split(',').map(c => c.trim()).filter(Boolean);
|
|
671
|
+
const positive = conditions.filter(c => !c.startsWith('!'));
|
|
672
|
+
const negative = conditions.filter(c => c.startsWith('!')).map(c => c.slice(1));
|
|
673
|
+
if (negative.some(c => routing.matchesCondition(path, c))) return false;
|
|
674
|
+
return positive.length === 0 || positive.some(c => routing.matchesCondition(path, c));
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
// One swapping pass once the router settles, for every placeholder deferred meanwhile
|
|
678
|
+
function rerunWhenSettled() {
|
|
679
|
+
if (rerunQueued) return;
|
|
680
|
+
rerunQueued = true;
|
|
681
|
+
whenSettled().then(() => {
|
|
682
|
+
rerunQueued = false;
|
|
683
|
+
const swapping = window.ManifestComponentsSwapping;
|
|
684
|
+
return swapping && swapping.processAll().then(() => {
|
|
685
|
+
window.dispatchEvent(new CustomEvent('manifest:components-processed'));
|
|
686
|
+
});
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
function currentPath() {
|
|
691
|
+
const p = window.location.pathname;
|
|
692
|
+
return p === '/' ? '/' : p.replace(/^\/+|\/+$/g, '');
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
// 'swap' | 'skip' | 'defer' for a placeholder at a path
|
|
696
|
+
function decide(el, path) {
|
|
697
|
+
const xRoute = el.getAttribute('x-route');
|
|
698
|
+
if (!xRoute) return 'swap';
|
|
699
|
+
if (window.ManifestRouting) return matches(xRoute, path ?? currentPath()) ? 'swap' : 'skip';
|
|
700
|
+
if (!pending()) return 'swap';
|
|
701
|
+
rerunWhenSettled();
|
|
702
|
+
return 'defer';
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
return { pending, whenSettled, matches, decide };
|
|
706
|
+
})();
|
|
707
|
+
|
|
708
|
+
|
|
613
709
|
// Components swapping
|
|
614
710
|
(function () {
|
|
615
711
|
// Never reset — ids must stay unique for the life of the page so overlapping
|
|
@@ -733,7 +829,7 @@ window.ManifestComponentsProcessor = {
|
|
|
733
829
|
console.debug('[Manifest Components] skipped processAll: registry unavailable');
|
|
734
830
|
return;
|
|
735
831
|
}
|
|
736
|
-
const
|
|
832
|
+
const gate = window.ManifestComponentsRouting;
|
|
737
833
|
|
|
738
834
|
// Use normalized path from event if provided, otherwise compute from window.location
|
|
739
835
|
let normalizedPath;
|
|
@@ -750,34 +846,13 @@ window.ManifestComponentsProcessor = {
|
|
|
750
846
|
!el.hasAttribute('data-processed')
|
|
751
847
|
);
|
|
752
848
|
// First pass: revert any swapped-in instances that no longer match
|
|
753
|
-
if (
|
|
849
|
+
if (window.ManifestRouting) {
|
|
754
850
|
for (const instanceId of Array.from(swappedInstances)) {
|
|
755
851
|
const xRoute = instanceRouteMap.get(instanceId);
|
|
756
|
-
if (!xRoute)
|
|
757
|
-
// No route condition means always visible, don't revert
|
|
758
|
-
continue;
|
|
759
|
-
}
|
|
760
|
-
// Parse route conditions the same way as route visibility
|
|
761
|
-
const conditions = xRoute.split(',').map(cond => cond.trim());
|
|
762
|
-
const positiveConditions = conditions.filter(cond => !cond.startsWith('!'));
|
|
763
|
-
const negativeConditions = conditions
|
|
764
|
-
.filter(cond => cond.startsWith('!'))
|
|
765
|
-
.map(cond => cond.slice(1));
|
|
766
|
-
|
|
767
|
-
const hasNegativeMatch = negativeConditions.some(cond =>
|
|
768
|
-
window.ManifestRouting.matchesCondition(normalizedPath, cond)
|
|
769
|
-
);
|
|
770
|
-
const hasPositiveMatch = positiveConditions.length === 0 || positiveConditions.some(cond =>
|
|
771
|
-
window.ManifestRouting.matchesCondition(normalizedPath, cond)
|
|
772
|
-
);
|
|
773
|
-
|
|
774
|
-
const matches = hasPositiveMatch && !hasNegativeMatch;
|
|
775
|
-
if (!matches) {
|
|
776
|
-
this.revert(instanceId);
|
|
777
|
-
}
|
|
852
|
+
if (xRoute && !gate.matches(xRoute, normalizedPath)) this.revert(instanceId);
|
|
778
853
|
}
|
|
779
854
|
}
|
|
780
|
-
// Second pass: swap in
|
|
855
|
+
// Second pass: swap in matches. Routing is read per placeholder: it may arrive mid-pass.
|
|
781
856
|
for (const placeholder of placeholders) {
|
|
782
857
|
const name = placeholder.tagName.toLowerCase().replace('x-', '');
|
|
783
858
|
let instanceId = placeholder.getAttribute('data-component');
|
|
@@ -785,38 +860,8 @@ window.ManifestComponentsProcessor = {
|
|
|
785
860
|
instanceId = getComponentInstanceId(name);
|
|
786
861
|
placeholder.setAttribute('data-component', instanceId);
|
|
787
862
|
}
|
|
788
|
-
|
|
789
|
-
if (
|
|
790
|
-
// No routing: always swap in
|
|
791
|
-
await this.swapIn(placeholder);
|
|
792
|
-
} else {
|
|
793
|
-
// Routing present: check route using same logic as route visibility
|
|
794
|
-
// Handle comma-separated route conditions (e.g., "/,page-1,page-2")
|
|
795
|
-
let matches = !xRoute;
|
|
796
|
-
if (xRoute) {
|
|
797
|
-
const conditions = xRoute.split(',').map(cond => cond.trim());
|
|
798
|
-
const positiveConditions = conditions.filter(cond => !cond.startsWith('!'));
|
|
799
|
-
const negativeConditions = conditions
|
|
800
|
-
.filter(cond => cond.startsWith('!'))
|
|
801
|
-
.map(cond => cond.slice(1));
|
|
802
|
-
|
|
803
|
-
// Check negative conditions first
|
|
804
|
-
const hasNegativeMatch = negativeConditions.some(cond =>
|
|
805
|
-
window.ManifestRouting.matchesCondition(normalizedPath, cond)
|
|
806
|
-
);
|
|
807
|
-
|
|
808
|
-
// Check positive conditions
|
|
809
|
-
const hasPositiveMatch = positiveConditions.length === 0 || positiveConditions.some(cond =>
|
|
810
|
-
window.ManifestRouting.matchesCondition(normalizedPath, cond)
|
|
811
|
-
);
|
|
812
|
-
|
|
813
|
-
matches = hasPositiveMatch && !hasNegativeMatch;
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
if (matches) {
|
|
817
|
-
await this.swapIn(placeholder);
|
|
818
|
-
}
|
|
819
|
-
}
|
|
863
|
+
// 'defer' queues a re-run for when the router settles
|
|
864
|
+
if (gate.decide(placeholder, normalizedPath) === 'swap') await this.swapIn(placeholder);
|
|
820
865
|
}
|
|
821
866
|
},
|
|
822
867
|
// Public entry point. Coalesces overlapping calls: while a run is active,
|
|
@@ -859,26 +904,23 @@ window.ManifestComponentsProcessor = {
|
|
|
859
904
|
// Dispatch event when components are fully processed
|
|
860
905
|
window.dispatchEvent(new CustomEvent('manifest:components-processed'));
|
|
861
906
|
});
|
|
862
|
-
//
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
this.processAll(normalizedPath).then(() => {
|
|
868
|
-
// Dispatch event when components are fully processed after route change
|
|
869
|
-
window.dispatchEvent(new CustomEvent('manifest:components-processed'));
|
|
870
|
-
});
|
|
907
|
+
// Only the router dispatches route changes, whenever it arrives
|
|
908
|
+
window.addEventListener('manifest:route-change', (event) => {
|
|
909
|
+
const normalizedPath = event.detail?.normalizedPath || null;
|
|
910
|
+
this.processAll(normalizedPath).then(() => {
|
|
911
|
+
window.dispatchEvent(new CustomEvent('manifest:components-processed'));
|
|
871
912
|
});
|
|
872
|
-
}
|
|
913
|
+
});
|
|
873
914
|
}
|
|
874
915
|
};
|
|
875
916
|
})();
|
|
876
917
|
|
|
877
918
|
// Components mutation observer
|
|
919
|
+
// Deferred placeholders are left for swapping's post-router pass.
|
|
878
920
|
window.ManifestComponentsMutation = {
|
|
879
921
|
async processAllPlaceholders() {
|
|
880
922
|
const processor = window.ManifestComponentsProcessor;
|
|
881
|
-
const
|
|
923
|
+
const gate = window.ManifestComponentsRouting;
|
|
882
924
|
if (!processor) return;
|
|
883
925
|
const placeholders = Array.from(document.querySelectorAll('*')).filter(el =>
|
|
884
926
|
el.tagName.toLowerCase().startsWith('x-') &&
|
|
@@ -886,56 +928,31 @@ window.ManifestComponentsMutation = {
|
|
|
886
928
|
!el.hasAttribute('data-processed')
|
|
887
929
|
);
|
|
888
930
|
for (const el of placeholders) {
|
|
889
|
-
if (
|
|
890
|
-
// Only process if route matches
|
|
891
|
-
const xRoute = el.getAttribute('x-route');
|
|
892
|
-
const currentPath = window.location.pathname;
|
|
893
|
-
const normalizedPath = currentPath === '/' ? '/' : currentPath.replace(/^\/+|\/+$/g, '');
|
|
894
|
-
const matches = !xRoute || window.ManifestRouting.matchesCondition(normalizedPath, xRoute);
|
|
895
|
-
if (!matches) continue;
|
|
896
|
-
}
|
|
931
|
+
if (gate.decide(el) !== 'swap') continue;
|
|
897
932
|
await processor.processComponent(el);
|
|
898
933
|
}
|
|
899
934
|
},
|
|
900
935
|
initialize() {
|
|
901
936
|
const processor = window.ManifestComponentsProcessor;
|
|
902
|
-
const
|
|
937
|
+
const gate = window.ManifestComponentsRouting;
|
|
903
938
|
if (!processor) return;
|
|
904
939
|
// Initial scan
|
|
905
940
|
this.processAllPlaceholders();
|
|
941
|
+
const isPlaceholder = el => el.tagName.toLowerCase().startsWith('x-') &&
|
|
942
|
+
!el.hasAttribute('data-pre-rendered') && !el.hasAttribute('data-processed');
|
|
906
943
|
// Mutation observer for new placeholders
|
|
907
944
|
const observer = new MutationObserver(async mutations => {
|
|
908
945
|
for (const mutation of mutations) {
|
|
909
946
|
for (const node of mutation.addedNodes) {
|
|
910
|
-
if (node.nodeType
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
const xRoute = node.getAttribute('x-route');
|
|
914
|
-
const currentPath = window.location.pathname;
|
|
915
|
-
const normalizedPath = currentPath === '/' ? '/' : currentPath.replace(/^\/+|\/+$/g, '');
|
|
916
|
-
const matches = !xRoute || window.ManifestRouting.matchesCondition(normalizedPath, xRoute);
|
|
917
|
-
if (!matches) continue;
|
|
918
|
-
}
|
|
919
|
-
await processor.processComponent(node);
|
|
920
|
-
}
|
|
947
|
+
if (node.nodeType !== 1) continue;
|
|
948
|
+
if (isPlaceholder(node) && gate.decide(node) === 'swap') {
|
|
949
|
+
await processor.processComponent(node);
|
|
921
950
|
}
|
|
922
951
|
// Also check for any <x-*> descendants
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
!el.hasAttribute('data-processed')
|
|
928
|
-
);
|
|
929
|
-
for (const el of descendants) {
|
|
930
|
-
if (routing) {
|
|
931
|
-
const xRoute = el.getAttribute('x-route');
|
|
932
|
-
const currentPath = window.location.pathname;
|
|
933
|
-
const normalizedPath = currentPath === '/' ? '/' : currentPath.replace(/^\/+|\/+$/g, '');
|
|
934
|
-
const matches = !xRoute || window.ManifestRouting.matchesCondition(normalizedPath, xRoute);
|
|
935
|
-
if (!matches) continue;
|
|
936
|
-
}
|
|
937
|
-
await processor.processComponent(el);
|
|
938
|
-
}
|
|
952
|
+
const descendants = Array.from(node.querySelectorAll('*')).filter(isPlaceholder);
|
|
953
|
+
for (const el of descendants) {
|
|
954
|
+
if (gate.decide(el) !== 'swap') continue;
|
|
955
|
+
await processor.processComponent(el);
|
|
939
956
|
}
|
|
940
957
|
}
|
|
941
958
|
}
|
|
@@ -951,7 +968,8 @@ window.ManifestComponentsMutation = {
|
|
|
951
968
|
});
|
|
952
969
|
}
|
|
953
970
|
}
|
|
954
|
-
};
|
|
971
|
+
};
|
|
972
|
+
|
|
955
973
|
|
|
956
974
|
/* Manifest Components — route-level prefetch (batch on route change + on hover) */
|
|
957
975
|
|
package/lib/manifest.data.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest.appwrite.auth.js": "sha384-gWLSeVPqCLMiUZB8MU7GqMg3x2yULFUsp8nTTZrPp/9Dlkix42rBn9yIimvwrHqZ",
|
|
3
|
-
"manifest.appwrite.data.js": "sha384-
|
|
3
|
+
"manifest.appwrite.data.js": "sha384-oNZ+lin9wI5/jzB3v244kwSp6w6xGEo0NgGe8MTzc5PjWkwNESr3nlF3HTl2doWd",
|
|
4
4
|
"manifest.appwrite.presences.js": "sha384-LINPhIPTCK+rA8zd+HPUzMSEgH6Sl2vQMEyItT97bnEE2FYGYKqjXX+CWdt6nl9z",
|
|
5
5
|
"manifest.bindings.js": "sha384-lPtMf8Ykaic9gNVZKq8Scia1881ZeMAyxer3WCIkUNwwrgzGBWto1OXADUwjvORF",
|
|
6
6
|
"manifest.charts.js": "sha384-AFbP7mQnigy7DU1s+YE30yKTeQAKfgNazhbfSNbfd9ZpLgeulZKaPi/fAq3gJHDO",
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"manifest.color.js": "sha384-tLmmr7KwPIjznXr2tJfJtuAOV9pohdr+Ojj4L4BaOZ8WngCNOPUp27Dfz47YqU2R",
|
|
10
10
|
"manifest.colorpicker.js": "sha384-P+Zx0QzhMGfku8s3yEskTte4/iXCGVX3zdhu42IGNfFcSmhOW+nqVK7w+uczWRGY",
|
|
11
11
|
"manifest.combobox.js": "sha384-/lJo6vaxKjgnBSRs/dzkhK1dzGk3GBw8FISoNJZB70mwAVwu1k5veZyBXjOb4keS",
|
|
12
|
-
"manifest.components.js": "sha384-
|
|
12
|
+
"manifest.components.js": "sha384-3kjiDSDrxJtdtqMpWKj7pl9RYKlY/S/yn9NHtrdP8NUDZdP2kvyeaHWdZ0kP/dzB",
|
|
13
13
|
"manifest.computed.js": "sha384-GYML/e81gQfN+iDbqhPUgny8bINCyL+SrbTofoGk4hlCnLLjv51mCv42JMqq+ku5",
|
|
14
|
-
"manifest.data.js": "sha384-
|
|
14
|
+
"manifest.data.js": "sha384-j/CI2i6V4EnD28/TKyq1fPB0E/pBpHO/emT9/0RHjiOxttaON7yc57oCclMZFxmb",
|
|
15
15
|
"manifest.datepicker.js": "sha384-EzlMwvIxlla/0BuyhAEqxN0M8TGcWIWgEIg840V0akKQQK1uY648wPWMkobvtq/o",
|
|
16
16
|
"manifest.defer.js": "sha384-PRp7+dCZHnnl55rX2xrHutLrQnszHo7o5o9Tq28M/yjLZPuXDzcwQNxCdvbtCYSz",
|
|
17
17
|
"manifest.device.js": "sha384-YeQaS56L8IILqrQNBSeAOLwIh5DuAOrE60cYLK1+46qJtUrXlAvqGe2j5mbV4Vq7",
|
|
@@ -24,18 +24,18 @@
|
|
|
24
24
|
"manifest.native.js": "sha384-YeQaS56L8IILqrQNBSeAOLwIh5DuAOrE60cYLK1+46qJtUrXlAvqGe2j5mbV4Vq7",
|
|
25
25
|
"manifest.payments.js": "sha384-p10n6EHBWFKVW9KhI2A+RpkwqrwD068D+wvOJ7D3Gklz1MvmIlqv1lLG1R0cUqbw",
|
|
26
26
|
"manifest.rich.text.js": "sha384-ZBV9jXmu2nmprEHicddRE/m7nR4RPZtVc969Jte0+EJYBcVph7itkjcgN/61PyeC",
|
|
27
|
-
"manifest.router.js": "sha384-
|
|
27
|
+
"manifest.router.js": "sha384-C+3jwRS+kxSZ0wQDtZ5NvOqcFaXrC4uevIzamHUuxgGcmtDcCRCZnMK53lFkClM9",
|
|
28
28
|
"manifest.slides.js": "sha384-3uRTkyK9XPLmnxI2+igZlpi4EyPlU/7IHj5j3BZJJ2KN455vXyk99fiXV3feO/XY",
|
|
29
29
|
"manifest.status.js": "sha384-ofu7nBnVIGZ1U1o2R9d2H3V8aEMPUCVbl5FO3gIToXqi0oa36fTviEdh5UU7Kitw",
|
|
30
30
|
"manifest.submissions.js": "sha384-v9eS47ytAfTGIKAyVnbd0QWegucVS7yduvigqfsxxoqXmbaEoy0M2y+BiI4xeZBd",
|
|
31
31
|
"manifest.svg.js": "sha384-qr/8H9+2cIhSXNbRWRtIdrDlTOxKlNJqwEefHvCYoiBNW/kKhPTFa109Orv/EBnb",
|
|
32
|
-
"manifest.sw.js": "sha384-
|
|
32
|
+
"manifest.sw.js": "sha384-vZlT026s96VLf4+v38pNX9fnfuANMQbGlgSYnMKWNdzRCXNwaKBgDxbrivu3SVdE",
|
|
33
33
|
"manifest.tabs.js": "sha384-otU09H7jnawVKQdLAYpMCd3jx00tgyPVr42D2hLIBzN5dG4se505YesavdnMqEi1",
|
|
34
34
|
"manifest.tailwind.js": "sha384-yuP3LEvWU+QVjxjkZ0YhErtC9RrGmhOmHjjFjhS9obqZbp5/KTIEnSR0CXDvHE0B",
|
|
35
35
|
"manifest.toasts.js": "sha384-UpOz9fAdGeGUhL0NamBg5iPepEfIy73p9HYdcxfOQC5b7CVsl7Our0skdZzaLNcC",
|
|
36
36
|
"manifest.tooltips.js": "sha384-hXGp5j0s6p2kGZY/hqLPEbaUv68ca63kFCjYiZqK3DcC12mpHTBy1vz3kuApyf4p",
|
|
37
37
|
"manifest.url.parameters.js": "sha384-J2aSVBOPsoqsbafHndrWLHEDpKb4AKJAoQnVmKA4gZh5P/8HHjFWHO/lkusmG84l",
|
|
38
|
-
"manifest.utilities.js": "sha384-
|
|
38
|
+
"manifest.utilities.js": "sha384-IT5dOFePCzbLAuVXMiXXW7lYnxVwHMfjtvn1edWEdASlNlJO60YbILm2+l+Cjm8g",
|
|
39
39
|
"manifest.virtual.js": "sha384-PtIDx042i29mkxEYZH+y3whBzKgBgV01CU1XzzeEl/8TBPl9qvny4ppyXgYI5DsM",
|
|
40
40
|
"manifest.js": "sha384-7+hNmvzD6OPQt6q4pZEDoqf5C8LHucIqlfKJQAAH6b4tsmvpX0viCvdYqqGOjqET"
|
|
41
41
|
}
|
package/lib/manifest.router.js
CHANGED
|
@@ -13,13 +13,6 @@ function initializeRouting() {
|
|
|
13
13
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
// Start initialization when DOM is ready
|
|
17
|
-
if (document.readyState === 'loading') {
|
|
18
|
-
document.addEventListener('DOMContentLoaded', initializeRouting);
|
|
19
|
-
} else {
|
|
20
|
-
initializeRouting();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
16
|
// Export main routing interface
|
|
24
17
|
window.ManifestRouting = {
|
|
25
18
|
initialize: initializeRouting,
|
|
@@ -89,6 +82,13 @@ window.ManifestRouting = {
|
|
|
89
82
|
}
|
|
90
83
|
};
|
|
91
84
|
|
|
85
|
+
// Start when DOM is ready; after the export so routing-ready listeners can read ManifestRouting
|
|
86
|
+
if (document.readyState === 'loading') {
|
|
87
|
+
document.addEventListener('DOMContentLoaded', initializeRouting);
|
|
88
|
+
} else {
|
|
89
|
+
initializeRouting();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
92
|
|
|
93
93
|
// Router position
|
|
94
94
|
|
|
@@ -913,9 +913,6 @@ function headIsPrerenderedMPA() {
|
|
|
913
913
|
}
|
|
914
914
|
}
|
|
915
915
|
|
|
916
|
-
// Track injected head content to prevent duplicates
|
|
917
|
-
const injectedHeadContent = new Set();
|
|
918
|
-
|
|
919
916
|
// Check if an element should be visible based on route conditions
|
|
920
917
|
function shouldElementBeVisible(element, normalizedPath) {
|
|
921
918
|
|
|
@@ -988,141 +985,189 @@ function resolveDataHeadBindings(element) {
|
|
|
988
985
|
}
|
|
989
986
|
}
|
|
990
987
|
|
|
991
|
-
//
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
988
|
+
// Template id → head elements it owns (attached or superseded)
|
|
989
|
+
const injectedHead = new Map();
|
|
990
|
+
const templateHeadIds = new WeakMap();
|
|
991
|
+
const usedHeadIds = new Set();
|
|
992
|
+
// Static index.html tags set aside while a route provides their identity → { key, next }
|
|
993
|
+
const supersededStatic = new Map();
|
|
994
|
+
let headIdCounter = 0;
|
|
995
|
+
|
|
996
|
+
// Stable per-template id, so leaving a route finds what it injected
|
|
997
|
+
function generateHeadId(template, host) {
|
|
998
|
+
if (templateHeadIds.has(template)) return templateHeadIds.get(template);
|
|
999
|
+
const order = host && host.getAttribute('data-order');
|
|
1000
|
+
const componentId = host && host.getAttribute('data-component-id');
|
|
1001
|
+
let id = order ? `head-${order}` : componentId ? `head-${componentId}` : '';
|
|
1002
|
+
if (!id || usedHeadIds.has(id)) {
|
|
1003
|
+
do { id = `head-${++headIdCounter}`; } while (usedHeadIds.has(id));
|
|
1003
1004
|
}
|
|
1005
|
+
usedHeadIds.add(id);
|
|
1006
|
+
templateHeadIds.set(template, id);
|
|
1007
|
+
return id;
|
|
1004
1008
|
}
|
|
1005
1009
|
|
|
1006
|
-
//
|
|
1007
|
-
function
|
|
1008
|
-
|
|
1010
|
+
// Tags that replace each other by identity
|
|
1011
|
+
function headIdentity(el) {
|
|
1012
|
+
const tag = el.tagName;
|
|
1013
|
+
if (tag === 'TITLE') return 'title';
|
|
1014
|
+
if (tag === 'META') {
|
|
1015
|
+
const name = el.getAttribute('name');
|
|
1016
|
+
if (name) return `meta:name:${name.toLowerCase()}|${el.getAttribute('media') || ''}`;
|
|
1017
|
+
const prop = el.getAttribute('property');
|
|
1018
|
+
if (prop) return `meta:property:${prop.toLowerCase()}`;
|
|
1019
|
+
return null;
|
|
1020
|
+
}
|
|
1021
|
+
if (tag === 'LINK' && (el.getAttribute('rel') || '').toLowerCase() === 'canonical') return 'link:canonical';
|
|
1022
|
+
return null;
|
|
1023
|
+
}
|
|
1009
1024
|
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1025
|
+
// Route host for a non-component template
|
|
1026
|
+
function headTemplateHost(template) {
|
|
1027
|
+
let element = template.closest('[data-order], [data-component-id], [x-route]');
|
|
1028
|
+
if (!element || element === template) {
|
|
1029
|
+
if (template.hasAttribute('data-order') || template.hasAttribute('data-component') || template.hasAttribute('x-route')) {
|
|
1030
|
+
element = template;
|
|
1031
|
+
} else {
|
|
1032
|
+
element = template.parentElement;
|
|
1033
|
+
}
|
|
1016
1034
|
}
|
|
1035
|
+
return element;
|
|
1036
|
+
}
|
|
1017
1037
|
|
|
1018
|
-
|
|
1019
|
-
|
|
1038
|
+
function headTemplateIsActive(template, host, normalizedPath) {
|
|
1039
|
+
if (template.hasAttribute('data-component')) {
|
|
1040
|
+
const componentRoute = template.getAttribute('x-route');
|
|
1041
|
+
if (componentRoute) return window.ManifestRouting.matchesCondition(normalizedPath, componentRoute);
|
|
1042
|
+
// Rendered component without its own route: active while connected under active routes
|
|
1043
|
+
return template.isConnected && shouldElementBeVisible(template, normalizedPath);
|
|
1020
1044
|
}
|
|
1045
|
+
return host ? shouldElementBeVisible(host, normalizedPath) : true;
|
|
1046
|
+
}
|
|
1021
1047
|
|
|
1022
|
-
|
|
1023
|
-
const
|
|
1048
|
+
function createHeadElements(template, headId) {
|
|
1049
|
+
const created = [];
|
|
1050
|
+
Array.from(template.content.children).forEach(child => {
|
|
1051
|
+
let el;
|
|
1052
|
+
if (child.tagName === 'SCRIPT') {
|
|
1053
|
+
// Fresh script so it executes; keep src/type/async/nonce etc.
|
|
1054
|
+
el = document.createElement('script');
|
|
1055
|
+
for (const attr of child.attributes) el.setAttribute(attr.name, attr.value);
|
|
1056
|
+
if (child.textContent) el.textContent = child.textContent;
|
|
1057
|
+
} else {
|
|
1058
|
+
el = child.cloneNode(true);
|
|
1059
|
+
resolveDataHeadBindings(el);
|
|
1060
|
+
}
|
|
1061
|
+
el.setAttribute('data-route-head', headId);
|
|
1062
|
+
document.head.appendChild(el);
|
|
1063
|
+
created.push(el);
|
|
1064
|
+
});
|
|
1065
|
+
return created;
|
|
1066
|
+
}
|
|
1024
1067
|
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1068
|
+
// Route element a template answers to, for nesting comparisons
|
|
1069
|
+
function headRouteHost(template, host) {
|
|
1070
|
+
const base = host || template;
|
|
1071
|
+
return (base.closest && base.closest('[x-route]')) || base;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
// Later candidate wins, unless the current owner's route is nested inside it
|
|
1075
|
+
function headOutranks(candidate, current, routeHosts) {
|
|
1076
|
+
const a = routeHosts.get(candidate), b = routeHosts.get(current);
|
|
1077
|
+
if (a && b && a !== b && a.contains(b)) return false;
|
|
1078
|
+
return true;
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
// Per identity, the winning active template keeps all its tags for it (og:image ×2,
|
|
1082
|
+
// theme-color by media…); static tags of that identity step aside as a group
|
|
1083
|
+
function applyHeadIdentities(activeIds, routeHosts) {
|
|
1084
|
+
const owner = new Map();
|
|
1085
|
+
for (const id of activeIds) {
|
|
1086
|
+
const keys = new Set();
|
|
1087
|
+
for (const el of injectedHead.get(id) || []) {
|
|
1088
|
+
const key = headIdentity(el);
|
|
1089
|
+
if (key) keys.add(key);
|
|
1029
1090
|
}
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
return;
|
|
1091
|
+
for (const key of keys) {
|
|
1092
|
+
if (!owner.has(key) || headOutranks(id, owner.get(key), routeHosts)) owner.set(key, id);
|
|
1033
1093
|
}
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
for (const attr of child.attributes) {
|
|
1044
|
-
script.setAttribute(attr.name, attr.value);
|
|
1045
|
-
}
|
|
1046
|
-
if (child.textContent) script.textContent = child.textContent;
|
|
1047
|
-
script.setAttribute('data-route-head', headId);
|
|
1048
|
-
document.head.appendChild(script);
|
|
1049
|
-
} else {
|
|
1050
|
-
// For other elements, clone and add (resolve $x bindings so meta/link have real values in SPA)
|
|
1051
|
-
const clonedChild = child.cloneNode(true);
|
|
1052
|
-
resolveDataHeadBindings(clonedChild);
|
|
1053
|
-
clonedChild.setAttribute('data-route-head', headId);
|
|
1054
|
-
document.head.appendChild(clonedChild);
|
|
1094
|
+
}
|
|
1095
|
+
for (const id of activeIds) {
|
|
1096
|
+
for (const el of injectedHead.get(id) || []) {
|
|
1097
|
+
const key = headIdentity(el);
|
|
1098
|
+
if (!key) continue;
|
|
1099
|
+
if (owner.get(key) === id) {
|
|
1100
|
+
if (!el.isConnected) document.head.appendChild(el);
|
|
1101
|
+
} else if (el.isConnected) {
|
|
1102
|
+
el.remove();
|
|
1055
1103
|
}
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
const
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
// Remember each static tag's place by the next sibling that stays, so a group restores in order
|
|
1107
|
+
const aside = Array.from(document.head.children).filter(el => {
|
|
1108
|
+
if (el.hasAttribute('data-route-head') || supersededStatic.has(el)) return false;
|
|
1109
|
+
const key = headIdentity(el);
|
|
1110
|
+
return !!key && owner.has(key);
|
|
1111
|
+
});
|
|
1112
|
+
const asideSet = new Set(aside);
|
|
1113
|
+
for (const el of aside) {
|
|
1114
|
+
let next = el.nextElementSibling;
|
|
1115
|
+
while (next && asideSet.has(next)) next = next.nextElementSibling;
|
|
1116
|
+
supersededStatic.set(el, { key: headIdentity(el), next });
|
|
1117
|
+
}
|
|
1118
|
+
aside.forEach(el => el.remove());
|
|
1119
|
+
// A tag of the same identity added meanwhile takes the set-aside one's place
|
|
1120
|
+
const taken = new Set();
|
|
1121
|
+
for (const el of Array.from(document.head.children)) {
|
|
1122
|
+
if (!el.hasAttribute('data-route-head')) taken.add(headIdentity(el));
|
|
1123
|
+
}
|
|
1124
|
+
for (const [el, { key, next }] of supersededStatic) {
|
|
1125
|
+
if (owner.has(key)) continue;
|
|
1126
|
+
supersededStatic.delete(el);
|
|
1127
|
+
if (el.isConnected || taken.has(key)) continue;
|
|
1128
|
+
if (next && next.parentNode === document.head) document.head.insertBefore(el, next);
|
|
1129
|
+
else document.head.appendChild(el);
|
|
1066
1130
|
}
|
|
1067
1131
|
}
|
|
1068
1132
|
|
|
1069
|
-
//
|
|
1133
|
+
// Sync document.head with the route's active <template data-head> blocks
|
|
1070
1134
|
function processAllHeadContent(normalizedPath) {
|
|
1071
1135
|
if (headIsPrerenderedMPA()) return;
|
|
1072
1136
|
|
|
1073
|
-
|
|
1074
|
-
const
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
// should be visible for the current route
|
|
1086
|
-
if (template.hasAttribute('data-component')) {
|
|
1087
|
-
const componentId = template.getAttribute('data-component');
|
|
1088
|
-
const componentRoute = template.getAttribute('x-route');
|
|
1137
|
+
const activeIds = [];
|
|
1138
|
+
const active = new Map();
|
|
1139
|
+
const routeHosts = new Map();
|
|
1140
|
+
document.querySelectorAll('template[data-head]').forEach(template => {
|
|
1141
|
+
const host = template.hasAttribute('data-component') ? template : headTemplateHost(template);
|
|
1142
|
+
if (!headTemplateIsActive(template, host, normalizedPath)) return;
|
|
1143
|
+
const headId = generateHeadId(template, host);
|
|
1144
|
+
if (active.has(headId)) return;
|
|
1145
|
+
active.set(headId, template);
|
|
1146
|
+
routeHosts.set(headId, headRouteHost(template, host));
|
|
1147
|
+
activeIds.push(headId);
|
|
1148
|
+
});
|
|
1089
1149
|
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
// For non-component templates, use the existing logic
|
|
1099
|
-
element = template.closest('[data-order], [data-component-id], [x-route]');
|
|
1150
|
+
for (const [id, els] of injectedHead) {
|
|
1151
|
+
if (active.has(id)) continue;
|
|
1152
|
+
els.forEach(el => el.remove());
|
|
1153
|
+
injectedHead.delete(id);
|
|
1154
|
+
}
|
|
1155
|
+
document.head.querySelectorAll('[data-route-head]').forEach(el => {
|
|
1156
|
+
if (!active.has(el.getAttribute('data-route-head'))) el.remove();
|
|
1157
|
+
});
|
|
1100
1158
|
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
element = template.parentElement;
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1159
|
+
for (const id of activeIds) {
|
|
1160
|
+
if (injectedHead.has(id)) continue;
|
|
1161
|
+
const existing = Array.from(document.head.querySelectorAll(`[data-route-head="${id}"]`));
|
|
1162
|
+
injectedHead.set(id, existing.length ? existing : createHeadElements(active.get(id), id));
|
|
1163
|
+
}
|
|
1109
1164
|
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
shouldProcess = isVisible;
|
|
1113
|
-
}
|
|
1114
|
-
}
|
|
1165
|
+
applyHeadIdentities(activeIds, routeHosts);
|
|
1166
|
+
}
|
|
1115
1167
|
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
processElementHeadContent(template, normalizedPath);
|
|
1120
|
-
} else {
|
|
1121
|
-
// For non-component templates, use the existing logic
|
|
1122
|
-
processElementHeadContent(element, normalizedPath);
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1125
|
-
});
|
|
1168
|
+
// Single-template entry point (kept for the public interface)
|
|
1169
|
+
function processElementHeadContent(element, normalizedPath) {
|
|
1170
|
+
processAllHeadContent(normalizedPath);
|
|
1126
1171
|
}
|
|
1127
1172
|
|
|
1128
1173
|
// Initialize head content management
|
package/lib/manifest.sw.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
// Build stamps the published version here; unstamped (dev) falls back to the
|
|
18
18
|
// registration URL's `v`, then 'dev'.
|
|
19
|
-
const BUILD_VERSION = '0.5.
|
|
19
|
+
const BUILD_VERSION = '0.5.292';
|
|
20
20
|
const CACHE_PREFIX = 'mnfst-sw:';
|
|
21
21
|
const META_CACHE = CACHE_PREFIX + 'meta';
|
|
22
22
|
// Sized to hold a full precache.json warm-up (PRECACHE_MAX_ENTRIES server-side)
|
|
@@ -724,6 +724,8 @@ class TailwindCompiler {
|
|
|
724
724
|
|
|
725
725
|
TailwindCompiler.prototype.addCriticalBlockingStylesSync = function () {
|
|
726
726
|
if (!this.criticalStyleElement) return;
|
|
727
|
+
// Unlayered guesses would override the shipped sheets' breakpoint rules
|
|
728
|
+
if (this.hasShippedUtilitiesSheet()) return;
|
|
727
729
|
|
|
728
730
|
const syncStart = performance.now();
|
|
729
731
|
|
|
@@ -986,7 +988,7 @@ TailwindCompiler.prototype.addCriticalBlockingStylesSync = function () {
|
|
|
986
988
|
|
|
987
989
|
// Generate synchronous utilities (fallback method)
|
|
988
990
|
TailwindCompiler.prototype.generateSynchronousUtilities = function () {
|
|
989
|
-
if (this.usesStaticPrerenderUtilities) return;
|
|
991
|
+
if (this.usesStaticPrerenderUtilities || this.hasShippedUtilitiesSheet()) return;
|
|
990
992
|
try {
|
|
991
993
|
// Always try to generate, even if cache exists, to catch any new classes
|
|
992
994
|
const hasExistingStyles = this.styleElement.textContent && this.styleElement.textContent.trim();
|
|
@@ -1180,7 +1182,8 @@ TailwindCompiler.prototype.loadAndApplyCache = function () {
|
|
|
1180
1182
|
const cacheToUse = bestMatch || Array.from(this.cache.entries())
|
|
1181
1183
|
.sort((a, b) => b[1].timestamp - a[1].timestamp)[0]?.[1];
|
|
1182
1184
|
|
|
1183
|
-
|
|
1185
|
+
// Pages with shipped utility sheets skip the replay: its bare rules would land after them
|
|
1186
|
+
if (cacheToUse && cacheToUse.css && !this.hasShippedUtilitiesSheet()) {
|
|
1184
1187
|
const applyCacheStart = performance.now();
|
|
1185
1188
|
// The cached CSS may predate the static utilities sheet (or come
|
|
1186
1189
|
// from a visitor without one) — strip anything it already covers
|
|
@@ -1716,7 +1719,8 @@ TailwindCompiler.prototype.fetchThemeContent = async function () {
|
|
|
1716
1719
|
|
|
1717
1720
|
// Order-free identity (fetches land in any order) for "theme unchanged" checks
|
|
1718
1721
|
this.lastThemeKey = Array.from(themeContents).sort().join('\n');
|
|
1719
|
-
|
|
1722
|
+
this.lastThemeCss = Array.from(themeContents).join('\n');
|
|
1723
|
+
return this.lastThemeCss;
|
|
1720
1724
|
};
|
|
1721
1725
|
|
|
1722
1726
|
// Extract CSS variables from CSS text
|
|
@@ -2657,6 +2661,69 @@ TailwindCompiler.prototype.generateUtilitiesFromVars = function (cssText, usedDa
|
|
|
2657
2661
|
}
|
|
2658
2662
|
};
|
|
2659
2663
|
|
|
2664
|
+
// Responsive display ordering: every breakpoint display class sits at 0,2,0, in breakpoint order,
|
|
2665
|
+
// so it beats an unprefixed `hidden` from any sheet and larger breakpoints still win (col md:row lg:hidden)
|
|
2666
|
+
const BUILTIN_DISPLAY_CLASSES = new Set(['row', 'row-wrap', 'col', 'col-wrap', 'trailing']);
|
|
2667
|
+
const BREAKPOINT_PX = { sm: 640, md: 768, lg: 1024, xl: 1280, '2xl': 1536 };
|
|
2668
|
+
const TAILWIND_DISPLAY = {
|
|
2669
|
+
hidden: 'none', block: 'block', 'inline-block': 'inline-block', inline: 'inline', flex: 'flex',
|
|
2670
|
+
'inline-flex': 'inline-flex', grid: 'grid', 'inline-grid': 'inline-grid', contents: 'contents',
|
|
2671
|
+
'flow-root': 'flow-root', 'list-item': 'list-item', table: 'table', 'inline-table': 'inline-table',
|
|
2672
|
+
'table-caption': 'table-caption', 'table-cell': 'table-cell', 'table-column': 'table-column',
|
|
2673
|
+
'table-column-group': 'table-column-group', 'table-footer-group': 'table-footer-group',
|
|
2674
|
+
'table-header-group': 'table-header-group', 'table-row-group': 'table-row-group', 'table-row': 'table-row'
|
|
2675
|
+
};
|
|
2676
|
+
|
|
2677
|
+
// max-* widest first, then min-width ascending (Tailwind's order)
|
|
2678
|
+
function breakpointRank(name) {
|
|
2679
|
+
if (name.startsWith('max-')) return -BREAKPOINT_PX[name.slice(4)];
|
|
2680
|
+
return BREAKPOINT_PX[name];
|
|
2681
|
+
}
|
|
2682
|
+
|
|
2683
|
+
// Top-level display declarations only (nested blocks ignored)
|
|
2684
|
+
function topLevelDisplay(css) {
|
|
2685
|
+
let flat = '', depth = 0;
|
|
2686
|
+
for (const ch of css) {
|
|
2687
|
+
if (ch === '{') depth++;
|
|
2688
|
+
else if (ch === '}') depth = Math.max(0, depth - 1);
|
|
2689
|
+
else if (depth === 0) flat += ch;
|
|
2690
|
+
}
|
|
2691
|
+
const m = flat.match(/(?:^|[\s;])display\s*:\s*([^;!]+)/);
|
|
2692
|
+
return m ? m[1].trim() : null;
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2695
|
+
// Declarations other than display; nested blocks keep the whole rule
|
|
2696
|
+
function withoutTopLevelDisplay(css) {
|
|
2697
|
+
if (css.includes('{')) return css;
|
|
2698
|
+
return css.split(';').map(d => d.trim()).filter(d => d && !/^display\s*:/.test(d)).join('; ');
|
|
2699
|
+
}
|
|
2700
|
+
|
|
2701
|
+
function responsiveDisplayDecl(baseClass, parsed, css) {
|
|
2702
|
+
if (!BUILTIN_DISPLAY_CLASSES.has(baseClass) || parsed.variants.length !== 1) return null;
|
|
2703
|
+
if (!Object.prototype.hasOwnProperty.call(BREAKPOINT_PX, parsed.variants[0].name)) return null;
|
|
2704
|
+
return topLevelDisplay(css);
|
|
2705
|
+
}
|
|
2706
|
+
|
|
2707
|
+
// Used Tailwind display utilities with one breakpoint prefix (md:hidden, max-lg:flex)
|
|
2708
|
+
function tailwindResponsiveDisplay(usedClasses) {
|
|
2709
|
+
const out = [];
|
|
2710
|
+
for (const cls of usedClasses) {
|
|
2711
|
+
const parts = cls.split(':');
|
|
2712
|
+
if (parts.length !== 2 || !Object.prototype.hasOwnProperty.call(TAILWIND_DISPLAY, parts[1])) continue;
|
|
2713
|
+
const bp = parts[0];
|
|
2714
|
+
const max = bp.startsWith('max-');
|
|
2715
|
+
const px = BREAKPOINT_PX[max ? bp.slice(4) : bp];
|
|
2716
|
+
if (!px) continue;
|
|
2717
|
+
out.push({
|
|
2718
|
+
cls,
|
|
2719
|
+
media: max ? `@media (width < ${px}px)` : `@media (min-width: ${px}px)`,
|
|
2720
|
+
rank: breakpointRank(bp),
|
|
2721
|
+
css: TAILWIND_DISPLAY[parts[1]]
|
|
2722
|
+
});
|
|
2723
|
+
}
|
|
2724
|
+
return out;
|
|
2725
|
+
}
|
|
2726
|
+
|
|
2660
2727
|
// Generate custom utilities from discovered custom utility classes
|
|
2661
2728
|
TailwindCompiler.prototype.generateCustomUtilities = function (usedData) {
|
|
2662
2729
|
try {
|
|
@@ -2666,6 +2733,7 @@ TailwindCompiler.prototype.generateCustomUtilities = function (usedData) {
|
|
|
2666
2733
|
const rulesOut = usedData.rulesOut, keysOut = usedData.keysOut;
|
|
2667
2734
|
let slot = null;
|
|
2668
2735
|
const emit = (rule, sub) => { utilities.push(rule); if (rulesOut) { rulesOut.push(rule); keysOut.push(slot.concat(sub)); } };
|
|
2736
|
+
const responsiveDisplay = [];
|
|
2669
2737
|
|
|
2670
2738
|
// Helper to clean up [object Object] from CSS strings
|
|
2671
2739
|
const cleanCssString = (css) => {
|
|
@@ -2837,7 +2905,7 @@ TailwindCompiler.prototype.generateCustomUtilities = function (usedData) {
|
|
|
2837
2905
|
const isImportant = parsed.important;
|
|
2838
2906
|
// Ensure css is a string (handle cases where it might be an object)
|
|
2839
2907
|
const cssString = typeof css === 'string' ? css : (css && typeof css === 'object' && css.css ? css.css : String(css));
|
|
2840
|
-
|
|
2908
|
+
let cssContent = isImportant ?
|
|
2841
2909
|
(cssString.includes(';') ? cssString.replace(/;/g, ' !important;') : cssString + ' !important') :
|
|
2842
2910
|
cssString;
|
|
2843
2911
|
|
|
@@ -2877,6 +2945,16 @@ TailwindCompiler.prototype.generateCustomUtilities = function (usedData) {
|
|
|
2877
2945
|
}
|
|
2878
2946
|
}
|
|
2879
2947
|
|
|
2948
|
+
// Built-in display classes at a breakpoint join the ordered responsive display block
|
|
2949
|
+
const display = !isImportant && !parsed.baseClass.startsWith('!') && typeof selector === 'string' && responsiveDisplayDecl(baseClass, parsed, cssString);
|
|
2950
|
+
if (display) {
|
|
2951
|
+
responsiveDisplay.push({ cls: variantClass, media: mediaQueryRule, rank: breakpointRank(parsed.variants[0].name), css: display });
|
|
2952
|
+
// The rest of the rule (trailing's margin and color) stays a normal variant
|
|
2953
|
+
const rest = withoutTopLevelDisplay(cssString);
|
|
2954
|
+
if (!rest) continue;
|
|
2955
|
+
cssContent = rest;
|
|
2956
|
+
}
|
|
2957
|
+
|
|
2880
2958
|
// Generate the final rule
|
|
2881
2959
|
let rule;
|
|
2882
2960
|
// Ensure cssContent is a string before using it anywhere
|
|
@@ -3080,6 +3158,20 @@ TailwindCompiler.prototype.generateCustomUtilities = function (usedData) {
|
|
|
3080
3158
|
}
|
|
3081
3159
|
}
|
|
3082
3160
|
|
|
3161
|
+
if (responsiveDisplay.length) {
|
|
3162
|
+
const seen = new Set(responsiveDisplay.map(e => e.cls));
|
|
3163
|
+
const all = responsiveDisplay.concat(tailwindResponsiveDisplay(usedClasses).filter(e => !seen.has(e.cls)));
|
|
3164
|
+
all.sort((a, b) => a.rank - b.rank || (a.cls < b.cls ? -1 : a.cls > b.cls ? 1 : 0));
|
|
3165
|
+
for (const e of all) {
|
|
3166
|
+
const own = `.${escapeClassName(e.cls)}`;
|
|
3167
|
+
const rule = `${e.media} { ${own}${own} { display: ${e.css} } }`;
|
|
3168
|
+
if (generatedRules.has(rule)) continue;
|
|
3169
|
+
generatedRules.add(rule);
|
|
3170
|
+
slot = [2, e.rank, 0, 0];
|
|
3171
|
+
emit(rule, 2);
|
|
3172
|
+
}
|
|
3173
|
+
}
|
|
3174
|
+
|
|
3083
3175
|
return utilities.join('\n');
|
|
3084
3176
|
} catch (error) {
|
|
3085
3177
|
console.error('Error generating custom utilities:', error);
|
|
@@ -3321,6 +3413,18 @@ TailwindCompiler.prototype.filterCriticalUtilities = function(criticalText, laye
|
|
|
3321
3413
|
return filteredCritical.join('\n').trim();
|
|
3322
3414
|
};
|
|
3323
3415
|
|
|
3416
|
+
// Nothing left to generate over the shipped sheets: drop boot-time guesses (sync/critical/cache)
|
|
3417
|
+
// so no bare rule sits after the sheets' breakpoint rules
|
|
3418
|
+
TailwindCompiler.prototype.clearStaleUtilityPatches = function () {
|
|
3419
|
+
if (!this.staticUtilitiesCoveredClasses) return;
|
|
3420
|
+
this._applied = null;
|
|
3421
|
+
if (this.styleElement) this.styleElement.textContent = '';
|
|
3422
|
+
if (this.criticalStyleElement && this.criticalStyleElement.parentNode) {
|
|
3423
|
+
this.criticalStyleElement.parentNode.removeChild(this.criticalStyleElement);
|
|
3424
|
+
this.criticalStyleElement = null;
|
|
3425
|
+
}
|
|
3426
|
+
};
|
|
3427
|
+
|
|
3324
3428
|
// Main compilation method
|
|
3325
3429
|
TailwindCompiler.prototype.compile = async function () {
|
|
3326
3430
|
if (this.usesStaticPrerenderUtilities) {
|
|
@@ -3437,6 +3541,8 @@ TailwindCompiler.prototype.compile = async function () {
|
|
|
3437
3541
|
themeHash: themeHash
|
|
3438
3542
|
});
|
|
3439
3543
|
this.savePersistentCache();
|
|
3544
|
+
} else {
|
|
3545
|
+
this.clearStaleUtilityPatches();
|
|
3440
3546
|
}
|
|
3441
3547
|
}
|
|
3442
3548
|
|
|
@@ -3532,6 +3638,8 @@ TailwindCompiler.prototype.compile = async function () {
|
|
|
3532
3638
|
themeHash: themeHash
|
|
3533
3639
|
});
|
|
3534
3640
|
this.savePersistentCache();
|
|
3641
|
+
} else {
|
|
3642
|
+
this.clearStaleUtilityPatches();
|
|
3535
3643
|
}
|
|
3536
3644
|
} else {
|
|
3537
3645
|
this._applied = null; // theme text moved: order keys are stale until the next full write
|
|
@@ -3572,6 +3680,19 @@ TailwindCompiler.prototype.findStaticUtilitiesElement = function () {
|
|
|
3572
3680
|
}
|
|
3573
3681
|
};
|
|
3574
3682
|
|
|
3683
|
+
// Every shipped utilities sheet: the publish bake plus mnfst-render's prerender sheets
|
|
3684
|
+
TailwindCompiler.prototype.findStaticUtilitiesElements = function () {
|
|
3685
|
+
try {
|
|
3686
|
+
return Array.from(document.querySelectorAll('link[rel="stylesheet"][data-mnfst-utilities], style[data-mnfst-utilities], link[rel="stylesheet"][href*="prerender.tailwind.css"], link[rel="stylesheet"][href*="prerender.utilities.css"]'));
|
|
3687
|
+
} catch (e) {
|
|
3688
|
+
return [];
|
|
3689
|
+
}
|
|
3690
|
+
};
|
|
3691
|
+
|
|
3692
|
+
TailwindCompiler.prototype.hasShippedUtilitiesSheet = function () {
|
|
3693
|
+
return this.findStaticUtilitiesElements().length > 0;
|
|
3694
|
+
};
|
|
3695
|
+
|
|
3575
3696
|
// Top-level selector text only (skips declaration bodies, so values like
|
|
3576
3697
|
// `margin: .5rem` can't be mistaken for a `.5` class selector).
|
|
3577
3698
|
TailwindCompiler.prototype.extractSelectorsFromCssText = function (cssText) {
|
|
@@ -3684,39 +3805,44 @@ TailwindCompiler.prototype.readStaticUtilitiesRules = function (el) {
|
|
|
3684
3805
|
// covered) until a read actually succeeds, never cached as "covered".
|
|
3685
3806
|
TailwindCompiler.prototype.detectStaticUtilitiesSheet = function () {
|
|
3686
3807
|
this.staticUtilitiesCoveredClasses = null;
|
|
3687
|
-
const
|
|
3688
|
-
if (!
|
|
3808
|
+
const els = this.findStaticUtilitiesElements();
|
|
3809
|
+
if (!els.length) return Promise.resolve();
|
|
3689
3810
|
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
const covered = this.readStaticUtilitiesRules(el);
|
|
3696
|
-
if (covered) {
|
|
3697
|
-
this.staticUtilitiesCoveredClasses = covered;
|
|
3698
|
-
return Promise.resolve();
|
|
3699
|
-
}
|
|
3811
|
+
const merge = (classes) => {
|
|
3812
|
+
if (!classes) return;
|
|
3813
|
+
if (!this.staticUtilitiesCoveredClasses) this.staticUtilitiesCoveredClasses = new Set();
|
|
3814
|
+
for (const c of classes) this.staticUtilitiesCoveredClasses.add(c);
|
|
3815
|
+
};
|
|
3700
3816
|
|
|
3701
|
-
return
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3817
|
+
return Promise.all(els.map((el) => {
|
|
3818
|
+
if (el.tagName === 'STYLE') {
|
|
3819
|
+
merge(this.classNamesFromCssText(el.textContent || ''));
|
|
3820
|
+
return null;
|
|
3821
|
+
}
|
|
3822
|
+
const covered = this.readStaticUtilitiesRules(el);
|
|
3823
|
+
if (covered) {
|
|
3824
|
+
merge(covered);
|
|
3825
|
+
return null;
|
|
3826
|
+
}
|
|
3827
|
+
return new Promise((resolve) => {
|
|
3828
|
+
let settled = false;
|
|
3829
|
+
const finish = () => {
|
|
3830
|
+
if (settled) return;
|
|
3831
|
+
settled = true;
|
|
3832
|
+
clearTimeout(timer);
|
|
3833
|
+
el.removeEventListener('load', onLoad);
|
|
3834
|
+
el.removeEventListener('error', onError);
|
|
3835
|
+
// Unreadable (e.g. cross-origin without CORS) stays uncounted: fail open
|
|
3836
|
+
merge(this.readStaticUtilitiesRules(el));
|
|
3837
|
+
resolve();
|
|
3838
|
+
};
|
|
3839
|
+
const onLoad = () => finish();
|
|
3840
|
+
const onError = () => finish();
|
|
3841
|
+
const timer = setTimeout(finish, 2000);
|
|
3842
|
+
el.addEventListener('load', onLoad, { once: true });
|
|
3843
|
+
el.addEventListener('error', onError, { once: true });
|
|
3844
|
+
});
|
|
3845
|
+
})).then(() => { });
|
|
3720
3846
|
};
|
|
3721
3847
|
|
|
3722
3848
|
// manifest.json's `utilities.safelist` (exact class names) / `utilities.patterns`
|
|
@@ -3775,7 +3901,55 @@ TailwindCompiler.prototype.hasSafelistEntries = function () {
|
|
|
3775
3901
|
TailwindCompiler.prototype.filterStaticallyCoveredClasses = function (classes) {
|
|
3776
3902
|
const covered = this.staticUtilitiesCoveredClasses;
|
|
3777
3903
|
if ((!covered || covered.size === 0) && !this.hasSafelistEntries()) return classes;
|
|
3778
|
-
|
|
3904
|
+
const left = classes.filter(c => !this.isClassCovered(c));
|
|
3905
|
+
if (!this.bareClassesEmitRules(left.filter(c => !hasClassVariant(c)))) return left;
|
|
3906
|
+
// A bare class emitted last would beat its breakpoint partners in the shipped sheets
|
|
3907
|
+
// (text-3xl over md:text-5xl): re-emit the at-rule variant classes after it
|
|
3908
|
+
const out = new Set(left);
|
|
3909
|
+
const pageClasses = [classes, this.staticClassCache || [], this.dynamicClassCache || []];
|
|
3910
|
+
for (const list of pageClasses) for (const c of list) if (this.isAtRuleVariantClass(c)) out.add(c);
|
|
3911
|
+
return Array.from(out);
|
|
3912
|
+
};
|
|
3913
|
+
|
|
3914
|
+
// Whether any of these bare classes actually generates a rule (author classes like `card` don't)
|
|
3915
|
+
TailwindCompiler.prototype.bareClassesEmitRules = function (bare) {
|
|
3916
|
+
if (!bare.length) return false;
|
|
3917
|
+
const themeCss = this.lastThemeCss;
|
|
3918
|
+
if (!themeCss) return true;
|
|
3919
|
+
try {
|
|
3920
|
+
const probe = { classes: bare, variableSuffixes: [] };
|
|
3921
|
+
return !!((this.generateUtilitiesFromVars(themeCss, probe) || '').trim() || (this.generateCustomUtilities(probe) || '').trim());
|
|
3922
|
+
} catch (e) {
|
|
3923
|
+
return true;
|
|
3924
|
+
}
|
|
3925
|
+
};
|
|
3926
|
+
|
|
3927
|
+
// Variant prefixes outside brackets (md:text-5xl, [&_p]:x — not w-[a:b])
|
|
3928
|
+
function classVariantTokens(cls) {
|
|
3929
|
+
const parts = [];
|
|
3930
|
+
let depth = 0, current = '';
|
|
3931
|
+
for (const ch of cls) {
|
|
3932
|
+
if (ch === '[') depth++;
|
|
3933
|
+
else if (ch === ']') depth--;
|
|
3934
|
+
if (ch === ':' && depth === 0) { parts.push(current); current = ''; }
|
|
3935
|
+
else current += ch;
|
|
3936
|
+
}
|
|
3937
|
+
return parts;
|
|
3938
|
+
}
|
|
3939
|
+
|
|
3940
|
+
function hasClassVariant(cls) {
|
|
3941
|
+
return classVariantTokens(cls).length > 0;
|
|
3942
|
+
}
|
|
3943
|
+
|
|
3944
|
+
// Only media/container/supports conditions: same specificity as the bare class, so order decides
|
|
3945
|
+
TailwindCompiler.prototype.isAtRuleVariantClass = function (cls) {
|
|
3946
|
+
const tokens = classVariantTokens(cls.replace(/^!/, ''));
|
|
3947
|
+
if (!tokens.length) return false;
|
|
3948
|
+
return tokens.every(t => {
|
|
3949
|
+
const sel = this.variants && this.variants[t];
|
|
3950
|
+
if (sel) return sel.startsWith('@');
|
|
3951
|
+
return t.startsWith('@') || /^(min-|max-)?(sm|md|lg|xl|2xl)$/.test(t) || /^(min|max)-\[.+\]$/.test(t);
|
|
3952
|
+
});
|
|
3779
3953
|
};
|
|
3780
3954
|
|
|
3781
3955
|
// The localStorage cache (manifest.utilities.cache.js) stores a full compiled
|
|
@@ -3845,11 +4019,23 @@ TailwindCompiler.prototype.stripCoveredRulesFromCss = function (cssText) {
|
|
|
3845
4019
|
// Only drop a rule once every class it references is covered — a
|
|
3846
4020
|
// mixed selector (`:where(.row, .col)`) stays if either is new.
|
|
3847
4021
|
const isFullyCovered = classes.length > 0 && classes.every(c => this.isClassCovered(c));
|
|
3848
|
-
|
|
4022
|
+
const isVariant = classes.some(c => this.isAtRuleVariantClass(c));
|
|
4023
|
+
if (!isFullyCovered) {
|
|
4024
|
+
out.push(fullRule);
|
|
4025
|
+
if (classes.length > 0 && !classes.some(hasClassVariant)) keptBare = true;
|
|
4026
|
+
} else if (keepVariants && isVariant) {
|
|
4027
|
+
out.push(fullRule);
|
|
4028
|
+
}
|
|
3849
4029
|
}
|
|
3850
4030
|
return out.join('\n');
|
|
3851
4031
|
};
|
|
3852
4032
|
|
|
4033
|
+
// Kept bare rules sit last: keep the variant rules too so they still follow them
|
|
4034
|
+
let keepVariants = false;
|
|
4035
|
+
let keptBare = false;
|
|
4036
|
+
const stripped = strip(cssText);
|
|
4037
|
+
if (!keptBare) return stripped;
|
|
4038
|
+
keepVariants = true;
|
|
3853
4039
|
return strip(cssText);
|
|
3854
4040
|
};
|
|
3855
4041
|
|
|
@@ -1150,7 +1150,8 @@ TailwindCompiler.prototype.fetchThemeContent = async function () {
|
|
|
1150
1150
|
|
|
1151
1151
|
// Order-free identity (fetches land in any order) for "theme unchanged" checks
|
|
1152
1152
|
this.lastThemeKey = Array.from(themeContents).sort().join('\n');
|
|
1153
|
-
|
|
1153
|
+
this.lastThemeCss = Array.from(themeContents).join('\n');
|
|
1154
|
+
return this.lastThemeCss;
|
|
1154
1155
|
};
|
|
1155
1156
|
|
|
1156
1157
|
// Extract CSS variables from CSS text
|
|
@@ -2091,6 +2092,69 @@ TailwindCompiler.prototype.generateUtilitiesFromVars = function (cssText, usedDa
|
|
|
2091
2092
|
}
|
|
2092
2093
|
};
|
|
2093
2094
|
|
|
2095
|
+
// Responsive display ordering: every breakpoint display class sits at 0,2,0, in breakpoint order,
|
|
2096
|
+
// so it beats an unprefixed `hidden` from any sheet and larger breakpoints still win (col md:row lg:hidden)
|
|
2097
|
+
const BUILTIN_DISPLAY_CLASSES = new Set(['row', 'row-wrap', 'col', 'col-wrap', 'trailing']);
|
|
2098
|
+
const BREAKPOINT_PX = { sm: 640, md: 768, lg: 1024, xl: 1280, '2xl': 1536 };
|
|
2099
|
+
const TAILWIND_DISPLAY = {
|
|
2100
|
+
hidden: 'none', block: 'block', 'inline-block': 'inline-block', inline: 'inline', flex: 'flex',
|
|
2101
|
+
'inline-flex': 'inline-flex', grid: 'grid', 'inline-grid': 'inline-grid', contents: 'contents',
|
|
2102
|
+
'flow-root': 'flow-root', 'list-item': 'list-item', table: 'table', 'inline-table': 'inline-table',
|
|
2103
|
+
'table-caption': 'table-caption', 'table-cell': 'table-cell', 'table-column': 'table-column',
|
|
2104
|
+
'table-column-group': 'table-column-group', 'table-footer-group': 'table-footer-group',
|
|
2105
|
+
'table-header-group': 'table-header-group', 'table-row-group': 'table-row-group', 'table-row': 'table-row'
|
|
2106
|
+
};
|
|
2107
|
+
|
|
2108
|
+
// max-* widest first, then min-width ascending (Tailwind's order)
|
|
2109
|
+
function breakpointRank(name) {
|
|
2110
|
+
if (name.startsWith('max-')) return -BREAKPOINT_PX[name.slice(4)];
|
|
2111
|
+
return BREAKPOINT_PX[name];
|
|
2112
|
+
}
|
|
2113
|
+
|
|
2114
|
+
// Top-level display declarations only (nested blocks ignored)
|
|
2115
|
+
function topLevelDisplay(css) {
|
|
2116
|
+
let flat = '', depth = 0;
|
|
2117
|
+
for (const ch of css) {
|
|
2118
|
+
if (ch === '{') depth++;
|
|
2119
|
+
else if (ch === '}') depth = Math.max(0, depth - 1);
|
|
2120
|
+
else if (depth === 0) flat += ch;
|
|
2121
|
+
}
|
|
2122
|
+
const m = flat.match(/(?:^|[\s;])display\s*:\s*([^;!]+)/);
|
|
2123
|
+
return m ? m[1].trim() : null;
|
|
2124
|
+
}
|
|
2125
|
+
|
|
2126
|
+
// Declarations other than display; nested blocks keep the whole rule
|
|
2127
|
+
function withoutTopLevelDisplay(css) {
|
|
2128
|
+
if (css.includes('{')) return css;
|
|
2129
|
+
return css.split(';').map(d => d.trim()).filter(d => d && !/^display\s*:/.test(d)).join('; ');
|
|
2130
|
+
}
|
|
2131
|
+
|
|
2132
|
+
function responsiveDisplayDecl(baseClass, parsed, css) {
|
|
2133
|
+
if (!BUILTIN_DISPLAY_CLASSES.has(baseClass) || parsed.variants.length !== 1) return null;
|
|
2134
|
+
if (!Object.prototype.hasOwnProperty.call(BREAKPOINT_PX, parsed.variants[0].name)) return null;
|
|
2135
|
+
return topLevelDisplay(css);
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2138
|
+
// Used Tailwind display utilities with one breakpoint prefix (md:hidden, max-lg:flex)
|
|
2139
|
+
function tailwindResponsiveDisplay(usedClasses) {
|
|
2140
|
+
const out = [];
|
|
2141
|
+
for (const cls of usedClasses) {
|
|
2142
|
+
const parts = cls.split(':');
|
|
2143
|
+
if (parts.length !== 2 || !Object.prototype.hasOwnProperty.call(TAILWIND_DISPLAY, parts[1])) continue;
|
|
2144
|
+
const bp = parts[0];
|
|
2145
|
+
const max = bp.startsWith('max-');
|
|
2146
|
+
const px = BREAKPOINT_PX[max ? bp.slice(4) : bp];
|
|
2147
|
+
if (!px) continue;
|
|
2148
|
+
out.push({
|
|
2149
|
+
cls,
|
|
2150
|
+
media: max ? `@media (width < ${px}px)` : `@media (min-width: ${px}px)`,
|
|
2151
|
+
rank: breakpointRank(bp),
|
|
2152
|
+
css: TAILWIND_DISPLAY[parts[1]]
|
|
2153
|
+
});
|
|
2154
|
+
}
|
|
2155
|
+
return out;
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2094
2158
|
// Generate custom utilities from discovered custom utility classes
|
|
2095
2159
|
TailwindCompiler.prototype.generateCustomUtilities = function (usedData) {
|
|
2096
2160
|
try {
|
|
@@ -2100,6 +2164,7 @@ TailwindCompiler.prototype.generateCustomUtilities = function (usedData) {
|
|
|
2100
2164
|
const rulesOut = usedData.rulesOut, keysOut = usedData.keysOut;
|
|
2101
2165
|
let slot = null;
|
|
2102
2166
|
const emit = (rule, sub) => { utilities.push(rule); if (rulesOut) { rulesOut.push(rule); keysOut.push(slot.concat(sub)); } };
|
|
2167
|
+
const responsiveDisplay = [];
|
|
2103
2168
|
|
|
2104
2169
|
// Helper to clean up [object Object] from CSS strings
|
|
2105
2170
|
const cleanCssString = (css) => {
|
|
@@ -2271,7 +2336,7 @@ TailwindCompiler.prototype.generateCustomUtilities = function (usedData) {
|
|
|
2271
2336
|
const isImportant = parsed.important;
|
|
2272
2337
|
// Ensure css is a string (handle cases where it might be an object)
|
|
2273
2338
|
const cssString = typeof css === 'string' ? css : (css && typeof css === 'object' && css.css ? css.css : String(css));
|
|
2274
|
-
|
|
2339
|
+
let cssContent = isImportant ?
|
|
2275
2340
|
(cssString.includes(';') ? cssString.replace(/;/g, ' !important;') : cssString + ' !important') :
|
|
2276
2341
|
cssString;
|
|
2277
2342
|
|
|
@@ -2311,6 +2376,16 @@ TailwindCompiler.prototype.generateCustomUtilities = function (usedData) {
|
|
|
2311
2376
|
}
|
|
2312
2377
|
}
|
|
2313
2378
|
|
|
2379
|
+
// Built-in display classes at a breakpoint join the ordered responsive display block
|
|
2380
|
+
const display = !isImportant && !parsed.baseClass.startsWith('!') && typeof selector === 'string' && responsiveDisplayDecl(baseClass, parsed, cssString);
|
|
2381
|
+
if (display) {
|
|
2382
|
+
responsiveDisplay.push({ cls: variantClass, media: mediaQueryRule, rank: breakpointRank(parsed.variants[0].name), css: display });
|
|
2383
|
+
// The rest of the rule (trailing's margin and color) stays a normal variant
|
|
2384
|
+
const rest = withoutTopLevelDisplay(cssString);
|
|
2385
|
+
if (!rest) continue;
|
|
2386
|
+
cssContent = rest;
|
|
2387
|
+
}
|
|
2388
|
+
|
|
2314
2389
|
// Generate the final rule
|
|
2315
2390
|
let rule;
|
|
2316
2391
|
// Ensure cssContent is a string before using it anywhere
|
|
@@ -2514,6 +2589,20 @@ TailwindCompiler.prototype.generateCustomUtilities = function (usedData) {
|
|
|
2514
2589
|
}
|
|
2515
2590
|
}
|
|
2516
2591
|
|
|
2592
|
+
if (responsiveDisplay.length) {
|
|
2593
|
+
const seen = new Set(responsiveDisplay.map(e => e.cls));
|
|
2594
|
+
const all = responsiveDisplay.concat(tailwindResponsiveDisplay(usedClasses).filter(e => !seen.has(e.cls)));
|
|
2595
|
+
all.sort((a, b) => a.rank - b.rank || (a.cls < b.cls ? -1 : a.cls > b.cls ? 1 : 0));
|
|
2596
|
+
for (const e of all) {
|
|
2597
|
+
const own = `.${escapeClassName(e.cls)}`;
|
|
2598
|
+
const rule = `${e.media} { ${own}${own} { display: ${e.css} } }`;
|
|
2599
|
+
if (generatedRules.has(rule)) continue;
|
|
2600
|
+
generatedRules.add(rule);
|
|
2601
|
+
slot = [2, e.rank, 0, 0];
|
|
2602
|
+
emit(rule, 2);
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
2605
|
+
|
|
2517
2606
|
return utilities.join('\n');
|
|
2518
2607
|
} catch (error) {
|
|
2519
2608
|
console.error('Error generating custom utilities:', error);
|
|
@@ -2755,6 +2844,18 @@ TailwindCompiler.prototype.filterCriticalUtilities = function(criticalText, laye
|
|
|
2755
2844
|
return filteredCritical.join('\n').trim();
|
|
2756
2845
|
};
|
|
2757
2846
|
|
|
2847
|
+
// Nothing left to generate over the shipped sheets: drop boot-time guesses (sync/critical/cache)
|
|
2848
|
+
// so no bare rule sits after the sheets' breakpoint rules
|
|
2849
|
+
TailwindCompiler.prototype.clearStaleUtilityPatches = function () {
|
|
2850
|
+
if (!this.staticUtilitiesCoveredClasses) return;
|
|
2851
|
+
this._applied = null;
|
|
2852
|
+
if (this.styleElement) this.styleElement.textContent = '';
|
|
2853
|
+
if (this.criticalStyleElement && this.criticalStyleElement.parentNode) {
|
|
2854
|
+
this.criticalStyleElement.parentNode.removeChild(this.criticalStyleElement);
|
|
2855
|
+
this.criticalStyleElement = null;
|
|
2856
|
+
}
|
|
2857
|
+
};
|
|
2858
|
+
|
|
2758
2859
|
// Main compilation method
|
|
2759
2860
|
TailwindCompiler.prototype.compile = async function () {
|
|
2760
2861
|
if (this.usesStaticPrerenderUtilities) {
|
|
@@ -2871,6 +2972,8 @@ TailwindCompiler.prototype.compile = async function () {
|
|
|
2871
2972
|
themeHash: themeHash
|
|
2872
2973
|
});
|
|
2873
2974
|
this.savePersistentCache();
|
|
2975
|
+
} else {
|
|
2976
|
+
this.clearStaleUtilityPatches();
|
|
2874
2977
|
}
|
|
2875
2978
|
}
|
|
2876
2979
|
|
|
@@ -2966,6 +3069,8 @@ TailwindCompiler.prototype.compile = async function () {
|
|
|
2966
3069
|
themeHash: themeHash
|
|
2967
3070
|
});
|
|
2968
3071
|
this.savePersistentCache();
|
|
3072
|
+
} else {
|
|
3073
|
+
this.clearStaleUtilityPatches();
|
|
2969
3074
|
}
|
|
2970
3075
|
} else {
|
|
2971
3076
|
this._applied = null; // theme text moved: order keys are stale until the next full write
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mnfst",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.292",
|
|
4
4
|
"private": false,
|
|
5
5
|
"workspaces": [
|
|
6
6
|
"templates/starter",
|
|
@@ -55,6 +55,10 @@
|
|
|
55
55
|
"test:e2e:data-paging": "node tests/e2e/data-paging.e2e.mjs",
|
|
56
56
|
"test:e2e:modules": "node tests/e2e/modules.e2e.mjs",
|
|
57
57
|
"test:e2e:router-xshow": "node tests/e2e/router-xshow.e2e.mjs",
|
|
58
|
+
"test:e2e:components-router-race": "node tests/e2e/components-router-race.e2e.mjs",
|
|
59
|
+
"test:e2e:route-head": "node tests/e2e/route-head.e2e.mjs",
|
|
60
|
+
"test:e2e:prerender-patch": "node tests/e2e/utilities-prerender-patch.e2e.mjs",
|
|
61
|
+
"test:e2e:hidden-responsive": "node tests/e2e/utilities-hidden-responsive.e2e.mjs",
|
|
58
62
|
"lint": "echo 'No linting configured'",
|
|
59
63
|
"release:docs": "npm test && node scripts/release-bump.mjs packages/docs && cd packages/docs && npm publish --auth-type=web",
|
|
60
64
|
"release:check": "node scripts/release-check.mjs"
|