mnfst 0.5.288 → 0.5.290
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.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.290';
|
|
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-oKXa/eOSr9HiqTJ8reClBVzcsSwQOuU7+rSR5Al5XSAiTBkBw2G+SIonE0cquTWY",
|
|
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-iCwaub0nFyUnvFnACpTYH08Rx6pDOay4n7HZvoyTpE6fHeJnN/mz/7gf3gFf8kCe",
|
|
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",
|
|
@@ -29,13 +29,13 @@
|
|
|
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-NSBCg4zw2wNVHYPWBpc5b58ryQ+2+jU/U/0EXMjEjTbUa1P3ebNTzV64c+bDBg7J",
|
|
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-gG9ciUlw5ul09hku6p49DUVC8JiJIB5YW5Xf0Wj/5j7trDJHIpN/0OW4um2V70JR",
|
|
39
39
|
"manifest.virtual.js": "sha384-PtIDx042i29mkxEYZH+y3whBzKgBgV01CU1XzzeEl/8TBPl9qvny4ppyXgYI5DsM",
|
|
40
40
|
"manifest.js": "sha384-7+hNmvzD6OPQt6q4pZEDoqf5C8LHucIqlfKJQAAH6b4tsmvpX0viCvdYqqGOjqET"
|
|
41
41
|
}
|
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.290';
|
|
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)
|
|
@@ -354,58 +354,30 @@ function createVariants() {
|
|
|
354
354
|
'android': 'html[data-os="android"] &',
|
|
355
355
|
'apple': 'html[data-os="macos"] &, html[data-os="ios"] &',
|
|
356
356
|
|
|
357
|
-
//
|
|
358
|
-
'
|
|
359
|
-
'
|
|
360
|
-
'
|
|
361
|
-
'
|
|
362
|
-
'
|
|
363
|
-
'
|
|
364
|
-
'
|
|
365
|
-
'
|
|
366
|
-
'
|
|
367
|
-
'
|
|
368
|
-
'
|
|
369
|
-
'
|
|
370
|
-
'
|
|
371
|
-
'
|
|
372
|
-
'
|
|
373
|
-
'
|
|
374
|
-
'
|
|
375
|
-
'
|
|
376
|
-
'
|
|
377
|
-
'
|
|
378
|
-
'
|
|
379
|
-
'
|
|
380
|
-
'
|
|
381
|
-
'data-optional': '[data-optional] &',
|
|
382
|
-
'data-readonly': '[data-readonly] &',
|
|
383
|
-
'data-write': '[data-write] &',
|
|
384
|
-
|
|
385
|
-
// Aria attribute variants (common patterns)
|
|
386
|
-
'aria-expanded': '[aria-expanded="true"] &',
|
|
387
|
-
'aria-collapsed': '[aria-expanded="false"] &',
|
|
388
|
-
'aria-pressed': '[aria-pressed="true"] &',
|
|
389
|
-
'aria-unpressed': '[aria-pressed="false"] &',
|
|
390
|
-
'aria-checked': '[aria-checked="true"] &',
|
|
391
|
-
'aria-unchecked': '[aria-checked="false"] &',
|
|
392
|
-
'aria-selected': '[aria-selected="true"] &',
|
|
393
|
-
'aria-unselected': '[aria-selected="false"] &',
|
|
394
|
-
'aria-invalid': '[aria-invalid="true"] &',
|
|
395
|
-
'aria-valid': '[aria-invalid="false"] &',
|
|
396
|
-
'aria-required': '[aria-required="true"] &',
|
|
397
|
-
'aria-optional': '[aria-required="false"] &',
|
|
398
|
-
'aria-disabled': '[aria-disabled="true"] &',
|
|
399
|
-
'aria-enabled': '[aria-disabled="false"] &',
|
|
400
|
-
'aria-hidden': '[aria-hidden="true"] &',
|
|
401
|
-
'aria-visible': '[aria-hidden="false"] &',
|
|
402
|
-
'aria-busy': '[aria-busy="true"] &',
|
|
403
|
-
'aria-available': '[aria-busy="false"] &',
|
|
404
|
-
'aria-current': '[aria-current="true"] &',
|
|
405
|
-
'aria-not-current': '[aria-current="false"] &',
|
|
406
|
-
'aria-live': '[aria-live="polite"] &, [aria-live="assertive"] &',
|
|
407
|
-
'aria-atomic': '[aria-atomic="true"] &',
|
|
408
|
-
'aria-relevant': '[aria-relevant="additions"] &, [aria-relevant="removals"] &, [aria-relevant="text"] &, [aria-relevant="all"] &'
|
|
357
|
+
// Attribute variants sit on the element itself (Tailwind v4); data-*, data-[…] and aria-[…] are parsed in parseClassName
|
|
358
|
+
'aria-expanded': '&[aria-expanded="true"]',
|
|
359
|
+
'aria-collapsed': '&[aria-expanded="false"]',
|
|
360
|
+
'aria-pressed': '&[aria-pressed="true"]',
|
|
361
|
+
'aria-unpressed': '&[aria-pressed="false"]',
|
|
362
|
+
'aria-checked': '&[aria-checked="true"]',
|
|
363
|
+
'aria-unchecked': '&[aria-checked="false"]',
|
|
364
|
+
'aria-selected': '&[aria-selected="true"]',
|
|
365
|
+
'aria-unselected': '&[aria-selected="false"]',
|
|
366
|
+
'aria-invalid': '&[aria-invalid="true"]',
|
|
367
|
+
'aria-valid': '&[aria-invalid="false"]',
|
|
368
|
+
'aria-required': '&[aria-required="true"]',
|
|
369
|
+
'aria-optional': '&[aria-required="false"]',
|
|
370
|
+
'aria-disabled': '&[aria-disabled="true"]',
|
|
371
|
+
'aria-enabled': '&[aria-disabled="false"]',
|
|
372
|
+
'aria-hidden': '&[aria-hidden="true"]',
|
|
373
|
+
'aria-visible': '&[aria-hidden="false"]',
|
|
374
|
+
'aria-busy': '&[aria-busy="true"]',
|
|
375
|
+
'aria-available': '&[aria-busy="false"]',
|
|
376
|
+
'aria-current': '&[aria-current="true"]',
|
|
377
|
+
'aria-not-current': '&[aria-current="false"]',
|
|
378
|
+
'aria-live': '&:is([aria-live="polite"], [aria-live="assertive"])',
|
|
379
|
+
'aria-atomic': '&[aria-atomic="true"]',
|
|
380
|
+
'aria-relevant': '&:is([aria-relevant="additions"], [aria-relevant="removals"], [aria-relevant="text"], [aria-relevant="all"])'
|
|
409
381
|
};
|
|
410
382
|
}
|
|
411
383
|
|
|
@@ -1521,19 +1493,21 @@ TailwindCompiler.prototype.extractClassesFromHTML = function (html, classSet) {
|
|
|
1521
1493
|
}
|
|
1522
1494
|
}
|
|
1523
1495
|
|
|
1524
|
-
//
|
|
1525
|
-
const
|
|
1496
|
+
// Alpine class bindings: every literal they could apply
|
|
1497
|
+
const bindingRegex = /(?<![\w-])(?::|x-bind:)class=(["'])((?:(?!\1)[\s\S])*)\1/g;
|
|
1498
|
+
while ((match = bindingRegex.exec(html)) !== null) {
|
|
1499
|
+
this.collectBindingClasses(match[2], classSet);
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
// x-data is arbitrary JS: keep single-token string literals only
|
|
1503
|
+
const alpineRegex = /x-data=["']([^"']+)["']/g;
|
|
1526
1504
|
while ((match = alpineRegex.exec(html)) !== null) {
|
|
1527
|
-
// Simple extraction - could be enhanced for complex Alpine expressions
|
|
1528
1505
|
const content = match[1];
|
|
1529
1506
|
const classMatches = content.match(/['"`]([^'"`\s]+)['"`]/g);
|
|
1530
1507
|
if (classMatches) {
|
|
1531
1508
|
for (const classMatch of classMatches) {
|
|
1532
1509
|
const cls = classMatch.replace(/['"`]/g, '');
|
|
1533
|
-
//
|
|
1534
|
-
// (e.g. `location.pathname.split('/')`) matches this quoted-
|
|
1535
|
-
// token scan too, so require a letter/digit; a punctuation-only
|
|
1536
|
-
// "token" like a bare '/' is skipped (seen on a live page).
|
|
1510
|
+
// Skip punctuation-only literals such as split('/')
|
|
1537
1511
|
if (cls && !cls.startsWith('$') && !cls.includes('(') && /[a-zA-Z0-9]/.test(cls)) {
|
|
1538
1512
|
classSet.add(cls);
|
|
1539
1513
|
}
|
|
@@ -1542,6 +1516,26 @@ TailwindCompiler.prototype.extractClassesFromHTML = function (html, classSet) {
|
|
|
1542
1516
|
}
|
|
1543
1517
|
};
|
|
1544
1518
|
|
|
1519
|
+
// Class names a :class / x-bind:class expression can apply: string literals and object keys
|
|
1520
|
+
TailwindCompiler.prototype.collectBindingClasses = function (expr, classSet) {
|
|
1521
|
+
if (!expr) return;
|
|
1522
|
+
if (expr.includes('&')) expr = expr.replace(/"/g, '"').replace(/�?39;|'/g, "'").replace(/&/g, '&');
|
|
1523
|
+
const add = (token) => {
|
|
1524
|
+
if (!token || token.startsWith('x-') || token.startsWith('$') || !/[a-zA-Z0-9]/.test(token)) return;
|
|
1525
|
+
if (token.includes('://') || /^\d+:/.test(token)) return; // URLs, times
|
|
1526
|
+
if ((token.includes('[') ? /[{}'"`$;]/ : /[(){}'"`$;,]/).test(token)) return;
|
|
1527
|
+
classSet.add(token);
|
|
1528
|
+
};
|
|
1529
|
+
const literal = /(['"`])((?:\\[\s\S]|(?!\1)[^\\])*)\1/g;
|
|
1530
|
+
let m;
|
|
1531
|
+
while ((m = literal.exec(expr)) !== null) {
|
|
1532
|
+
for (const token of m[2].split(/\s+/)) add(token);
|
|
1533
|
+
if (m[1] === '`' && m[2].includes('${')) this.collectBindingClasses(m[2].replace(/`/g, ' '), classSet);
|
|
1534
|
+
}
|
|
1535
|
+
const bareKey = /[{,]\s*([A-Za-z_][\w-]*)\s*:/g;
|
|
1536
|
+
while ((m = bareKey.exec(expr)) !== null) add(m[1]);
|
|
1537
|
+
};
|
|
1538
|
+
|
|
1545
1539
|
// Get all used classes from static and dynamic sources
|
|
1546
1540
|
TailwindCompiler.prototype.getUsedClasses = function () {
|
|
1547
1541
|
try {
|
|
@@ -1552,6 +1546,10 @@ TailwindCompiler.prototype.getUsedClasses = function () {
|
|
|
1552
1546
|
for (const cls of this.staticClassCache) {
|
|
1553
1547
|
allClasses.add(cls);
|
|
1554
1548
|
}
|
|
1549
|
+
// Classes seen so far, including binding literals not yet in the DOM
|
|
1550
|
+
for (const cls of this.dynamicClassCache) {
|
|
1551
|
+
allClasses.add(cls);
|
|
1552
|
+
}
|
|
1555
1553
|
|
|
1556
1554
|
// Scan current DOM for dynamic classes only
|
|
1557
1555
|
const elements = document.getElementsByTagName('*');
|
|
@@ -2237,6 +2235,19 @@ TailwindCompiler.prototype.isTailwindGeneratedClass = function (className) {
|
|
|
2237
2235
|
return tailwindPatterns.some(pattern => pattern.test(className));
|
|
2238
2236
|
};
|
|
2239
2237
|
|
|
2238
|
+
// `[data-good]`, `[data-tone="good"]`, `[aria-busy="true"]` for a data-/aria- variant's remainder
|
|
2239
|
+
function attributeVariantCondition(kind, rest) {
|
|
2240
|
+
if (rest.startsWith('[') && rest.endsWith(']')) {
|
|
2241
|
+
const m = rest.slice(1, -1).match(/^([a-zA-Z0-9_-]+)(?:([~|^$*]?=)(.+))?$/);
|
|
2242
|
+
if (!m) return null;
|
|
2243
|
+
if (!m[2]) return `[${kind}-${m[1]}]`;
|
|
2244
|
+
const value = m[3].replace(/^(['"])(.*)\1$/, '$2').replace(/_/g, ' ').replace(/"/g, '\\"');
|
|
2245
|
+
return `[${kind}-${m[1]}${m[2]}"${value}"]`;
|
|
2246
|
+
}
|
|
2247
|
+
if (!/^[a-zA-Z0-9_-]+$/.test(rest)) return null;
|
|
2248
|
+
return kind === 'aria' ? `[aria-${rest}="true"]` : `[data-${rest}]`;
|
|
2249
|
+
}
|
|
2250
|
+
|
|
2240
2251
|
// Parse a class name into its components (variants, base class, important)
|
|
2241
2252
|
TailwindCompiler.prototype.parseClassName = function (className) {
|
|
2242
2253
|
// Check cache first
|
|
@@ -2314,20 +2325,17 @@ TailwindCompiler.prototype.parseClassName = function (className) {
|
|
|
2314
2325
|
|
|
2315
2326
|
// THIRD: Handle parameterized variants (only if exact match not found)
|
|
2316
2327
|
|
|
2317
|
-
//
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
const
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
selector: `[data-${quotedValue}] &`,
|
|
2329
|
-
isArbitrary: false
|
|
2330
|
-
};
|
|
2328
|
+
// Attribute variants (Tailwind v4): the condition sits on the element; group-/peer- move it to the marker
|
|
2329
|
+
const attrMatch = variant.match(/^(group-|peer-)?(data|aria)-(.+)$/);
|
|
2330
|
+
if (attrMatch) {
|
|
2331
|
+
const named = attrMatch[1] && /^&([[:][^&]*)$/.exec(this.variants[`${attrMatch[2]}-${attrMatch[3]}`] || '');
|
|
2332
|
+
const condition = named ? named[1] : attributeVariantCondition(attrMatch[2], attrMatch[3]);
|
|
2333
|
+
if (condition) {
|
|
2334
|
+
const selector = !attrMatch[1] ? `&${condition}`
|
|
2335
|
+
: attrMatch[1] === 'group-' ? `:where(.group${condition}) &`
|
|
2336
|
+
: `:where(.peer${condition}) ~ &`;
|
|
2337
|
+
return { name: variant, selector, isArbitrary: false };
|
|
2338
|
+
}
|
|
2331
2339
|
}
|
|
2332
2340
|
|
|
2333
2341
|
// Handle parameterized nth variants: nth-3, nth-last-2, nth-of-type-2, nth-last-of-type-2
|
|
@@ -2435,6 +2443,7 @@ TailwindCompiler.prototype.parseClassName = function (className) {
|
|
|
2435
2443
|
this._warnedVariants.add(variant);
|
|
2436
2444
|
console.warn(`Unknown variant: ${variant}`);
|
|
2437
2445
|
}
|
|
2446
|
+
result.unknown = true;
|
|
2438
2447
|
return null;
|
|
2439
2448
|
}).filter(Boolean);
|
|
2440
2449
|
|
|
@@ -2503,6 +2512,7 @@ TailwindCompiler.prototype.generateUtilitiesFromVars = function (cssText, usedDa
|
|
|
2503
2512
|
if (variantClass === baseClass) continue;
|
|
2504
2513
|
|
|
2505
2514
|
const parsed = this.parseClassName(variantClass);
|
|
2515
|
+
if (parsed.unknown) continue; // never drop a condition and emit unconditionally
|
|
2506
2516
|
|
|
2507
2517
|
// Check if this is an important variant
|
|
2508
2518
|
const isImportant = parsed.important;
|
|
@@ -2821,6 +2831,7 @@ TailwindCompiler.prototype.generateCustomUtilities = function (usedData) {
|
|
|
2821
2831
|
if (variantClass === baseClass) continue;
|
|
2822
2832
|
|
|
2823
2833
|
const parsed = this.parseClassName(variantClass);
|
|
2834
|
+
if (parsed.unknown) continue; // never drop a condition and emit unconditionally
|
|
2824
2835
|
|
|
2825
2836
|
// Check if this is an important variant
|
|
2826
2837
|
const isImportant = parsed.important;
|
|
@@ -3152,7 +3163,7 @@ TailwindCompiler.prototype.entriesMatchSheet = function (entries) {
|
|
|
3152
3163
|
};
|
|
3153
3164
|
|
|
3154
3165
|
// After a full write: remember its rules so later compiles can insert beside them
|
|
3155
|
-
TailwindCompiler.prototype.recordAppliedUtilities = function (entries, themeCss) {
|
|
3166
|
+
TailwindCompiler.prototype.recordAppliedUtilities = function (entries, themeCss, compiledClasses) {
|
|
3156
3167
|
this._applied = null;
|
|
3157
3168
|
if (window.__manifestRender === true || !this.entriesMatchSheet(entries)) return;
|
|
3158
3169
|
this._applied = {
|
|
@@ -3160,7 +3171,7 @@ TailwindCompiler.prototype.recordAppliedUtilities = function (entries, themeCss)
|
|
|
3160
3171
|
themeCss, // keys index this exact variable order
|
|
3161
3172
|
entries,
|
|
3162
3173
|
rules: new Set(entries.map(e => e.rule)),
|
|
3163
|
-
classes: new Set(
|
|
3174
|
+
classes: new Set(compiledClasses), // only what this write covered
|
|
3164
3175
|
dirty: false // inserted rules not yet in textContent
|
|
3165
3176
|
};
|
|
3166
3177
|
};
|
|
@@ -3508,7 +3519,9 @@ TailwindCompiler.prototype.compile = async function () {
|
|
|
3508
3519
|
});
|
|
3509
3520
|
this.lastClassesHash = dynamicClassesHash;
|
|
3510
3521
|
const entries = rulesOut.map((rule, i) => ({ rule, key: [isMediaRule(rule) ? 1 : 0].concat(keysOut[i]) }));
|
|
3511
|
-
this.recordAppliedUtilities(entries.filter(e => !e.key[0]).concat(entries.filter(e => e.key[0])), themeCss);
|
|
3522
|
+
this.recordAppliedUtilities(entries.filter(e => !e.key[0]).concat(entries.filter(e => e.key[0])), themeCss, dynamicClasses);
|
|
3523
|
+
// Classes that arrived during the await above still need a pass
|
|
3524
|
+
if (this.dynamicClassCache.size > dynamicClasses.length) this.compile();
|
|
3512
3525
|
|
|
3513
3526
|
// Save to cache for next page load
|
|
3514
3527
|
const themeHash = this.generateThemeHash(themeCss);
|
|
@@ -3935,11 +3948,8 @@ TailwindCompiler.prototype.setupUncoveredClassWatcher = function () {
|
|
|
3935
3948
|
|
|
3936
3949
|
// Setup component load listener and MutationObserver
|
|
3937
3950
|
TailwindCompiler.prototype.setupComponentLoadListener = function () {
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
this.compile();
|
|
3941
|
-
}
|
|
3942
|
-
}, this.options.debounceTime);
|
|
3951
|
+
// compile() queues a retry when busy; dropping the call here lost classes seen mid-compile
|
|
3952
|
+
const debouncedCompile = this.debounce(() => this.compile(), this.options.debounceTime);
|
|
3943
3953
|
|
|
3944
3954
|
// Recompile when components load/process; re-scan so component HTML is covered.
|
|
3945
3955
|
const handleComponentEvent = () => {
|
|
@@ -4025,10 +4035,31 @@ TailwindCompiler.prototype.setupComponentLoadListener = function () {
|
|
|
4025
4035
|
|
|
4026
4036
|
// Record classes not seen before; true when any were new. Quiet = collect without triggering
|
|
4027
4037
|
TailwindCompiler.prototype.collectNewClasses = function (el, quiet) {
|
|
4028
|
-
|
|
4029
|
-
|
|
4038
|
+
if (!el.getAttribute) return false;
|
|
4039
|
+
const value = el.getAttribute('class');
|
|
4040
|
+
let fresh = value ? this.recordClasses(value.split(/\s+/), quiet) : false;
|
|
4041
|
+
const bound = el.getAttribute(':class') || el.getAttribute('x-bind:class');
|
|
4042
|
+
if (bound && this.recordClasses(this.bindingClasses(bound), quiet)) fresh = true;
|
|
4043
|
+
return fresh;
|
|
4044
|
+
};
|
|
4045
|
+
|
|
4046
|
+
// Binding literals per expression, cached: x-for clones repeat the same few
|
|
4047
|
+
TailwindCompiler.prototype.bindingClasses = function (expr) {
|
|
4048
|
+
if (!this._bindingClasses) this._bindingClasses = new Map();
|
|
4049
|
+
let list = this._bindingClasses.get(expr);
|
|
4050
|
+
if (!list) {
|
|
4051
|
+
const set = new Set();
|
|
4052
|
+
this.collectBindingClasses(expr, set);
|
|
4053
|
+
list = Array.from(set);
|
|
4054
|
+
if (this._bindingClasses.size > 500) this._bindingClasses.clear();
|
|
4055
|
+
this._bindingClasses.set(expr, list);
|
|
4056
|
+
}
|
|
4057
|
+
return list;
|
|
4058
|
+
};
|
|
4059
|
+
|
|
4060
|
+
TailwindCompiler.prototype.recordClasses = function (list, quiet) {
|
|
4030
4061
|
let fresh = false;
|
|
4031
|
-
for (const cls of
|
|
4062
|
+
for (const cls of list) {
|
|
4032
4063
|
if (!cls || this.staticClassCache.has(cls)) continue;
|
|
4033
4064
|
if (this.dynamicClassCache.has(cls)) {
|
|
4034
4065
|
if (!quiet && this.quietClasses.delete(cls)) fresh = true;
|
|
@@ -372,58 +372,30 @@ function createVariants() {
|
|
|
372
372
|
'android': 'html[data-os="android"] &',
|
|
373
373
|
'apple': 'html[data-os="macos"] &, html[data-os="ios"] &',
|
|
374
374
|
|
|
375
|
-
//
|
|
376
|
-
'
|
|
377
|
-
'
|
|
378
|
-
'
|
|
379
|
-
'
|
|
380
|
-
'
|
|
381
|
-
'
|
|
382
|
-
'
|
|
383
|
-
'
|
|
384
|
-
'
|
|
385
|
-
'
|
|
386
|
-
'
|
|
387
|
-
'
|
|
388
|
-
'
|
|
389
|
-
'
|
|
390
|
-
'
|
|
391
|
-
'
|
|
392
|
-
'
|
|
393
|
-
'
|
|
394
|
-
'
|
|
395
|
-
'
|
|
396
|
-
'
|
|
397
|
-
'
|
|
398
|
-
'
|
|
399
|
-
'data-optional': '[data-optional] &',
|
|
400
|
-
'data-readonly': '[data-readonly] &',
|
|
401
|
-
'data-write': '[data-write] &',
|
|
402
|
-
|
|
403
|
-
// Aria attribute variants (common patterns)
|
|
404
|
-
'aria-expanded': '[aria-expanded="true"] &',
|
|
405
|
-
'aria-collapsed': '[aria-expanded="false"] &',
|
|
406
|
-
'aria-pressed': '[aria-pressed="true"] &',
|
|
407
|
-
'aria-unpressed': '[aria-pressed="false"] &',
|
|
408
|
-
'aria-checked': '[aria-checked="true"] &',
|
|
409
|
-
'aria-unchecked': '[aria-checked="false"] &',
|
|
410
|
-
'aria-selected': '[aria-selected="true"] &',
|
|
411
|
-
'aria-unselected': '[aria-selected="false"] &',
|
|
412
|
-
'aria-invalid': '[aria-invalid="true"] &',
|
|
413
|
-
'aria-valid': '[aria-invalid="false"] &',
|
|
414
|
-
'aria-required': '[aria-required="true"] &',
|
|
415
|
-
'aria-optional': '[aria-required="false"] &',
|
|
416
|
-
'aria-disabled': '[aria-disabled="true"] &',
|
|
417
|
-
'aria-enabled': '[aria-disabled="false"] &',
|
|
418
|
-
'aria-hidden': '[aria-hidden="true"] &',
|
|
419
|
-
'aria-visible': '[aria-hidden="false"] &',
|
|
420
|
-
'aria-busy': '[aria-busy="true"] &',
|
|
421
|
-
'aria-available': '[aria-busy="false"] &',
|
|
422
|
-
'aria-current': '[aria-current="true"] &',
|
|
423
|
-
'aria-not-current': '[aria-current="false"] &',
|
|
424
|
-
'aria-live': '[aria-live="polite"] &, [aria-live="assertive"] &',
|
|
425
|
-
'aria-atomic': '[aria-atomic="true"] &',
|
|
426
|
-
'aria-relevant': '[aria-relevant="additions"] &, [aria-relevant="removals"] &, [aria-relevant="text"] &, [aria-relevant="all"] &'
|
|
375
|
+
// Attribute variants sit on the element itself (Tailwind v4); data-*, data-[…] and aria-[…] are parsed in parseClassName
|
|
376
|
+
'aria-expanded': '&[aria-expanded="true"]',
|
|
377
|
+
'aria-collapsed': '&[aria-expanded="false"]',
|
|
378
|
+
'aria-pressed': '&[aria-pressed="true"]',
|
|
379
|
+
'aria-unpressed': '&[aria-pressed="false"]',
|
|
380
|
+
'aria-checked': '&[aria-checked="true"]',
|
|
381
|
+
'aria-unchecked': '&[aria-checked="false"]',
|
|
382
|
+
'aria-selected': '&[aria-selected="true"]',
|
|
383
|
+
'aria-unselected': '&[aria-selected="false"]',
|
|
384
|
+
'aria-invalid': '&[aria-invalid="true"]',
|
|
385
|
+
'aria-valid': '&[aria-invalid="false"]',
|
|
386
|
+
'aria-required': '&[aria-required="true"]',
|
|
387
|
+
'aria-optional': '&[aria-required="false"]',
|
|
388
|
+
'aria-disabled': '&[aria-disabled="true"]',
|
|
389
|
+
'aria-enabled': '&[aria-disabled="false"]',
|
|
390
|
+
'aria-hidden': '&[aria-hidden="true"]',
|
|
391
|
+
'aria-visible': '&[aria-hidden="false"]',
|
|
392
|
+
'aria-busy': '&[aria-busy="true"]',
|
|
393
|
+
'aria-available': '&[aria-busy="false"]',
|
|
394
|
+
'aria-current': '&[aria-current="true"]',
|
|
395
|
+
'aria-not-current': '&[aria-current="false"]',
|
|
396
|
+
'aria-live': '&:is([aria-live="polite"], [aria-live="assertive"])',
|
|
397
|
+
'aria-atomic': '&[aria-atomic="true"]',
|
|
398
|
+
'aria-relevant': '&:is([aria-relevant="additions"], [aria-relevant="removals"], [aria-relevant="text"], [aria-relevant="all"])'
|
|
427
399
|
};
|
|
428
400
|
}
|
|
429
401
|
|
|
@@ -955,19 +927,21 @@ TailwindCompiler.prototype.extractClassesFromHTML = function (html, classSet) {
|
|
|
955
927
|
}
|
|
956
928
|
}
|
|
957
929
|
|
|
958
|
-
//
|
|
959
|
-
const
|
|
930
|
+
// Alpine class bindings: every literal they could apply
|
|
931
|
+
const bindingRegex = /(?<![\w-])(?::|x-bind:)class=(["'])((?:(?!\1)[\s\S])*)\1/g;
|
|
932
|
+
while ((match = bindingRegex.exec(html)) !== null) {
|
|
933
|
+
this.collectBindingClasses(match[2], classSet);
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
// x-data is arbitrary JS: keep single-token string literals only
|
|
937
|
+
const alpineRegex = /x-data=["']([^"']+)["']/g;
|
|
960
938
|
while ((match = alpineRegex.exec(html)) !== null) {
|
|
961
|
-
// Simple extraction - could be enhanced for complex Alpine expressions
|
|
962
939
|
const content = match[1];
|
|
963
940
|
const classMatches = content.match(/['"`]([^'"`\s]+)['"`]/g);
|
|
964
941
|
if (classMatches) {
|
|
965
942
|
for (const classMatch of classMatches) {
|
|
966
943
|
const cls = classMatch.replace(/['"`]/g, '');
|
|
967
|
-
//
|
|
968
|
-
// (e.g. `location.pathname.split('/')`) matches this quoted-
|
|
969
|
-
// token scan too, so require a letter/digit; a punctuation-only
|
|
970
|
-
// "token" like a bare '/' is skipped (seen on a live page).
|
|
944
|
+
// Skip punctuation-only literals such as split('/')
|
|
971
945
|
if (cls && !cls.startsWith('$') && !cls.includes('(') && /[a-zA-Z0-9]/.test(cls)) {
|
|
972
946
|
classSet.add(cls);
|
|
973
947
|
}
|
|
@@ -976,6 +950,26 @@ TailwindCompiler.prototype.extractClassesFromHTML = function (html, classSet) {
|
|
|
976
950
|
}
|
|
977
951
|
};
|
|
978
952
|
|
|
953
|
+
// Class names a :class / x-bind:class expression can apply: string literals and object keys
|
|
954
|
+
TailwindCompiler.prototype.collectBindingClasses = function (expr, classSet) {
|
|
955
|
+
if (!expr) return;
|
|
956
|
+
if (expr.includes('&')) expr = expr.replace(/"/g, '"').replace(/�?39;|'/g, "'").replace(/&/g, '&');
|
|
957
|
+
const add = (token) => {
|
|
958
|
+
if (!token || token.startsWith('x-') || token.startsWith('$') || !/[a-zA-Z0-9]/.test(token)) return;
|
|
959
|
+
if (token.includes('://') || /^\d+:/.test(token)) return; // URLs, times
|
|
960
|
+
if ((token.includes('[') ? /[{}'"`$;]/ : /[(){}'"`$;,]/).test(token)) return;
|
|
961
|
+
classSet.add(token);
|
|
962
|
+
};
|
|
963
|
+
const literal = /(['"`])((?:\\[\s\S]|(?!\1)[^\\])*)\1/g;
|
|
964
|
+
let m;
|
|
965
|
+
while ((m = literal.exec(expr)) !== null) {
|
|
966
|
+
for (const token of m[2].split(/\s+/)) add(token);
|
|
967
|
+
if (m[1] === '`' && m[2].includes('${')) this.collectBindingClasses(m[2].replace(/`/g, ' '), classSet);
|
|
968
|
+
}
|
|
969
|
+
const bareKey = /[{,]\s*([A-Za-z_][\w-]*)\s*:/g;
|
|
970
|
+
while ((m = bareKey.exec(expr)) !== null) add(m[1]);
|
|
971
|
+
};
|
|
972
|
+
|
|
979
973
|
// Get all used classes from static and dynamic sources
|
|
980
974
|
TailwindCompiler.prototype.getUsedClasses = function () {
|
|
981
975
|
try {
|
|
@@ -986,6 +980,10 @@ TailwindCompiler.prototype.getUsedClasses = function () {
|
|
|
986
980
|
for (const cls of this.staticClassCache) {
|
|
987
981
|
allClasses.add(cls);
|
|
988
982
|
}
|
|
983
|
+
// Classes seen so far, including binding literals not yet in the DOM
|
|
984
|
+
for (const cls of this.dynamicClassCache) {
|
|
985
|
+
allClasses.add(cls);
|
|
986
|
+
}
|
|
989
987
|
|
|
990
988
|
// Scan current DOM for dynamic classes only
|
|
991
989
|
const elements = document.getElementsByTagName('*');
|
|
@@ -1671,6 +1669,19 @@ TailwindCompiler.prototype.isTailwindGeneratedClass = function (className) {
|
|
|
1671
1669
|
return tailwindPatterns.some(pattern => pattern.test(className));
|
|
1672
1670
|
};
|
|
1673
1671
|
|
|
1672
|
+
// `[data-good]`, `[data-tone="good"]`, `[aria-busy="true"]` for a data-/aria- variant's remainder
|
|
1673
|
+
function attributeVariantCondition(kind, rest) {
|
|
1674
|
+
if (rest.startsWith('[') && rest.endsWith(']')) {
|
|
1675
|
+
const m = rest.slice(1, -1).match(/^([a-zA-Z0-9_-]+)(?:([~|^$*]?=)(.+))?$/);
|
|
1676
|
+
if (!m) return null;
|
|
1677
|
+
if (!m[2]) return `[${kind}-${m[1]}]`;
|
|
1678
|
+
const value = m[3].replace(/^(['"])(.*)\1$/, '$2').replace(/_/g, ' ').replace(/"/g, '\\"');
|
|
1679
|
+
return `[${kind}-${m[1]}${m[2]}"${value}"]`;
|
|
1680
|
+
}
|
|
1681
|
+
if (!/^[a-zA-Z0-9_-]+$/.test(rest)) return null;
|
|
1682
|
+
return kind === 'aria' ? `[aria-${rest}="true"]` : `[data-${rest}]`;
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1674
1685
|
// Parse a class name into its components (variants, base class, important)
|
|
1675
1686
|
TailwindCompiler.prototype.parseClassName = function (className) {
|
|
1676
1687
|
// Check cache first
|
|
@@ -1748,20 +1759,17 @@ TailwindCompiler.prototype.parseClassName = function (className) {
|
|
|
1748
1759
|
|
|
1749
1760
|
// THIRD: Handle parameterized variants (only if exact match not found)
|
|
1750
1761
|
|
|
1751
|
-
//
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
const
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
selector: `[data-${quotedValue}] &`,
|
|
1763
|
-
isArbitrary: false
|
|
1764
|
-
};
|
|
1762
|
+
// Attribute variants (Tailwind v4): the condition sits on the element; group-/peer- move it to the marker
|
|
1763
|
+
const attrMatch = variant.match(/^(group-|peer-)?(data|aria)-(.+)$/);
|
|
1764
|
+
if (attrMatch) {
|
|
1765
|
+
const named = attrMatch[1] && /^&([[:][^&]*)$/.exec(this.variants[`${attrMatch[2]}-${attrMatch[3]}`] || '');
|
|
1766
|
+
const condition = named ? named[1] : attributeVariantCondition(attrMatch[2], attrMatch[3]);
|
|
1767
|
+
if (condition) {
|
|
1768
|
+
const selector = !attrMatch[1] ? `&${condition}`
|
|
1769
|
+
: attrMatch[1] === 'group-' ? `:where(.group${condition}) &`
|
|
1770
|
+
: `:where(.peer${condition}) ~ &`;
|
|
1771
|
+
return { name: variant, selector, isArbitrary: false };
|
|
1772
|
+
}
|
|
1765
1773
|
}
|
|
1766
1774
|
|
|
1767
1775
|
// Handle parameterized nth variants: nth-3, nth-last-2, nth-of-type-2, nth-last-of-type-2
|
|
@@ -1869,6 +1877,7 @@ TailwindCompiler.prototype.parseClassName = function (className) {
|
|
|
1869
1877
|
this._warnedVariants.add(variant);
|
|
1870
1878
|
console.warn(`Unknown variant: ${variant}`);
|
|
1871
1879
|
}
|
|
1880
|
+
result.unknown = true;
|
|
1872
1881
|
return null;
|
|
1873
1882
|
}).filter(Boolean);
|
|
1874
1883
|
|
|
@@ -1937,6 +1946,7 @@ TailwindCompiler.prototype.generateUtilitiesFromVars = function (cssText, usedDa
|
|
|
1937
1946
|
if (variantClass === baseClass) continue;
|
|
1938
1947
|
|
|
1939
1948
|
const parsed = this.parseClassName(variantClass);
|
|
1949
|
+
if (parsed.unknown) continue; // never drop a condition and emit unconditionally
|
|
1940
1950
|
|
|
1941
1951
|
// Check if this is an important variant
|
|
1942
1952
|
const isImportant = parsed.important;
|
|
@@ -2255,6 +2265,7 @@ TailwindCompiler.prototype.generateCustomUtilities = function (usedData) {
|
|
|
2255
2265
|
if (variantClass === baseClass) continue;
|
|
2256
2266
|
|
|
2257
2267
|
const parsed = this.parseClassName(variantClass);
|
|
2268
|
+
if (parsed.unknown) continue; // never drop a condition and emit unconditionally
|
|
2258
2269
|
|
|
2259
2270
|
// Check if this is an important variant
|
|
2260
2271
|
const isImportant = parsed.important;
|
|
@@ -2586,7 +2597,7 @@ TailwindCompiler.prototype.entriesMatchSheet = function (entries) {
|
|
|
2586
2597
|
};
|
|
2587
2598
|
|
|
2588
2599
|
// After a full write: remember its rules so later compiles can insert beside them
|
|
2589
|
-
TailwindCompiler.prototype.recordAppliedUtilities = function (entries, themeCss) {
|
|
2600
|
+
TailwindCompiler.prototype.recordAppliedUtilities = function (entries, themeCss, compiledClasses) {
|
|
2590
2601
|
this._applied = null;
|
|
2591
2602
|
if (window.__manifestRender === true || !this.entriesMatchSheet(entries)) return;
|
|
2592
2603
|
this._applied = {
|
|
@@ -2594,7 +2605,7 @@ TailwindCompiler.prototype.recordAppliedUtilities = function (entries, themeCss)
|
|
|
2594
2605
|
themeCss, // keys index this exact variable order
|
|
2595
2606
|
entries,
|
|
2596
2607
|
rules: new Set(entries.map(e => e.rule)),
|
|
2597
|
-
classes: new Set(
|
|
2608
|
+
classes: new Set(compiledClasses), // only what this write covered
|
|
2598
2609
|
dirty: false // inserted rules not yet in textContent
|
|
2599
2610
|
};
|
|
2600
2611
|
};
|
|
@@ -2942,7 +2953,9 @@ TailwindCompiler.prototype.compile = async function () {
|
|
|
2942
2953
|
});
|
|
2943
2954
|
this.lastClassesHash = dynamicClassesHash;
|
|
2944
2955
|
const entries = rulesOut.map((rule, i) => ({ rule, key: [isMediaRule(rule) ? 1 : 0].concat(keysOut[i]) }));
|
|
2945
|
-
this.recordAppliedUtilities(entries.filter(e => !e.key[0]).concat(entries.filter(e => e.key[0])), themeCss);
|
|
2956
|
+
this.recordAppliedUtilities(entries.filter(e => !e.key[0]).concat(entries.filter(e => e.key[0])), themeCss, dynamicClasses);
|
|
2957
|
+
// Classes that arrived during the await above still need a pass
|
|
2958
|
+
if (this.dynamicClassCache.size > dynamicClasses.length) this.compile();
|
|
2946
2959
|
|
|
2947
2960
|
// Save to cache for next page load
|
|
2948
2961
|
const themeHash = this.generateThemeHash(themeCss);
|
|
@@ -3223,18 +3236,12 @@ export async function compileUtilities({ classes = [], themeCss = '', baseCss =
|
|
|
3223
3236
|
return `@layer base, components, utilities;\n\n${body}`;
|
|
3224
3237
|
}
|
|
3225
3238
|
|
|
3226
|
-
// `class:token=`
|
|
3227
|
-
// shorthand aren't matched by extractClassesFromHTML's `x-(data|bind:class|class)=`
|
|
3228
|
-
// regex (no `x-` prefix), so pick those up here too — cheap regex pass, not a
|
|
3229
|
-
// JS/expression parser, so only literal-looking quoted tokens are kept.
|
|
3239
|
+
// `class:token=` per-class conditional bindings; extractClassesFromHTML covers `:class`
|
|
3230
3240
|
const CLASS_TOKEN_BINDING_RE = /\bclass:([a-zA-Z0-9_-]+(?:\\.[a-zA-Z0-9_-]+)*)\s*=/g;
|
|
3231
|
-
// Backreference to the opening quote so a nested quote char (`:class="'a b'"`)
|
|
3232
|
-
// doesn't truncate the match early.
|
|
3233
|
-
const SHORTHAND_CLASS_BINDING_RE = /\B:class=(["'])((?:(?!\1)[\s\S])*)\1/g;
|
|
3234
3241
|
|
|
3235
3242
|
/**
|
|
3236
3243
|
* Scan HTML for utility class tokens using the same extraction the browser
|
|
3237
|
-
* plugin uses (extractClassesFromHTML), plus `class
|
|
3244
|
+
* plugin uses (extractClassesFromHTML, which reads `:class` literals), plus `class:` tokens.
|
|
3238
3245
|
* Skips `x-`/`$` tokens. Returns a sorted, deduplicated array.
|
|
3239
3246
|
*
|
|
3240
3247
|
* `safelist` (manifest.json's `utilities.safelist`) is folded into the result
|
|
@@ -3257,19 +3264,5 @@ export function scanClasses(html, { safelist = [] } = {}) {
|
|
|
3257
3264
|
if (cls && !cls.startsWith('x-') && !cls.startsWith('$')) set.add(cls);
|
|
3258
3265
|
}
|
|
3259
3266
|
|
|
3260
|
-
SHORTHAND_CLASS_BINDING_RE.lastIndex = 0;
|
|
3261
|
-
while ((m = SHORTHAND_CLASS_BINDING_RE.exec(html)) !== null) {
|
|
3262
|
-
const content = m[2];
|
|
3263
|
-
const quoted = content.match(/['"`]([^'"`\s]+)['"`]/g);
|
|
3264
|
-
if (quoted) {
|
|
3265
|
-
for (const q of quoted) {
|
|
3266
|
-
const cls = q.replace(/['"`]/g, '');
|
|
3267
|
-
// Reject punctuation-only "tokens" (e.g. a bare '/' from an
|
|
3268
|
-
// unrelated string literal in the expression) — see helpers.js.
|
|
3269
|
-
if (cls && !cls.startsWith('$') && !cls.startsWith('x-') && !cls.includes('(') && /[a-zA-Z0-9]/.test(cls)) set.add(cls);
|
|
3270
|
-
}
|
|
3271
|
-
}
|
|
3272
|
-
}
|
|
3273
|
-
|
|
3274
3267
|
return Array.from(set).sort();
|
|
3275
3268
|
}
|