@plumeria/utils 18.3.5 → 18.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/parser.js +19 -34
- package/package.json +1 -1
package/dist/parser.js
CHANGED
|
@@ -726,10 +726,10 @@ function evaluateExpression(node, staticTable, keyframesHashTable, viewTransitio
|
|
|
726
726
|
return staticTable[node.value];
|
|
727
727
|
}
|
|
728
728
|
if (keyframesHashTable[node.value] !== undefined) {
|
|
729
|
-
return keyframesHashTable[node.value];
|
|
729
|
+
return 'kf-' + keyframesHashTable[node.value];
|
|
730
730
|
}
|
|
731
731
|
if (viewTransitionHashTable[node.value] !== undefined) {
|
|
732
|
-
return viewTransitionHashTable[node.value];
|
|
732
|
+
return 'vt-' + viewTransitionHashTable[node.value];
|
|
733
733
|
}
|
|
734
734
|
if (createStaticHashTable[node.value] !== undefined) {
|
|
735
735
|
const hash = createStaticHashTable[node.value];
|
|
@@ -1836,6 +1836,8 @@ function resolveExport(filePath, exportName, visited = new Set()) {
|
|
|
1836
1836
|
}
|
|
1837
1837
|
return null;
|
|
1838
1838
|
}
|
|
1839
|
+
const REFERENCE_MARKER = /(kf|vt|cr)-([0-9a-z]+)/g;
|
|
1840
|
+
const CUSTOM_PROPERTY = /var\(\s*(--[^\s,)]+)/g;
|
|
1839
1841
|
function extractOndemandStyles(obj, extractedSheets, t) {
|
|
1840
1842
|
if (!obj || typeof obj !== 'object')
|
|
1841
1843
|
return;
|
|
@@ -1850,44 +1852,27 @@ function extractOndemandStyles(obj, extractedSheets, t) {
|
|
|
1850
1852
|
visited.add(n);
|
|
1851
1853
|
Object.values(n).forEach((val) => {
|
|
1852
1854
|
if (typeof val === 'string') {
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1855
|
+
for (const [, kind, hash] of val.matchAll(REFERENCE_MARKER)) {
|
|
1856
|
+
if (kind === 'kf') {
|
|
1857
|
+
if (!keyframesHashes.has(hash) && t.keyframesObjectTable[hash]) {
|
|
1858
|
+
keyframesHashes.add(hash);
|
|
1859
|
+
walk(t.keyframesObjectTable[hash]);
|
|
1860
|
+
}
|
|
1858
1861
|
}
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1862
|
+
else if (kind === 'vt') {
|
|
1863
|
+
if (!viewTransitionHashes.has(hash) &&
|
|
1864
|
+
t.viewTransitionObjectTable[hash]) {
|
|
1865
|
+
viewTransitionHashes.add(hash);
|
|
1866
|
+
walk(t.viewTransitionObjectTable[hash]);
|
|
1867
|
+
}
|
|
1865
1868
|
}
|
|
1866
|
-
|
|
1867
|
-
else if (val.startsWith('cr-')) {
|
|
1868
|
-
const hash = val.slice(3);
|
|
1869
|
-
if (!createHashes.has(hash)) {
|
|
1869
|
+
else if (!createHashes.has(hash) && t.createObjectTable[hash]) {
|
|
1870
1870
|
createHashes.add(hash);
|
|
1871
1871
|
walk(t.createObjectTable[hash]);
|
|
1872
1872
|
}
|
|
1873
1873
|
}
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
while ((startIdx = val.indexOf('var(--', startIdx)) !== -1) {
|
|
1877
|
-
startIdx += 4;
|
|
1878
|
-
const endIdx = val.indexOf(')', startIdx);
|
|
1879
|
-
if (endIdx !== -1) {
|
|
1880
|
-
const content = val.slice(startIdx, endIdx);
|
|
1881
|
-
const varName = content.trim();
|
|
1882
|
-
if (varName.startsWith('--')) {
|
|
1883
|
-
usedVariables.add(varName);
|
|
1884
|
-
}
|
|
1885
|
-
startIdx = endIdx + 1;
|
|
1886
|
-
}
|
|
1887
|
-
else {
|
|
1888
|
-
break;
|
|
1889
|
-
}
|
|
1890
|
-
}
|
|
1874
|
+
for (const [, varName] of val.matchAll(CUSTOM_PROPERTY)) {
|
|
1875
|
+
usedVariables.add(varName);
|
|
1891
1876
|
}
|
|
1892
1877
|
}
|
|
1893
1878
|
else {
|