@plumeria/utils 19.2.5 → 19.2.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 +33 -60
- package/package.json +1 -1
package/dist/parser.js
CHANGED
|
@@ -1039,6 +1039,7 @@ let resolutionConfigStamp;
|
|
|
1039
1039
|
let scannedCwd;
|
|
1040
1040
|
const objectTableOwners = new Map();
|
|
1041
1041
|
const fileObjectContributions = new Map();
|
|
1042
|
+
const fileKeyContributions = new Map();
|
|
1042
1043
|
function snapshotTables() {
|
|
1043
1044
|
return Object.fromEntries(Object.entries(globalAgregatedTables).map(([key, value]) => [
|
|
1044
1045
|
key,
|
|
@@ -1055,6 +1056,15 @@ function releaseFileObjects(filePath) {
|
|
|
1055
1056
|
}
|
|
1056
1057
|
fileObjectContributions.delete(filePath);
|
|
1057
1058
|
}
|
|
1059
|
+
function registerFileKey(tableName, key, filePath) {
|
|
1060
|
+
let contributions = fileKeyContributions.get(filePath);
|
|
1061
|
+
if (!contributions)
|
|
1062
|
+
fileKeyContributions.set(filePath, (contributions = new Map()));
|
|
1063
|
+
let keys = contributions.get(tableName);
|
|
1064
|
+
if (!keys)
|
|
1065
|
+
contributions.set(tableName, (keys = new Set()));
|
|
1066
|
+
keys.add(key);
|
|
1067
|
+
}
|
|
1058
1068
|
function registerObjectOwner(tableName, hash, filePath) {
|
|
1059
1069
|
let contributions = fileObjectContributions.get(filePath);
|
|
1060
1070
|
if (!contributions)
|
|
@@ -1090,60 +1100,17 @@ function stripFileContributions(filePath, cached) {
|
|
|
1090
1100
|
delete globalAgregatedTables.styleReceiverTable[key];
|
|
1091
1101
|
receiverKeysByFile.delete(filePath);
|
|
1092
1102
|
}
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
name === 'styleReceiverTable')
|
|
1099
|
-
continue;
|
|
1100
|
-
for (const key of Object.keys(table))
|
|
1101
|
-
if (key.startsWith(`${filePath}-`))
|
|
1103
|
+
const keyContributions = fileKeyContributions.get(filePath);
|
|
1104
|
+
if (keyContributions) {
|
|
1105
|
+
for (const [tableName, keys] of keyContributions) {
|
|
1106
|
+
const table = globalAgregatedTables[tableName];
|
|
1107
|
+
for (const key of keys)
|
|
1102
1108
|
delete table[key];
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
for (const key of Object.keys(cached.staticTable)) {
|
|
1106
|
-
delete localTables.staticTable[`${filePath}-${key}`];
|
|
1107
|
-
}
|
|
1108
|
-
for (const key of Object.keys(cached.keyframesHashTable)) {
|
|
1109
|
-
delete localTables.keyframesHashTable[`${filePath}-${key}`];
|
|
1110
|
-
}
|
|
1111
|
-
for (const key of Object.keys(cached.viewTransitionHashTable)) {
|
|
1112
|
-
delete localTables.viewTransitionHashTable[`${filePath}-${key}`];
|
|
1113
|
-
}
|
|
1114
|
-
for (const key of Object.keys(cached.createThemeHashTable)) {
|
|
1115
|
-
delete localTables.createThemeHashTable[`${filePath}-${key}`];
|
|
1116
|
-
}
|
|
1117
|
-
for (const key of Object.keys(cached.createStaticHashTable)) {
|
|
1118
|
-
delete localTables.createStaticHashTable[`${filePath}-${key}`];
|
|
1119
|
-
}
|
|
1120
|
-
for (const key of Object.keys(cached.createHashTable)) {
|
|
1121
|
-
delete localTables.createHashTable[`${filePath}-${key}`];
|
|
1122
|
-
delete localTables.createFunctionTable[`${filePath}-${key}`];
|
|
1123
|
-
}
|
|
1124
|
-
for (const key of Object.keys(cached.createStaticObjectTable)) {
|
|
1125
|
-
releaseObjectOwner('createStaticObjectTable', key, filePath, localTables.createStaticObjectTable);
|
|
1126
|
-
}
|
|
1127
|
-
for (const key of Object.keys(cached.keyframesObjectTable)) {
|
|
1128
|
-
releaseObjectOwner('keyframesObjectTable', key, filePath, localTables.keyframesObjectTable);
|
|
1129
|
-
}
|
|
1130
|
-
for (const key of Object.keys(cached.viewTransitionObjectTable)) {
|
|
1131
|
-
releaseObjectOwner('viewTransitionObjectTable', key, filePath, localTables.viewTransitionObjectTable);
|
|
1132
|
-
}
|
|
1133
|
-
for (const key of Object.keys(cached.createThemeObjectTable)) {
|
|
1134
|
-
releaseObjectOwner('createThemeObjectTable', key, filePath, localTables.createThemeObjectTable);
|
|
1135
|
-
}
|
|
1136
|
-
for (const key of Object.keys(cached.createThemeSelectorTable)) {
|
|
1137
|
-
releaseObjectOwner('createThemeSelectorTable', key, filePath, localTables.createThemeSelectorTable);
|
|
1138
|
-
}
|
|
1139
|
-
for (const key of Object.keys(cached.createObjectTable)) {
|
|
1140
|
-
releaseObjectOwner('createObjectTable', key, filePath, localTables.createObjectTable);
|
|
1141
|
-
}
|
|
1142
|
-
for (const key of Object.keys(cached.createAtomicMapTable)) {
|
|
1143
|
-
releaseObjectOwner('createAtomicMapTable', key, filePath, localTables.createAtomicMapTable);
|
|
1109
|
+
}
|
|
1110
|
+
fileKeyContributions.delete(filePath);
|
|
1144
1111
|
}
|
|
1145
1112
|
if (cached.componentPropsTable) {
|
|
1146
|
-
const table =
|
|
1113
|
+
const table = globalAgregatedTables.componentPropsTable;
|
|
1147
1114
|
for (const compKey of Object.keys(cached.componentPropsTable)) {
|
|
1148
1115
|
const propTable = table[compKey];
|
|
1149
1116
|
if (!propTable)
|
|
@@ -1252,8 +1219,8 @@ function scanAll(scanCwd = process.cwd()) {
|
|
|
1252
1219
|
invalidated.add(fp);
|
|
1253
1220
|
queue.push(fp);
|
|
1254
1221
|
}
|
|
1255
|
-
|
|
1256
|
-
const fp = queue
|
|
1222
|
+
for (let head = 0; head < queue.length; head++) {
|
|
1223
|
+
const fp = queue[head];
|
|
1257
1224
|
const deps = dependentsMap.get(fp);
|
|
1258
1225
|
if (deps) {
|
|
1259
1226
|
for (const dep of deps) {
|
|
@@ -1343,10 +1310,9 @@ function scanAll(scanCwd = process.cwd()) {
|
|
|
1343
1310
|
ordered.push(file);
|
|
1344
1311
|
};
|
|
1345
1312
|
parsedFiles.forEach(visitFile);
|
|
1346
|
-
parsedFiles.splice(0, parsedFiles.length, ...ordered);
|
|
1347
1313
|
for (let passNumber = 1; passNumber <= 2; passNumber++) {
|
|
1348
1314
|
const isFirstPass = passNumber === 1;
|
|
1349
|
-
for (const { filePath, ast, mtimeMs } of
|
|
1315
|
+
for (const { filePath, ast, mtimeMs } of ordered) {
|
|
1350
1316
|
try {
|
|
1351
1317
|
delete fileErrors[filePath];
|
|
1352
1318
|
let localConsts;
|
|
@@ -1584,9 +1550,11 @@ function scanAll(scanCwd = process.cwd()) {
|
|
|
1584
1550
|
if (method === 'createStatic') {
|
|
1585
1551
|
localStaticTable[name] = obj;
|
|
1586
1552
|
localTables.staticTable[uniqueKey] = obj;
|
|
1553
|
+
registerFileKey('staticTable', uniqueKey, filePath);
|
|
1587
1554
|
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
1588
1555
|
localCreateStaticHashTable[name] = hash;
|
|
1589
1556
|
localTables.createStaticHashTable[uniqueKey] = hash;
|
|
1557
|
+
registerFileKey('createStaticHashTable', uniqueKey, filePath);
|
|
1590
1558
|
localTables.createStaticObjectTable[hash] = obj;
|
|
1591
1559
|
localCreateStaticObjectTable[hash] = obj;
|
|
1592
1560
|
registerObjectOwner('createStaticObjectTable', hash, filePath);
|
|
@@ -1595,6 +1563,7 @@ function scanAll(scanCwd = process.cwd()) {
|
|
|
1595
1563
|
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
1596
1564
|
localKeyframesHashTable[name] = hash;
|
|
1597
1565
|
localTables.keyframesHashTable[uniqueKey] = hash;
|
|
1566
|
+
registerFileKey('keyframesHashTable', uniqueKey, filePath);
|
|
1598
1567
|
localTables.keyframesObjectTable[hash] = obj;
|
|
1599
1568
|
localKeyframesObjectTable[hash] = obj;
|
|
1600
1569
|
registerObjectOwner('keyframesObjectTable', hash, filePath);
|
|
@@ -1603,6 +1572,7 @@ function scanAll(scanCwd = process.cwd()) {
|
|
|
1603
1572
|
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
1604
1573
|
localViewTransitionHashTable[name] = hash;
|
|
1605
1574
|
localTables.viewTransitionHashTable[uniqueKey] = hash;
|
|
1575
|
+
registerFileKey('viewTransitionHashTable', uniqueKey, filePath);
|
|
1606
1576
|
localTables.viewTransitionObjectTable[hash] = obj;
|
|
1607
1577
|
localViewTransitionObjectTable[hash] = obj;
|
|
1608
1578
|
registerObjectOwner('viewTransitionObjectTable', hash, filePath);
|
|
@@ -1617,6 +1587,7 @@ function scanAll(scanCwd = process.cwd()) {
|
|
|
1617
1587
|
registerObjectOwner('createThemeObjectTable', hash, filePath);
|
|
1618
1588
|
localCreateThemeHashTable[name] = hash;
|
|
1619
1589
|
localTables.createThemeHashTable[uniqueKey] = hash;
|
|
1590
|
+
registerFileKey('createThemeHashTable', uniqueKey, filePath);
|
|
1620
1591
|
localTables.createThemeSelectorTable[hash] = selector;
|
|
1621
1592
|
localCreateThemeSelectorTable[hash] = selector;
|
|
1622
1593
|
registerObjectOwner('createThemeSelectorTable', hash, filePath);
|
|
@@ -1634,18 +1605,21 @@ function scanAll(scanCwd = process.cwd()) {
|
|
|
1634
1605
|
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
1635
1606
|
localCreateHashTable[name] = hash;
|
|
1636
1607
|
localTables.createHashTable[uniqueKey] = hash;
|
|
1608
|
+
registerFileKey('createHashTable', uniqueKey, filePath);
|
|
1637
1609
|
localTables.createObjectTable[hash] = obj;
|
|
1638
1610
|
localCreateObjectTable[hash] = obj;
|
|
1639
1611
|
registerObjectOwner('createObjectTable', hash, filePath);
|
|
1640
1612
|
const hasFunctionKey = objExpression.properties.some((prop) => prop.type === 'KeyValueProperty' &&
|
|
1641
1613
|
(prop.value.type === 'ArrowFunctionExpression' ||
|
|
1642
1614
|
prop.value.type === 'FunctionExpression'));
|
|
1643
|
-
if (hasFunctionKey)
|
|
1615
|
+
if (hasFunctionKey) {
|
|
1644
1616
|
localTables.createFunctionTable[uniqueKey] =
|
|
1645
1617
|
inlineOuterScope(objExpression, (property) => objectExpressionToObject({
|
|
1646
1618
|
...objExpression,
|
|
1647
1619
|
properties: [property],
|
|
1648
1620
|
}, scopedStaticTable, localKeyframesHashTable, localViewTransitionHashTable, localCreateThemeHashTable, localCreateThemeObjectTable, localCreateHashTable, localCreateStaticHashTable, localCreateStaticObjectTable, resolveVariable));
|
|
1621
|
+
registerFileKey('createFunctionTable', uniqueKey, filePath);
|
|
1622
|
+
}
|
|
1649
1623
|
const hashMap = {};
|
|
1650
1624
|
Object.entries(obj).forEach(([key, style]) => {
|
|
1651
1625
|
const records = (0, create_1.getStyleRecords)(style);
|
|
@@ -1661,10 +1635,8 @@ function scanAll(scanCwd = process.cwd()) {
|
|
|
1661
1635
|
}
|
|
1662
1636
|
}
|
|
1663
1637
|
}
|
|
1664
|
-
if (isFirstPass)
|
|
1665
|
-
extractAndCacheExports(filePath, ast, mtimeMs);
|
|
1638
|
+
if (isFirstPass)
|
|
1666
1639
|
continue;
|
|
1667
|
-
}
|
|
1668
1640
|
jsxPhaseQueue.push({
|
|
1669
1641
|
filePath,
|
|
1670
1642
|
ast,
|
|
@@ -2149,7 +2121,8 @@ function scanAll(scanCwd = process.cwd()) {
|
|
|
2149
2121
|
}
|
|
2150
2122
|
for (const props of Object.values(localTables.componentPropsTable ?? {})) {
|
|
2151
2123
|
for (const entries of Object.values(props))
|
|
2152
|
-
entries.sort((a, b) => a.filePath
|
|
2124
|
+
entries.sort((a, b) => (a.filePath < b.filePath ? -1 : a.filePath > b.filePath ? 1 : 0) ||
|
|
2125
|
+
a.spanStart - b.spanStart);
|
|
2153
2126
|
}
|
|
2154
2127
|
hasComputedOnce = true;
|
|
2155
2128
|
return snapshotTables();
|