mnfst 0.5.323 → 0.5.324
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.data.js +1 -1
- package/lib/manifest.data.min.js +1 -1
- package/lib/manifest.integrity.json +10 -10
- package/lib/manifest.js +2 -2
- package/lib/manifest.min.js +1 -1
- package/lib/manifest.modules.integrity.json +7 -7
- package/lib/manifest.sw.js +1 -1
- package/lib/manifest.sw.min.js +1 -1
- package/lib/manifest.utilities.js +102 -56
- package/lib/manifest.utilities.min.js +1 -1
- package/lib/manifest.utilities.min.js.map +1 -1
- package/lib/manifest.utilities.node.mjs +77 -16
- package/package.json +2 -1
|
@@ -1158,7 +1158,7 @@ TailwindCompiler.prototype.loadAndApplyCache = function () {
|
|
|
1158
1158
|
if (currentClasses.size > 0) {
|
|
1159
1159
|
for (const [key, value] of this.cache.entries()) {
|
|
1160
1160
|
// Extract classes from cache key (format: "class1,class2-themeHash")
|
|
1161
|
-
//
|
|
1161
|
+
// The theme hash has no '-': split on the last one
|
|
1162
1162
|
const lastDashIndex = key.lastIndexOf('-');
|
|
1163
1163
|
const classesPart = lastDashIndex > 0 ? key.substring(0, lastDashIndex) : key;
|
|
1164
1164
|
const cachedClasses = classesPart ? classesPart.split(',') : [];
|
|
@@ -1287,8 +1287,13 @@ TailwindCompiler.prototype.loadPersistentCache = function () {
|
|
|
1287
1287
|
|
|
1288
1288
|
// Generate a hash of the theme variables to detect changes
|
|
1289
1289
|
TailwindCompiler.prototype.generateThemeHash = function (themeCss) {
|
|
1290
|
-
//
|
|
1291
|
-
|
|
1290
|
+
// FNV-1a over the whole theme text
|
|
1291
|
+
let h = 0x811c9dc5;
|
|
1292
|
+
for (let i = 0; i < themeCss.length; i++) {
|
|
1293
|
+
h ^= themeCss.charCodeAt(i);
|
|
1294
|
+
h = Math.imul(h, 0x01000193);
|
|
1295
|
+
}
|
|
1296
|
+
return (h >>> 0).toString(36) + themeCss.length.toString(36);
|
|
1292
1297
|
};
|
|
1293
1298
|
|
|
1294
1299
|
// Clean up old cache entries
|
|
@@ -1319,12 +1324,20 @@ TailwindCompiler.prototype.cleanupCache = function () {
|
|
|
1319
1324
|
|
|
1320
1325
|
// Ensure #manifest-styles is last in head so our responsive/variant rules win over Tailwind and any later-injected styles
|
|
1321
1326
|
TailwindCompiler.prototype.ensureUtilityStylesLast = function () {
|
|
1322
|
-
if (this.styleElement
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1327
|
+
if (!this.styleElement || !this.styleElement.parentNode) return;
|
|
1328
|
+
// Only a stylesheet after ours can out-order it (scripts and meta tags cannot)
|
|
1329
|
+
let later = this.styleElement.nextElementSibling;
|
|
1330
|
+
while (later && !isStylesheetNode(later)) later = later.nextElementSibling;
|
|
1331
|
+
if (!later && this.styleElement.parentNode === document.head) return;
|
|
1332
|
+
document.head.appendChild(this.styleElement);
|
|
1333
|
+
if (this.resyncUtilitiesText) this.resyncUtilitiesText();
|
|
1326
1334
|
};
|
|
1327
1335
|
|
|
1336
|
+
// Any <link> counts: a preload can become a stylesheet after insertion
|
|
1337
|
+
function isStylesheetNode(node) {
|
|
1338
|
+
return node.localName === 'style' || node.localName === 'link';
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1328
1341
|
// When any element is added to head after ours, move #manifest-styles to end. Handles CDN load order (e.g. Tailwind injecting after we run).
|
|
1329
1342
|
TailwindCompiler.prototype.setupUtilityStylesOrderObserver = function () {
|
|
1330
1343
|
if (!document.head || !this.styleElement) return;
|
|
@@ -1334,6 +1347,7 @@ TailwindCompiler.prototype.setupUtilityStylesOrderObserver = function () {
|
|
|
1334
1347
|
if (mutation.type !== 'childList' || !mutation.addedNodes.length) continue;
|
|
1335
1348
|
for (const node of mutation.addedNodes) {
|
|
1336
1349
|
if (node.nodeType !== Node.ELEMENT_NODE || node === self.styleElement) continue;
|
|
1350
|
+
if (!isStylesheetNode(node)) continue;
|
|
1337
1351
|
self.ensureUtilityStylesLast();
|
|
1338
1352
|
break;
|
|
1339
1353
|
}
|
|
@@ -1438,7 +1452,10 @@ TailwindCompiler.prototype.scanStaticClasses = async function () {
|
|
|
1438
1452
|
|
|
1439
1453
|
const componentUrls = [];
|
|
1440
1454
|
|
|
1441
|
-
|
|
1455
|
+
// A complete shipped sheet was baked from these same files: nothing to learn by fetching them
|
|
1456
|
+
const baked = !!document.querySelector('[data-mnfst-utilities][data-mnfst-utilities-complete]');
|
|
1457
|
+
|
|
1458
|
+
if (!baked && registry && registry.manifest) {
|
|
1442
1459
|
// Get all component paths from manifest
|
|
1443
1460
|
const allComponents = [
|
|
1444
1461
|
...(registry.manifest.preloadedComponents || []),
|
|
@@ -1652,6 +1669,12 @@ TailwindCompiler.prototype.getUsedClasses = function () {
|
|
|
1652
1669
|
}
|
|
1653
1670
|
};
|
|
1654
1671
|
|
|
1672
|
+
function isDevHostname(host) {
|
|
1673
|
+
const h = String(host || '').toLowerCase();
|
|
1674
|
+
return !h || h === 'localhost' || h === '127.0.0.1' || h === '[::1]' || h === '::1' || h === '0.0.0.0' ||
|
|
1675
|
+
h.endsWith('.localhost') || h.endsWith('.local') || h.endsWith('.test');
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1655
1678
|
// Fetch theme content from CSS files
|
|
1656
1679
|
TailwindCompiler.prototype.fetchThemeContent = async function () {
|
|
1657
1680
|
const themeContents = new Set();
|
|
@@ -1695,25 +1718,33 @@ TailwindCompiler.prototype.fetchThemeContent = async function () {
|
|
|
1695
1718
|
cacheTime = this.hasScannedStatic ? 5000 : 30000;
|
|
1696
1719
|
}
|
|
1697
1720
|
|
|
1698
|
-
|
|
1721
|
+
// Off a dev host a stylesheet never changes under a loaded page: fetch once, from the HTTP cache
|
|
1722
|
+
const dev = isDevHostname(location.hostname);
|
|
1723
|
+
if (cached && (!dev || (now - cached.timestamp) < cacheTime)) {
|
|
1699
1724
|
content = cached.content;
|
|
1700
1725
|
needsFetch = false;
|
|
1701
1726
|
}
|
|
1702
1727
|
|
|
1703
1728
|
if (needsFetch) {
|
|
1704
|
-
//
|
|
1705
|
-
const
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
const
|
|
1729
|
+
// Dev: cache-bust so an edited stylesheet is re-read
|
|
1730
|
+
const url = dev ? `${source}${source.includes('?') ? '&' : '?'}t=${Math.floor(now / 1000)}` : source;
|
|
1731
|
+
|
|
1732
|
+
// Overlapping compiles share one request
|
|
1733
|
+
const inflight = this._cssInflight || (this._cssInflight = new Map());
|
|
1734
|
+
let pending = inflight.get(url);
|
|
1735
|
+
if (!pending) {
|
|
1736
|
+
pending = fetch(url).then(response => (response.ok ? response.text() : null));
|
|
1737
|
+
inflight.set(url, pending);
|
|
1738
|
+
const done = () => inflight.delete(url);
|
|
1739
|
+
pending.then(done, done);
|
|
1740
|
+
}
|
|
1741
|
+
content = await pending;
|
|
1709
1742
|
|
|
1710
|
-
if (
|
|
1743
|
+
if (content === null) {
|
|
1711
1744
|
console.warn('Failed to fetch stylesheet:', url);
|
|
1712
1745
|
return;
|
|
1713
1746
|
}
|
|
1714
1747
|
|
|
1715
|
-
content = await response.text();
|
|
1716
|
-
|
|
1717
1748
|
// Cache the content with timestamp
|
|
1718
1749
|
this.cssContentCache.set(cacheKey, {
|
|
1719
1750
|
content: content,
|
|
@@ -3373,6 +3404,9 @@ TailwindCompiler.prototype.compileDelta = function (themeCss) {
|
|
|
3373
3404
|
const applied = this._applied;
|
|
3374
3405
|
const candidates = [];
|
|
3375
3406
|
for (const cls of this.dynamicClassCache) if (!applied.classes.has(cls)) candidates.push(cls);
|
|
3407
|
+
// A shipped at-rule variant arriving beside our own rules may need re-emitting after a bare partner: full regen decides
|
|
3408
|
+
if (this.staticUtilitiesCoveredClasses && applied.entries.length &&
|
|
3409
|
+
candidates.some(c => this.isAtRuleVariantClass(c) && this.isClassCovered(c))) return false;
|
|
3376
3410
|
const classes = this.filterStaticallyCoveredClasses(candidates);
|
|
3377
3411
|
// Tailwind display classes at a breakpoint join the display block, which only a full regen emits
|
|
3378
3412
|
if (tailwindResponsiveDisplay(classes).length) return false;
|
|
@@ -3515,6 +3549,28 @@ TailwindCompiler.prototype.clearStaleUtilityPatches = function () {
|
|
|
3515
3549
|
}
|
|
3516
3550
|
};
|
|
3517
3551
|
|
|
3552
|
+
// Boot-time guesses are unlayered and beat every layered variant: drop them once real rules cover the page
|
|
3553
|
+
TailwindCompiler.prototype.dropCriticalStyles = function () {
|
|
3554
|
+
if (!this.criticalStyleElement) return;
|
|
3555
|
+
requestAnimationFrame(() => requestAnimationFrame(() => {
|
|
3556
|
+
if (this.criticalStyleElement && this.criticalStyleElement.parentNode) {
|
|
3557
|
+
this.criticalStyleElement.parentNode.removeChild(this.criticalStyleElement);
|
|
3558
|
+
this.criticalStyleElement = null;
|
|
3559
|
+
}
|
|
3560
|
+
this.ensureUtilityStylesLast();
|
|
3561
|
+
}));
|
|
3562
|
+
};
|
|
3563
|
+
|
|
3564
|
+
// Nothing to generate yet: arm delta on an empty layer so later classes insert, not regenerate
|
|
3565
|
+
TailwindCompiler.prototype.armEmptyDelta = function (themeCss, classes) {
|
|
3566
|
+
if (!this.styleElement) return;
|
|
3567
|
+
// A replayed cache sheet stays until the next full write replaces it
|
|
3568
|
+
if (!this.staticUtilitiesCoveredClasses && this.styleElement.textContent.trim()) return;
|
|
3569
|
+
this._applied = null;
|
|
3570
|
+
this.styleElement.textContent = '@layer utilities {\n}';
|
|
3571
|
+
this.recordAppliedUtilities([], themeCss, classes);
|
|
3572
|
+
};
|
|
3573
|
+
|
|
3518
3574
|
// Main compilation method
|
|
3519
3575
|
TailwindCompiler.prototype.compile = async function () {
|
|
3520
3576
|
if (this.usesStaticPrerenderUtilities) {
|
|
@@ -3593,11 +3649,13 @@ TailwindCompiler.prototype.compile = async function () {
|
|
|
3593
3649
|
}
|
|
3594
3650
|
}
|
|
3595
3651
|
|
|
3596
|
-
const
|
|
3652
|
+
const staticEntries = this.generateOrderedUtilities(themeCss, staticUsedData);
|
|
3653
|
+
const allUtilities = this.orderedUtilitiesCss(staticEntries);
|
|
3597
3654
|
|
|
3598
3655
|
if (allUtilities) {
|
|
3599
3656
|
const finalCss = `@layer utilities {\n${allUtilities}\n}`;
|
|
3600
3657
|
|
|
3658
|
+
this._applied = null; // a move below must not write the previous delta state back
|
|
3601
3659
|
this.styleElement.textContent = finalCss;
|
|
3602
3660
|
this.ensureUtilityStylesLast();
|
|
3603
3661
|
this.scheduleEnsureUtilityStylesLast();
|
|
@@ -3615,6 +3673,7 @@ TailwindCompiler.prototype.compile = async function () {
|
|
|
3615
3673
|
});
|
|
3616
3674
|
});
|
|
3617
3675
|
this.lastClassesHash = staticUsedData.classes.sort().join(',');
|
|
3676
|
+
this.recordAppliedUtilities(staticEntries, themeCss, []);
|
|
3618
3677
|
|
|
3619
3678
|
// Save to cache for next page load
|
|
3620
3679
|
const themeHash = this.generateThemeHash(themeCss);
|
|
@@ -3627,6 +3686,7 @@ TailwindCompiler.prototype.compile = async function () {
|
|
|
3627
3686
|
this.savePersistentCache();
|
|
3628
3687
|
} else {
|
|
3629
3688
|
this.clearStaleUtilityPatches();
|
|
3689
|
+
this.armEmptyDelta(themeCss, []);
|
|
3630
3690
|
}
|
|
3631
3691
|
}
|
|
3632
3692
|
|
|
@@ -3639,7 +3699,10 @@ TailwindCompiler.prototype.compile = async function () {
|
|
|
3639
3699
|
let prefetchedTheme = null;
|
|
3640
3700
|
if (this.canCompileDelta()) {
|
|
3641
3701
|
prefetchedTheme = await this.fetchThemeContent();
|
|
3642
|
-
if (prefetchedTheme && this.lastThemeKey === this._applied.themeKey && this.compileDelta(this._applied.themeCss))
|
|
3702
|
+
if (prefetchedTheme && this.lastThemeKey === this._applied.themeKey && this.compileDelta(this._applied.themeCss)) {
|
|
3703
|
+
this.dropCriticalStyles();
|
|
3704
|
+
return;
|
|
3705
|
+
}
|
|
3643
3706
|
}
|
|
3644
3707
|
|
|
3645
3708
|
// For subsequent compilations, check for new dynamic classes
|
|
@@ -3684,6 +3747,7 @@ TailwindCompiler.prototype.compile = async function () {
|
|
|
3684
3747
|
if (allUtilities) {
|
|
3685
3748
|
const finalCss = `@layer utilities {\n${allUtilities}\n}`;
|
|
3686
3749
|
|
|
3750
|
+
this._applied = null; // a move below must not write the previous delta state back
|
|
3687
3751
|
this.styleElement.textContent = finalCss;
|
|
3688
3752
|
this.ensureUtilityStylesLast();
|
|
3689
3753
|
this.scheduleEnsureUtilityStylesLast();
|
|
@@ -3716,6 +3780,8 @@ TailwindCompiler.prototype.compile = async function () {
|
|
|
3716
3780
|
this.savePersistentCache();
|
|
3717
3781
|
} else {
|
|
3718
3782
|
this.clearStaleUtilityPatches();
|
|
3783
|
+
this.lastClassesHash = dynamicClassesHash;
|
|
3784
|
+
this.armEmptyDelta(themeCss, dynamicClasses);
|
|
3719
3785
|
}
|
|
3720
3786
|
} else {
|
|
3721
3787
|
this._applied = null; // theme text moved: order keys are stale until the next full write
|
|
@@ -4213,7 +4279,7 @@ TailwindCompiler.prototype.setupComponentLoadListener = function () {
|
|
|
4213
4279
|
// compile() queues a retry when busy; dropping the call here lost classes seen mid-compile
|
|
4214
4280
|
const debouncedCompile = this.debounce(() => this.compile(), this.options.debounceTime);
|
|
4215
4281
|
|
|
4216
|
-
// Recompile when components load/process
|
|
4282
|
+
// Recompile when components load/process (the observer has already collected their classes)
|
|
4217
4283
|
const handleComponentEvent = () => {
|
|
4218
4284
|
if (!this.hasScannedStatic) {
|
|
4219
4285
|
this.staticScanPromise = null;
|
|
@@ -4225,39 +4291,6 @@ TailwindCompiler.prototype.setupComponentLoadListener = function () {
|
|
|
4225
4291
|
document.addEventListener('manifest:component-loaded', handleComponentEvent);
|
|
4226
4292
|
document.addEventListener('manifest:components-processed', handleComponentEvent);
|
|
4227
4293
|
document.addEventListener('manifest:components-ready', handleComponentEvent);
|
|
4228
|
-
// Also listen for manifest-prefixed events (for future compatibility)
|
|
4229
|
-
document.addEventListener('manifest:components-processed', handleComponentEvent);
|
|
4230
|
-
document.addEventListener('manifest:components-ready', handleComponentEvent);
|
|
4231
|
-
|
|
4232
|
-
// On route change, recompile only if genuinely new dynamic classes appeared.
|
|
4233
|
-
document.addEventListener('manifest:route-change', (event) => {
|
|
4234
|
-
if (this.hasScannedStatic) {
|
|
4235
|
-
setTimeout(() => {
|
|
4236
|
-
const currentDynamicCount = this.dynamicClassCache.size;
|
|
4237
|
-
const currentClassesHash = this.lastClassesHash;
|
|
4238
|
-
|
|
4239
|
-
// Scan for new classes
|
|
4240
|
-
const usedData = this.getUsedClasses();
|
|
4241
|
-
const newDynamicCount = this.dynamicClassCache.size;
|
|
4242
|
-
const dynamicClasses = Array.from(this.dynamicClassCache);
|
|
4243
|
-
const newClassesHash = dynamicClasses.sort().join(',');
|
|
4244
|
-
|
|
4245
|
-
if (newDynamicCount > currentDynamicCount && newClassesHash !== currentClassesHash) {
|
|
4246
|
-
const newClasses = dynamicClasses.filter(cls =>
|
|
4247
|
-
// Ignore highlight/code-processing artifacts
|
|
4248
|
-
!cls.includes('hljs') &&
|
|
4249
|
-
!cls.startsWith('language-') &&
|
|
4250
|
-
!cls.includes('copy') &&
|
|
4251
|
-
!cls.includes('lines')
|
|
4252
|
-
);
|
|
4253
|
-
|
|
4254
|
-
if (newClasses.length > 0) {
|
|
4255
|
-
debouncedCompile();
|
|
4256
|
-
}
|
|
4257
|
-
}
|
|
4258
|
-
}, 300); // let code processing finish
|
|
4259
|
-
}
|
|
4260
|
-
});
|
|
4261
4294
|
|
|
4262
4295
|
// Single MutationObserver for all DOM changes: recompile only when a class not yet seen appears
|
|
4263
4296
|
const observer = new MutationObserver((mutations) => {
|
|
@@ -4266,7 +4299,7 @@ TailwindCompiler.prototype.setupComponentLoadListener = function () {
|
|
|
4266
4299
|
for (const mutation of mutations) {
|
|
4267
4300
|
if (mutation.type === 'attributes') {
|
|
4268
4301
|
if (this.ignoredAttributes.includes(mutation.attributeName) || mutation.attributeName !== 'class') continue;
|
|
4269
|
-
if (mutation.target.nodeType === Node.ELEMENT_NODE && this.collectNewClasses(mutation.target)) fresh = true;
|
|
4302
|
+
if (mutation.target.nodeType === Node.ELEMENT_NODE && this.collectNewClasses(mutation.target, false, true)) fresh = true;
|
|
4270
4303
|
} else if (mutation.type === 'childList') {
|
|
4271
4304
|
for (const node of mutation.addedNodes) {
|
|
4272
4305
|
if (node.nodeType !== Node.ELEMENT_NODE) continue;
|
|
@@ -4296,10 +4329,23 @@ TailwindCompiler.prototype.setupComponentLoadListener = function () {
|
|
|
4296
4329
|
};
|
|
4297
4330
|
|
|
4298
4331
|
// Record classes not seen before; true when any were new. Quiet = collect without triggering
|
|
4299
|
-
|
|
4332
|
+
// classOnly: a class attribute change (the element's binding expression was read when it was added)
|
|
4333
|
+
TailwindCompiler.prototype.collectNewClasses = function (el, quiet, classOnly) {
|
|
4300
4334
|
if (!el.getAttribute) return false;
|
|
4301
4335
|
const value = el.getAttribute('class');
|
|
4302
|
-
let fresh =
|
|
4336
|
+
let fresh = false;
|
|
4337
|
+
if (value) {
|
|
4338
|
+
// Rows repeat a handful of class strings: one fully recorded needs no re-split
|
|
4339
|
+
const seen = this._seenClassStrings || (this._seenClassStrings = new Set());
|
|
4340
|
+
if (!seen.has(value)) {
|
|
4341
|
+
fresh = this.recordClasses(value.split(/\s+/), quiet);
|
|
4342
|
+
if (!quiet) {
|
|
4343
|
+
if (seen.size > 5000) seen.clear();
|
|
4344
|
+
seen.add(value);
|
|
4345
|
+
}
|
|
4346
|
+
}
|
|
4347
|
+
}
|
|
4348
|
+
if (classOnly) return fresh;
|
|
4303
4349
|
const bound = el.getAttribute(':class') || el.getAttribute('x-bind:class');
|
|
4304
4350
|
if (bound && this.recordClasses(this.bindingClasses(bound), quiet)) fresh = true;
|
|
4305
4351
|
return fresh;
|