mnfst 0.5.38 → 0.5.39
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 +46 -1
- package/package.json +2 -2
|
@@ -411,9 +411,50 @@ function createVariantGroups() {
|
|
|
411
411
|
|
|
412
412
|
/* Manifest Utilities */
|
|
413
413
|
|
|
414
|
+
/** True when prerender wrote utilities to prerender.utilities.css — skip runtime #utility-styles generation. */
|
|
415
|
+
function manifestPageUsesStaticPrerenderUtilities() {
|
|
416
|
+
if (typeof document === 'undefined') return false;
|
|
417
|
+
try {
|
|
418
|
+
if (!document.querySelector('meta[name="manifest:prerendered"][content="1"]')) return false;
|
|
419
|
+
for (const link of document.querySelectorAll('link[rel="stylesheet"][href]')) {
|
|
420
|
+
if ((link.getAttribute('href') || '').toLowerCase().includes('prerender.utilities.css')) {
|
|
421
|
+
return true;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
} catch (e) {
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
return false;
|
|
428
|
+
}
|
|
429
|
+
|
|
414
430
|
// Browser runtime compiler
|
|
415
431
|
class TailwindCompiler {
|
|
416
432
|
constructor(options = {}) {
|
|
433
|
+
this.usesStaticPrerenderUtilities = manifestPageUsesStaticPrerenderUtilities();
|
|
434
|
+
|
|
435
|
+
// Prerender already emitted utility CSS; do not inject duplicate #utility-styles / observers.
|
|
436
|
+
if (this.usesStaticPrerenderUtilities) {
|
|
437
|
+
this.debug = options.debug === true;
|
|
438
|
+
this.startTime = performance.now();
|
|
439
|
+
this.options = {
|
|
440
|
+
rootSelector: options.rootSelector || ':root',
|
|
441
|
+
themeSelector: options.themeSelector || '@theme',
|
|
442
|
+
debounceTime: options.debounceTime || 50,
|
|
443
|
+
maxCacheAge: options.maxCacheAge || 24 * 60 * 60 * 1000,
|
|
444
|
+
debug: options.debug !== false,
|
|
445
|
+
...options
|
|
446
|
+
};
|
|
447
|
+
this.criticalStyleElement = null;
|
|
448
|
+
this.styleElement = null;
|
|
449
|
+
this.tailwindLink = null;
|
|
450
|
+
this.observer = null;
|
|
451
|
+
this.isCompiling = false;
|
|
452
|
+
this.compileTimeout = null;
|
|
453
|
+
this.cache = new Map();
|
|
454
|
+
this.hasInitialized = true;
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
|
|
417
458
|
this.debug = options.debug === true;
|
|
418
459
|
this.startTime = performance.now();
|
|
419
460
|
|
|
@@ -924,6 +965,7 @@ TailwindCompiler.prototype.addCriticalBlockingStylesSync = function () {
|
|
|
924
965
|
|
|
925
966
|
// Generate synchronous utilities (fallback method)
|
|
926
967
|
TailwindCompiler.prototype.generateSynchronousUtilities = function () {
|
|
968
|
+
if (this.usesStaticPrerenderUtilities) return;
|
|
927
969
|
try {
|
|
928
970
|
// Always try to generate, even if cache exists, to catch any new classes
|
|
929
971
|
const hasExistingStyles = this.styleElement.textContent && this.styleElement.textContent.trim();
|
|
@@ -2975,6 +3017,8 @@ TailwindCompiler.prototype.filterCriticalUtilities = function(criticalText, laye
|
|
|
2975
3017
|
|
|
2976
3018
|
// Main compilation method
|
|
2977
3019
|
TailwindCompiler.prototype.compile = async function () {
|
|
3020
|
+
if (this.usesStaticPrerenderUtilities) return;
|
|
3021
|
+
|
|
2978
3022
|
const compileStart = performance.now();
|
|
2979
3023
|
|
|
2980
3024
|
try {
|
|
@@ -3311,6 +3355,7 @@ TailwindCompiler.prototype.setupComponentLoadListener = function () {
|
|
|
3311
3355
|
|
|
3312
3356
|
// Start processing with initial compilation and observer setup
|
|
3313
3357
|
TailwindCompiler.prototype.startProcessing = async function () {
|
|
3358
|
+
if (this.usesStaticPrerenderUtilities) return;
|
|
3314
3359
|
try {
|
|
3315
3360
|
// Start initial compilation immediately
|
|
3316
3361
|
const initialCompilation = this.compile();
|
|
@@ -3397,7 +3442,7 @@ if ('PerformanceObserver' in window) {
|
|
|
3397
3442
|
|
|
3398
3443
|
// Also handle DOMContentLoaded for any elements that might be added later
|
|
3399
3444
|
document.addEventListener('DOMContentLoaded', () => {
|
|
3400
|
-
if (!compiler.isCompiling) {
|
|
3445
|
+
if (!compiler.usesStaticPrerenderUtilities && !compiler.isCompiling) {
|
|
3401
3446
|
compiler.compile();
|
|
3402
3447
|
}
|
|
3403
3448
|
});
|
package/package.json
CHANGED