mnfst 0.5.37 → 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.
@@ -2369,6 +2369,9 @@ function getLoadingBranch(depth) {
2369
2369
  const d = depth == null ? 0 : Math.min(Math.max(0, depth), MAX_LOADING_BRANCH_DEPTH);
2370
2370
  if (loadingBranchByDepth[d]) return loadingBranchByDepth[d];
2371
2371
  const emptyStr = function () { return ''; };
2372
+ const emptyArray = [];
2373
+ const attachArrayMethods = window.ManifestDataProxies?.attachArrayMethods;
2374
+ const arrayWithMethods = attachArrayMethods ? attachArrayMethods(emptyArray, '', null) : emptyArray;
2372
2375
  const nextDepth = d + 1;
2373
2376
  const getReturnForStringKey = () =>
2374
2377
  nextDepth <= MAX_LOADING_BRANCH_DEPTH ? getLoadingBranch(nextDepth) : '';
@@ -2380,6 +2383,12 @@ function getLoadingBranch(depth) {
2380
2383
  if (key === '$route' || key === '$search' || key === '$query') {
2381
2384
  return function () { return getLoadingBranch(nextDepth <= MAX_LOADING_BRANCH_DEPTH ? nextDepth : MAX_LOADING_BRANCH_DEPTH); };
2382
2385
  }
2386
+ if (typeof key === 'string' && typeof Array.prototype[key] === 'function') {
2387
+ if (key in arrayWithMethods && typeof arrayWithMethods[key] === 'function') {
2388
+ return arrayWithMethods[key].bind(arrayWithMethods);
2389
+ }
2390
+ return Array.prototype[key].bind(arrayWithMethods);
2391
+ }
2383
2392
  if (key === 'length') return 0;
2384
2393
  if (typeof key === 'string') return getReturnForStringKey();
2385
2394
  if (typeof key === 'symbol') return undefined;
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnfst",
3
- "version": "0.5.37",
3
+ "version": "0.5.39",
4
4
  "private": false,
5
5
  "workspaces": [
6
6
  "templates/starter",
@@ -62,4 +62,4 @@
62
62
  "bugs": {
63
63
  "url": "https://github.com/andrewmatlock/manifest/issues"
64
64
  }
65
- }
65
+ }