mnfst 0.5.21 → 0.5.22
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.utilities.js +42 -0
- package/package.json +1 -1
|
@@ -489,6 +489,7 @@ class TailwindCompiler {
|
|
|
489
489
|
this.styleElement = document.createElement('style');
|
|
490
490
|
this.styleElement.id = 'utility-styles';
|
|
491
491
|
document.head.appendChild(this.styleElement);
|
|
492
|
+
this.setupUtilityStylesOrderObserver();
|
|
492
493
|
|
|
493
494
|
// Initialize properties
|
|
494
495
|
this.tailwindLink = null;
|
|
@@ -1028,6 +1029,7 @@ TailwindCompiler.prototype.generateSynchronousUtilities = function () {
|
|
|
1028
1029
|
} else {
|
|
1029
1030
|
this.styleElement.textContent = finalCss;
|
|
1030
1031
|
}
|
|
1032
|
+
this.ensureUtilityStylesLast();
|
|
1031
1033
|
|
|
1032
1034
|
// Clear critical styles once we have generated utilities
|
|
1033
1035
|
if (this.criticalStyleElement && generated.trim()) {
|
|
@@ -1116,6 +1118,8 @@ TailwindCompiler.prototype.loadAndApplyCache = function () {
|
|
|
1116
1118
|
if (cacheToUse && cacheToUse.css) {
|
|
1117
1119
|
const applyCacheStart = performance.now();
|
|
1118
1120
|
this.styleElement.textContent = cacheToUse.css;
|
|
1121
|
+
this.ensureUtilityStylesLast();
|
|
1122
|
+
this.scheduleEnsureUtilityStylesLast();
|
|
1119
1123
|
this.lastThemeHash = cacheToUse.themeHash;
|
|
1120
1124
|
|
|
1121
1125
|
// Also apply cache to critical style element
|
|
@@ -1192,6 +1196,38 @@ TailwindCompiler.prototype.cleanupCache = function () {
|
|
|
1192
1196
|
// Helper methods
|
|
1193
1197
|
// Utility functions for extracting, parsing, and processing CSS and classes
|
|
1194
1198
|
|
|
1199
|
+
// Ensure #utility-styles is last in head so our responsive/variant rules win over Tailwind and any later-injected styles
|
|
1200
|
+
TailwindCompiler.prototype.ensureUtilityStylesLast = function () {
|
|
1201
|
+
if (this.styleElement && this.styleElement.parentNode && document.head.lastElementChild !== this.styleElement) {
|
|
1202
|
+
document.head.appendChild(this.styleElement);
|
|
1203
|
+
}
|
|
1204
|
+
};
|
|
1205
|
+
|
|
1206
|
+
// When any element is added to head after ours, move #utility-styles to end. Handles CDN load order (e.g. Tailwind injecting after we run).
|
|
1207
|
+
TailwindCompiler.prototype.setupUtilityStylesOrderObserver = function () {
|
|
1208
|
+
if (!document.head || !this.styleElement) return;
|
|
1209
|
+
const self = this;
|
|
1210
|
+
const observer = new MutationObserver((mutations) => {
|
|
1211
|
+
for (const mutation of mutations) {
|
|
1212
|
+
if (mutation.type !== 'childList' || !mutation.addedNodes.length) continue;
|
|
1213
|
+
for (const node of mutation.addedNodes) {
|
|
1214
|
+
if (node.nodeType !== Node.ELEMENT_NODE || node === self.styleElement) continue;
|
|
1215
|
+
self.ensureUtilityStylesLast();
|
|
1216
|
+
break;
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
});
|
|
1220
|
+
observer.observe(document.head, { childList: true, subtree: false });
|
|
1221
|
+
};
|
|
1222
|
+
|
|
1223
|
+
// Schedule ensureUtilityStylesLast at 0ms, 100ms, 500ms so we win when Tailwind (or other scripts) inject styles later (e.g. CDN).
|
|
1224
|
+
TailwindCompiler.prototype.scheduleEnsureUtilityStylesLast = function () {
|
|
1225
|
+
const self = this;
|
|
1226
|
+
[0, 100, 500].forEach((ms) => {
|
|
1227
|
+
setTimeout(() => self.ensureUtilityStylesLast(), ms);
|
|
1228
|
+
});
|
|
1229
|
+
};
|
|
1230
|
+
|
|
1195
1231
|
// Discover CSS files from stylesheets and imports
|
|
1196
1232
|
TailwindCompiler.prototype.discoverCssFiles = function () {
|
|
1197
1233
|
try {
|
|
@@ -2981,6 +3017,8 @@ TailwindCompiler.prototype.compile = async function () {
|
|
|
2981
3017
|
const finalCss = `@layer utilities {\n${allUtilities}\n}`;
|
|
2982
3018
|
|
|
2983
3019
|
this.styleElement.textContent = finalCss;
|
|
3020
|
+
this.ensureUtilityStylesLast();
|
|
3021
|
+
this.scheduleEnsureUtilityStylesLast();
|
|
2984
3022
|
|
|
2985
3023
|
// Remove critical style element entirely after compilation
|
|
2986
3024
|
// Use requestAnimationFrame to ensure styles are painted before removing
|
|
@@ -2991,6 +3029,7 @@ TailwindCompiler.prototype.compile = async function () {
|
|
|
2991
3029
|
this.criticalStyleElement.parentNode.removeChild(this.criticalStyleElement);
|
|
2992
3030
|
this.criticalStyleElement = null;
|
|
2993
3031
|
}
|
|
3032
|
+
this.ensureUtilityStylesLast();
|
|
2994
3033
|
});
|
|
2995
3034
|
});
|
|
2996
3035
|
this.lastClassesHash = staticUsedData.classes.sort().join(',');
|
|
@@ -3060,6 +3099,8 @@ TailwindCompiler.prototype.compile = async function () {
|
|
|
3060
3099
|
const finalCss = `@layer utilities {\n${allUtilities}\n}`;
|
|
3061
3100
|
|
|
3062
3101
|
this.styleElement.textContent = finalCss;
|
|
3102
|
+
this.ensureUtilityStylesLast();
|
|
3103
|
+
this.scheduleEnsureUtilityStylesLast();
|
|
3063
3104
|
|
|
3064
3105
|
// Remove critical style element entirely after compilation
|
|
3065
3106
|
// Use requestAnimationFrame to ensure styles are painted before removing
|
|
@@ -3070,6 +3111,7 @@ TailwindCompiler.prototype.compile = async function () {
|
|
|
3070
3111
|
this.criticalStyleElement.parentNode.removeChild(this.criticalStyleElement);
|
|
3071
3112
|
this.criticalStyleElement = null;
|
|
3072
3113
|
}
|
|
3114
|
+
this.ensureUtilityStylesLast();
|
|
3073
3115
|
});
|
|
3074
3116
|
});
|
|
3075
3117
|
this.lastClassesHash = dynamicClassesHash;
|