mnfst 0.5.289 → 0.5.291
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 +17 -8
- package/lib/manifest.integrity.json +5 -5
- package/lib/manifest.router.js +161 -116
- 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 +4 -1
package/lib/manifest.data.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
(function () {
|
|
4
4
|
|
|
5
|
-
const MANIFEST_BUILD_VERSION = '0.5.
|
|
5
|
+
const MANIFEST_BUILD_VERSION = '0.5.291';
|
|
6
6
|
|
|
7
7
|
/* Manifest Data Sources - Configuration */
|
|
8
8
|
|
|
@@ -7702,6 +7702,9 @@ async function unlinkFileFromAllEntries(fileId, options = {}) {
|
|
|
7702
7702
|
|
|
7703
7703
|
const columns = fileLinkColumns(manifest, tableName, tableConfig, options.bucketId);
|
|
7704
7704
|
const affected = new Set();
|
|
7705
|
+
const generation = window.ManifestDataStore?.sourceGeneration?.(tableName);
|
|
7706
|
+
const isCurrent = () => (!options.isCurrent || options.isCurrent())
|
|
7707
|
+
&& window.ManifestDataStore?.sourceGeneration?.(tableName) === generation;
|
|
7705
7708
|
|
|
7706
7709
|
for (const entry of entries) {
|
|
7707
7710
|
for (const column of columns) {
|
|
@@ -7711,7 +7714,7 @@ async function unlinkFileFromAllEntries(fileId, options = {}) {
|
|
|
7711
7714
|
if (!linked.includes(id)) continue;
|
|
7712
7715
|
affected.add(entry.$id);
|
|
7713
7716
|
unlinkPromises.push(
|
|
7714
|
-
unlinkFileFromEntry(tableName, entry.$id, id, column).catch(error => {
|
|
7717
|
+
unlinkFileFromEntry(tableName, entry.$id, id, column, { isCurrent }).catch(error => {
|
|
7715
7718
|
console.warn('[Manifest Data] Could not unlink from', tableName, 'entry', entry.$id, ':', error.message);
|
|
7716
7719
|
})
|
|
7717
7720
|
);
|
|
@@ -7734,11 +7737,14 @@ async function unlinkFileFromAllEntries(fileId, options = {}) {
|
|
|
7734
7737
|
|
|
7735
7738
|
// Unlink a file from a table entry by removing the file ID from the entry's fileIds array
|
|
7736
7739
|
// Generic function - works with any table and any scope
|
|
7737
|
-
function unlinkFileFromEntry(tableName, entryId, fileId, fileIdsColumn = 'fileIds') {
|
|
7738
|
-
return queueEntryFileWrite(tableName, entryId, fileIdsColumn, () => writeFileUnlink(tableName, entryId, fileId, fileIdsColumn));
|
|
7740
|
+
function unlinkFileFromEntry(tableName, entryId, fileId, fileIdsColumn = 'fileIds', options = {}) {
|
|
7741
|
+
return queueEntryFileWrite(tableName, entryId, fileIdsColumn, () => writeFileUnlink(tableName, entryId, fileId, fileIdsColumn, options));
|
|
7739
7742
|
}
|
|
7740
7743
|
|
|
7741
|
-
|
|
7744
|
+
// options.isCurrent: false once the identity that started the write is gone
|
|
7745
|
+
async function writeFileUnlink(tableName, entryId, fileId, fileIdsColumn, options = {}) {
|
|
7746
|
+
const stale = () => !!options.isCurrent && !options.isCurrent();
|
|
7747
|
+
if (stale()) return false;
|
|
7742
7748
|
const manifest = await window.ManifestDataConfig.ensureManifest();
|
|
7743
7749
|
const tableDataSource = manifest?.data?.[tableName];
|
|
7744
7750
|
|
|
@@ -7760,6 +7766,8 @@ async function writeFileUnlink(tableName, entryId, fileId, fileIdsColumn) {
|
|
|
7760
7766
|
entryId
|
|
7761
7767
|
);
|
|
7762
7768
|
|
|
7769
|
+
if (stale()) return false;
|
|
7770
|
+
|
|
7763
7771
|
if (!entry) {
|
|
7764
7772
|
throw new Error(`[Manifest Data] Entry "${entryId}" not found in table "${tableName}"`);
|
|
7765
7773
|
}
|
|
@@ -8477,7 +8485,7 @@ function createAppwriteMethodsHandler(dataSourceName, reloadDataSource) {
|
|
|
8477
8485
|
if (bucketId) {
|
|
8478
8486
|
// $delete / $remove: delete each file, land successes locally, then unlink them
|
|
8479
8487
|
const deleteBucketFiles = async (fileId) => {
|
|
8480
|
-
const ids = (Array.isArray(fileId) ? fileId : [fileId]).map(id => id
|
|
8488
|
+
const ids = (Array.isArray(fileId) ? fileId : [fileId]).map(id => id && typeof id === 'object' ? id.$id : id);
|
|
8481
8489
|
if (Array.isArray(fileId) && !ids.length) return [];
|
|
8482
8490
|
if (ids.some(id => !id)) {
|
|
8483
8491
|
throw new Error(`[Manifest Data] ${method} requires file ID`);
|
|
@@ -8503,11 +8511,12 @@ function createAppwriteMethodsHandler(dataSourceName, reloadDataSource) {
|
|
|
8503
8511
|
await ds.landRemove(dataSourceName, deleted, { generation });
|
|
8504
8512
|
}
|
|
8505
8513
|
|
|
8506
|
-
// Unlink only what the server deleted
|
|
8514
|
+
// Unlink only what the server deleted, and only for the identity that deleted it
|
|
8515
|
+
const isCurrent = () => !ds?.sourceGeneration || ds.sourceGeneration(dataSourceName) === generation;
|
|
8507
8516
|
const unlink = window.ManifestDataProxiesFiles?.unlinkFileFromAllEntries;
|
|
8508
8517
|
const affected = await Promise.all(deleted.map(async id => {
|
|
8509
8518
|
try {
|
|
8510
|
-
return unlink ? await unlink(id, { bucketId }) || {} : {};
|
|
8519
|
+
return unlink && isCurrent() ? await unlink(id, { bucketId, isCurrent }) || {} : {};
|
|
8511
8520
|
} catch (unlinkError) {
|
|
8512
8521
|
console.warn('[Manifest Data] Failed to unlink deleted file from entries:', unlinkError);
|
|
8513
8522
|
return {};
|
|
@@ -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-Opp1tNpEDbOj0WtdFQlogBJzc2tGiwLyj7AEWJkHxcjt06VrNYWn6DCvdDbwSPt5",
|
|
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",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"manifest.combobox.js": "sha384-/lJo6vaxKjgnBSRs/dzkhK1dzGk3GBw8FISoNJZB70mwAVwu1k5veZyBXjOb4keS",
|
|
12
12
|
"manifest.components.js": "sha384-1el5WMdgmzu/2ocaYN21OjLi/lfjllvA8aju1J3knYuOizw+XFfJU1+rvGqYW7qk",
|
|
13
13
|
"manifest.computed.js": "sha384-GYML/e81gQfN+iDbqhPUgny8bINCyL+SrbTofoGk4hlCnLLjv51mCv42JMqq+ku5",
|
|
14
|
-
"manifest.data.js": "sha384-
|
|
14
|
+
"manifest.data.js": "sha384-JvYICvCyjx/unD43o1DtkJ3nYwfgfgHHMHws4HmzZ9L90OnDGP6oNVTCQYlJ7pqC",
|
|
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-FgcHtfJ9OTwpo7ghsXL2ElurfVT0Q6541puTfeEIj17bGHBxlSAYtKPqk35gkkO2",
|
|
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-UUA5X6zDnljujAlIeHpFD4PEWSjaTi48STBZDS24jmrS1UvXPVuM54h0HgbHDCBl",
|
|
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
|
@@ -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.291';
|
|
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.291",
|
|
4
4
|
"private": false,
|
|
5
5
|
"workspaces": [
|
|
6
6
|
"templates/starter",
|
|
@@ -55,6 +55,9 @@
|
|
|
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:route-head": "node tests/e2e/route-head.e2e.mjs",
|
|
59
|
+
"test:e2e:prerender-patch": "node tests/e2e/utilities-prerender-patch.e2e.mjs",
|
|
60
|
+
"test:e2e:hidden-responsive": "node tests/e2e/utilities-hidden-responsive.e2e.mjs",
|
|
58
61
|
"lint": "echo 'No linting configured'",
|
|
59
62
|
"release:docs": "npm test && node scripts/release-bump.mjs packages/docs && cd packages/docs && npm publish --auth-type=web",
|
|
60
63
|
"release:check": "node scripts/release-check.mjs"
|