@plumeria/unplugin 18.1.0 → 18.1.1
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/core.js +80 -27
- package/dist/core.mjs +80 -27
- package/package.json +2 -2
package/dist/core.js
CHANGED
|
@@ -813,6 +813,8 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
813
813
|
});
|
|
814
814
|
const conditionals = [];
|
|
815
815
|
let groupIdCounter = 0;
|
|
816
|
+
let sourceOrder = 0;
|
|
817
|
+
const baseChunks = [];
|
|
816
818
|
let baseStyle = {};
|
|
817
819
|
let isOptimizable = true;
|
|
818
820
|
const resolveCreateObject = (varName) => {
|
|
@@ -923,6 +925,7 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
923
925
|
if (staticStyle) {
|
|
924
926
|
if (currentTestStrings.length === 0) {
|
|
925
927
|
baseStyle = (0, utils_1.deepMerge)(baseStyle, staticStyle);
|
|
928
|
+
baseChunks.push({ order: sourceOrder++, style: staticStyle });
|
|
926
929
|
}
|
|
927
930
|
else {
|
|
928
931
|
conditionals.push({
|
|
@@ -931,6 +934,7 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
931
934
|
truthy: staticStyle,
|
|
932
935
|
falsy: {},
|
|
933
936
|
varName: undefined,
|
|
937
|
+
order: sourceOrder++,
|
|
934
938
|
});
|
|
935
939
|
}
|
|
936
940
|
return true;
|
|
@@ -947,6 +951,7 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
947
951
|
truthy: trueStyle,
|
|
948
952
|
falsy: falseStyle,
|
|
949
953
|
varName: undefined,
|
|
954
|
+
order: sourceOrder++,
|
|
950
955
|
});
|
|
951
956
|
return true;
|
|
952
957
|
}
|
|
@@ -998,6 +1003,7 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
998
1003
|
}
|
|
999
1004
|
if (propPossibilities && propPossibilities.length > 0) {
|
|
1000
1005
|
const currentGroupId = ++groupIdCounter;
|
|
1006
|
+
const currentOrder = sourceOrder++;
|
|
1001
1007
|
const uniqueEntries = [];
|
|
1002
1008
|
propPossibilities.forEach((entry) => {
|
|
1003
1009
|
if (!uniqueEntries.some((x) => x.key === entry.key)) {
|
|
@@ -1012,6 +1018,7 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1012
1018
|
truthy: entry.styleObj,
|
|
1013
1019
|
falsy: {},
|
|
1014
1020
|
groupId: currentGroupId,
|
|
1021
|
+
order: currentOrder,
|
|
1015
1022
|
groupName: undefined,
|
|
1016
1023
|
valueName: entry.key,
|
|
1017
1024
|
varName,
|
|
@@ -1068,11 +1075,18 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1068
1075
|
if (!groupVariants)
|
|
1069
1076
|
continue;
|
|
1070
1077
|
const currentGroupId = ++groupIdCounter;
|
|
1078
|
+
const currentOrder = sourceOrder++;
|
|
1071
1079
|
const valSource = getSource(valExpr);
|
|
1072
1080
|
if (valExpr.type === 'StringLiteral') {
|
|
1073
1081
|
const groupVariantsAsObj = groupVariants;
|
|
1074
|
-
|
|
1075
|
-
|
|
1082
|
+
const picked = groupVariantsAsObj[valExpr.value];
|
|
1083
|
+
if (picked) {
|
|
1084
|
+
baseStyle = (0, utils_1.deepMerge)(baseStyle, picked);
|
|
1085
|
+
baseChunks.push({
|
|
1086
|
+
order: sourceOrder++,
|
|
1087
|
+
style: picked,
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1076
1090
|
continue;
|
|
1077
1091
|
}
|
|
1078
1092
|
Object.entries(groupVariants).forEach(([optionName, style]) => {
|
|
@@ -1083,6 +1097,7 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1083
1097
|
truthy: style,
|
|
1084
1098
|
falsy: {},
|
|
1085
1099
|
groupId: currentGroupId,
|
|
1100
|
+
order: currentOrder,
|
|
1086
1101
|
groupName,
|
|
1087
1102
|
valueName: optionName,
|
|
1088
1103
|
varName,
|
|
@@ -1094,11 +1109,15 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1094
1109
|
}
|
|
1095
1110
|
const argSource = getSource(arg);
|
|
1096
1111
|
if (utils_1.t.isStringLiteral(arg)) {
|
|
1097
|
-
|
|
1098
|
-
|
|
1112
|
+
const picked = variantObj[arg.value];
|
|
1113
|
+
if (picked) {
|
|
1114
|
+
baseStyle = (0, utils_1.deepMerge)(baseStyle, picked);
|
|
1115
|
+
baseChunks.push({ order: sourceOrder++, style: picked });
|
|
1116
|
+
}
|
|
1099
1117
|
continue;
|
|
1100
1118
|
}
|
|
1101
1119
|
const currentGroupId = ++groupIdCounter;
|
|
1120
|
+
const currentOrder = sourceOrder++;
|
|
1102
1121
|
Object.entries(variantObj).forEach(([key, style]) => {
|
|
1103
1122
|
conditionals.push({
|
|
1104
1123
|
test: arg,
|
|
@@ -1107,6 +1126,7 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1107
1126
|
truthy: style,
|
|
1108
1127
|
falsy: {},
|
|
1109
1128
|
groupId: currentGroupId,
|
|
1129
|
+
order: currentOrder,
|
|
1110
1130
|
groupName: undefined,
|
|
1111
1131
|
valueName: key,
|
|
1112
1132
|
varName,
|
|
@@ -1134,6 +1154,7 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1134
1154
|
if (!groupVariants)
|
|
1135
1155
|
return;
|
|
1136
1156
|
const currentGroupId = ++groupIdCounter;
|
|
1157
|
+
const currentOrder = sourceOrder++;
|
|
1137
1158
|
Object.entries(groupVariants).forEach(([optionName, style]) => {
|
|
1138
1159
|
conditionals.push({
|
|
1139
1160
|
test: expr,
|
|
@@ -1142,6 +1163,7 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1142
1163
|
truthy: style,
|
|
1143
1164
|
falsy: {},
|
|
1144
1165
|
groupId: currentGroupId,
|
|
1166
|
+
order: currentOrder,
|
|
1145
1167
|
groupName,
|
|
1146
1168
|
valueName: optionName,
|
|
1147
1169
|
varName,
|
|
@@ -1160,6 +1182,7 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1160
1182
|
const dynExpr = expr.property.expression;
|
|
1161
1183
|
const dynSource = getSource(dynExpr);
|
|
1162
1184
|
const currentGroupId = ++groupIdCounter;
|
|
1185
|
+
const currentOrder = sourceOrder++;
|
|
1163
1186
|
Object.entries(styleObj).forEach(([optionName, style]) => {
|
|
1164
1187
|
conditionals.push({
|
|
1165
1188
|
test: dynExpr,
|
|
@@ -1168,6 +1191,7 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1168
1191
|
truthy: style,
|
|
1169
1192
|
falsy: {},
|
|
1170
1193
|
groupId: currentGroupId,
|
|
1194
|
+
order: currentOrder,
|
|
1171
1195
|
groupName: undefined,
|
|
1172
1196
|
valueName: optionName,
|
|
1173
1197
|
varName,
|
|
@@ -1179,6 +1203,7 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1179
1203
|
const decision = resolveDecision(expr);
|
|
1180
1204
|
if (decision && (decision.hasGroup || decision.leaves > 2)) {
|
|
1181
1205
|
const groupId = ++groupIdCounter;
|
|
1206
|
+
const currentOrder = sourceOrder++;
|
|
1182
1207
|
decision.options.forEach(({ value, style }) => conditionals.push({
|
|
1183
1208
|
test: expr,
|
|
1184
1209
|
testLHS: decision.keyExpr,
|
|
@@ -1186,6 +1211,7 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1186
1211
|
truthy: style,
|
|
1187
1212
|
falsy: {},
|
|
1188
1213
|
groupId,
|
|
1214
|
+
order: currentOrder,
|
|
1189
1215
|
groupName: undefined,
|
|
1190
1216
|
valueName: value,
|
|
1191
1217
|
varName: undefined,
|
|
@@ -1342,17 +1368,38 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1342
1368
|
});
|
|
1343
1369
|
if (Object.keys(baseConflict).length > 0 ||
|
|
1344
1370
|
conflictConditionals.length > 0) {
|
|
1345
|
-
const
|
|
1371
|
+
const ordered = [];
|
|
1372
|
+
baseChunks.forEach(({ order, style }) => {
|
|
1373
|
+
const conflicting = {};
|
|
1374
|
+
Object.entries(style).forEach(([key, value]) => {
|
|
1375
|
+
if (conflictingKeys.has(key))
|
|
1376
|
+
conflicting[key] = value;
|
|
1377
|
+
});
|
|
1378
|
+
if (Object.keys(conflicting).length === 0)
|
|
1379
|
+
return;
|
|
1380
|
+
ordered.push({
|
|
1381
|
+
order,
|
|
1382
|
+
dimension: {
|
|
1383
|
+
type: 'const',
|
|
1384
|
+
options: [
|
|
1385
|
+
{ value: undefined, style: conflicting, label: 'base' },
|
|
1386
|
+
],
|
|
1387
|
+
},
|
|
1388
|
+
});
|
|
1389
|
+
});
|
|
1346
1390
|
conflictConditionals
|
|
1347
1391
|
.filter((c) => c.groupId === undefined)
|
|
1348
1392
|
.forEach((c) => {
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1393
|
+
ordered.push({
|
|
1394
|
+
order: c.order ?? 0,
|
|
1395
|
+
dimension: {
|
|
1396
|
+
type: 'std',
|
|
1397
|
+
testExpr: c.testString ?? getSource(c.test),
|
|
1398
|
+
options: [
|
|
1399
|
+
{ value: 0, style: c.falsy, label: 'false' },
|
|
1400
|
+
{ value: 1, style: c.truthy, label: 'true' },
|
|
1401
|
+
],
|
|
1402
|
+
},
|
|
1356
1403
|
});
|
|
1357
1404
|
});
|
|
1358
1405
|
const conflictVarGroups = {};
|
|
@@ -1373,18 +1420,23 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1373
1420
|
opts.push({ ...off, truthy: {}, falsy: {} });
|
|
1374
1421
|
});
|
|
1375
1422
|
Object.entries(conflictVarGroups).forEach(([, opts]) => {
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1423
|
+
ordered.push({
|
|
1424
|
+
order: opts[0].order ?? 0,
|
|
1425
|
+
dimension: {
|
|
1426
|
+
type: 'var',
|
|
1427
|
+
testExpr: opts[0].testLHS ??
|
|
1428
|
+
opts[0].testString ??
|
|
1429
|
+
getSource(opts[0].test),
|
|
1430
|
+
options: opts.map((opt) => ({
|
|
1431
|
+
value: opt.valueName,
|
|
1432
|
+
style: opt.truthy,
|
|
1433
|
+
label: opt.valueName || 'default',
|
|
1434
|
+
})),
|
|
1435
|
+
},
|
|
1386
1436
|
});
|
|
1387
1437
|
});
|
|
1438
|
+
ordered.sort((a, b) => a.order - b.order);
|
|
1439
|
+
const dimensions = ordered.map((o) => o.dimension);
|
|
1388
1440
|
const results = {};
|
|
1389
1441
|
const recurse = (dimIndex, currentStyle, keyParts) => {
|
|
1390
1442
|
if (dimIndex >= dimensions.length) {
|
|
@@ -1395,18 +1447,19 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1395
1447
|
results[keyParts.join('__')] = className;
|
|
1396
1448
|
return;
|
|
1397
1449
|
}
|
|
1398
|
-
dimensions[dimIndex]
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1450
|
+
const dimension = dimensions[dimIndex];
|
|
1451
|
+
dimension.options.forEach((opt) => recurse(dimIndex + 1, (0, utils_1.deepMerge)(currentStyle, opt.style), dimension.type === 'const'
|
|
1452
|
+
? keyParts
|
|
1453
|
+
: [...keyParts, String(opt.value)]));
|
|
1402
1454
|
};
|
|
1403
|
-
recurse(0,
|
|
1455
|
+
recurse(0, {}, []);
|
|
1404
1456
|
const baseConflictClass = Object.keys(baseConflict).length > 0
|
|
1405
1457
|
? processStyleRecords(baseConflict)
|
|
1406
1458
|
.map((r) => r.hash)
|
|
1407
1459
|
.join(' ')
|
|
1408
1460
|
: '';
|
|
1409
1461
|
const masterKeyExpr = dimensions
|
|
1462
|
+
.filter((dim) => dim.type !== 'const')
|
|
1410
1463
|
.map((dim) => dim.type === 'std'
|
|
1411
1464
|
? `(${dim.testExpr} ? "1" : "0")`
|
|
1412
1465
|
: dim.testExpr || '""')
|
package/dist/core.mjs
CHANGED
|
@@ -777,6 +777,8 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
777
777
|
});
|
|
778
778
|
const conditionals = [];
|
|
779
779
|
let groupIdCounter = 0;
|
|
780
|
+
let sourceOrder = 0;
|
|
781
|
+
const baseChunks = [];
|
|
780
782
|
let baseStyle = {};
|
|
781
783
|
let isOptimizable = true;
|
|
782
784
|
const resolveCreateObject = (varName) => {
|
|
@@ -887,6 +889,7 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
887
889
|
if (staticStyle) {
|
|
888
890
|
if (currentTestStrings.length === 0) {
|
|
889
891
|
baseStyle = deepMerge(baseStyle, staticStyle);
|
|
892
|
+
baseChunks.push({ order: sourceOrder++, style: staticStyle });
|
|
890
893
|
}
|
|
891
894
|
else {
|
|
892
895
|
conditionals.push({
|
|
@@ -895,6 +898,7 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
895
898
|
truthy: staticStyle,
|
|
896
899
|
falsy: {},
|
|
897
900
|
varName: undefined,
|
|
901
|
+
order: sourceOrder++,
|
|
898
902
|
});
|
|
899
903
|
}
|
|
900
904
|
return true;
|
|
@@ -911,6 +915,7 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
911
915
|
truthy: trueStyle,
|
|
912
916
|
falsy: falseStyle,
|
|
913
917
|
varName: undefined,
|
|
918
|
+
order: sourceOrder++,
|
|
914
919
|
});
|
|
915
920
|
return true;
|
|
916
921
|
}
|
|
@@ -962,6 +967,7 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
962
967
|
}
|
|
963
968
|
if (propPossibilities && propPossibilities.length > 0) {
|
|
964
969
|
const currentGroupId = ++groupIdCounter;
|
|
970
|
+
const currentOrder = sourceOrder++;
|
|
965
971
|
const uniqueEntries = [];
|
|
966
972
|
propPossibilities.forEach((entry) => {
|
|
967
973
|
if (!uniqueEntries.some((x) => x.key === entry.key)) {
|
|
@@ -976,6 +982,7 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
976
982
|
truthy: entry.styleObj,
|
|
977
983
|
falsy: {},
|
|
978
984
|
groupId: currentGroupId,
|
|
985
|
+
order: currentOrder,
|
|
979
986
|
groupName: undefined,
|
|
980
987
|
valueName: entry.key,
|
|
981
988
|
varName,
|
|
@@ -1032,11 +1039,18 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1032
1039
|
if (!groupVariants)
|
|
1033
1040
|
continue;
|
|
1034
1041
|
const currentGroupId = ++groupIdCounter;
|
|
1042
|
+
const currentOrder = sourceOrder++;
|
|
1035
1043
|
const valSource = getSource(valExpr);
|
|
1036
1044
|
if (valExpr.type === 'StringLiteral') {
|
|
1037
1045
|
const groupVariantsAsObj = groupVariants;
|
|
1038
|
-
|
|
1039
|
-
|
|
1046
|
+
const picked = groupVariantsAsObj[valExpr.value];
|
|
1047
|
+
if (picked) {
|
|
1048
|
+
baseStyle = deepMerge(baseStyle, picked);
|
|
1049
|
+
baseChunks.push({
|
|
1050
|
+
order: sourceOrder++,
|
|
1051
|
+
style: picked,
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1040
1054
|
continue;
|
|
1041
1055
|
}
|
|
1042
1056
|
Object.entries(groupVariants).forEach(([optionName, style]) => {
|
|
@@ -1047,6 +1061,7 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1047
1061
|
truthy: style,
|
|
1048
1062
|
falsy: {},
|
|
1049
1063
|
groupId: currentGroupId,
|
|
1064
|
+
order: currentOrder,
|
|
1050
1065
|
groupName,
|
|
1051
1066
|
valueName: optionName,
|
|
1052
1067
|
varName,
|
|
@@ -1058,11 +1073,15 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1058
1073
|
}
|
|
1059
1074
|
const argSource = getSource(arg);
|
|
1060
1075
|
if (t.isStringLiteral(arg)) {
|
|
1061
|
-
|
|
1062
|
-
|
|
1076
|
+
const picked = variantObj[arg.value];
|
|
1077
|
+
if (picked) {
|
|
1078
|
+
baseStyle = deepMerge(baseStyle, picked);
|
|
1079
|
+
baseChunks.push({ order: sourceOrder++, style: picked });
|
|
1080
|
+
}
|
|
1063
1081
|
continue;
|
|
1064
1082
|
}
|
|
1065
1083
|
const currentGroupId = ++groupIdCounter;
|
|
1084
|
+
const currentOrder = sourceOrder++;
|
|
1066
1085
|
Object.entries(variantObj).forEach(([key, style]) => {
|
|
1067
1086
|
conditionals.push({
|
|
1068
1087
|
test: arg,
|
|
@@ -1071,6 +1090,7 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1071
1090
|
truthy: style,
|
|
1072
1091
|
falsy: {},
|
|
1073
1092
|
groupId: currentGroupId,
|
|
1093
|
+
order: currentOrder,
|
|
1074
1094
|
groupName: undefined,
|
|
1075
1095
|
valueName: key,
|
|
1076
1096
|
varName,
|
|
@@ -1098,6 +1118,7 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1098
1118
|
if (!groupVariants)
|
|
1099
1119
|
return;
|
|
1100
1120
|
const currentGroupId = ++groupIdCounter;
|
|
1121
|
+
const currentOrder = sourceOrder++;
|
|
1101
1122
|
Object.entries(groupVariants).forEach(([optionName, style]) => {
|
|
1102
1123
|
conditionals.push({
|
|
1103
1124
|
test: expr,
|
|
@@ -1106,6 +1127,7 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1106
1127
|
truthy: style,
|
|
1107
1128
|
falsy: {},
|
|
1108
1129
|
groupId: currentGroupId,
|
|
1130
|
+
order: currentOrder,
|
|
1109
1131
|
groupName,
|
|
1110
1132
|
valueName: optionName,
|
|
1111
1133
|
varName,
|
|
@@ -1124,6 +1146,7 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1124
1146
|
const dynExpr = expr.property.expression;
|
|
1125
1147
|
const dynSource = getSource(dynExpr);
|
|
1126
1148
|
const currentGroupId = ++groupIdCounter;
|
|
1149
|
+
const currentOrder = sourceOrder++;
|
|
1127
1150
|
Object.entries(styleObj).forEach(([optionName, style]) => {
|
|
1128
1151
|
conditionals.push({
|
|
1129
1152
|
test: dynExpr,
|
|
@@ -1132,6 +1155,7 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1132
1155
|
truthy: style,
|
|
1133
1156
|
falsy: {},
|
|
1134
1157
|
groupId: currentGroupId,
|
|
1158
|
+
order: currentOrder,
|
|
1135
1159
|
groupName: undefined,
|
|
1136
1160
|
valueName: optionName,
|
|
1137
1161
|
varName,
|
|
@@ -1143,6 +1167,7 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1143
1167
|
const decision = resolveDecision(expr);
|
|
1144
1168
|
if (decision && (decision.hasGroup || decision.leaves > 2)) {
|
|
1145
1169
|
const groupId = ++groupIdCounter;
|
|
1170
|
+
const currentOrder = sourceOrder++;
|
|
1146
1171
|
decision.options.forEach(({ value, style }) => conditionals.push({
|
|
1147
1172
|
test: expr,
|
|
1148
1173
|
testLHS: decision.keyExpr,
|
|
@@ -1150,6 +1175,7 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1150
1175
|
truthy: style,
|
|
1151
1176
|
falsy: {},
|
|
1152
1177
|
groupId,
|
|
1178
|
+
order: currentOrder,
|
|
1153
1179
|
groupName: undefined,
|
|
1154
1180
|
valueName: value,
|
|
1155
1181
|
varName: undefined,
|
|
@@ -1306,17 +1332,38 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1306
1332
|
});
|
|
1307
1333
|
if (Object.keys(baseConflict).length > 0 ||
|
|
1308
1334
|
conflictConditionals.length > 0) {
|
|
1309
|
-
const
|
|
1335
|
+
const ordered = [];
|
|
1336
|
+
baseChunks.forEach(({ order, style }) => {
|
|
1337
|
+
const conflicting = {};
|
|
1338
|
+
Object.entries(style).forEach(([key, value]) => {
|
|
1339
|
+
if (conflictingKeys.has(key))
|
|
1340
|
+
conflicting[key] = value;
|
|
1341
|
+
});
|
|
1342
|
+
if (Object.keys(conflicting).length === 0)
|
|
1343
|
+
return;
|
|
1344
|
+
ordered.push({
|
|
1345
|
+
order,
|
|
1346
|
+
dimension: {
|
|
1347
|
+
type: 'const',
|
|
1348
|
+
options: [
|
|
1349
|
+
{ value: undefined, style: conflicting, label: 'base' },
|
|
1350
|
+
],
|
|
1351
|
+
},
|
|
1352
|
+
});
|
|
1353
|
+
});
|
|
1310
1354
|
conflictConditionals
|
|
1311
1355
|
.filter((c) => c.groupId === undefined)
|
|
1312
1356
|
.forEach((c) => {
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1357
|
+
ordered.push({
|
|
1358
|
+
order: c.order ?? 0,
|
|
1359
|
+
dimension: {
|
|
1360
|
+
type: 'std',
|
|
1361
|
+
testExpr: c.testString ?? getSource(c.test),
|
|
1362
|
+
options: [
|
|
1363
|
+
{ value: 0, style: c.falsy, label: 'false' },
|
|
1364
|
+
{ value: 1, style: c.truthy, label: 'true' },
|
|
1365
|
+
],
|
|
1366
|
+
},
|
|
1320
1367
|
});
|
|
1321
1368
|
});
|
|
1322
1369
|
const conflictVarGroups = {};
|
|
@@ -1337,18 +1384,23 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1337
1384
|
opts.push({ ...off, truthy: {}, falsy: {} });
|
|
1338
1385
|
});
|
|
1339
1386
|
Object.entries(conflictVarGroups).forEach(([, opts]) => {
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1387
|
+
ordered.push({
|
|
1388
|
+
order: opts[0].order ?? 0,
|
|
1389
|
+
dimension: {
|
|
1390
|
+
type: 'var',
|
|
1391
|
+
testExpr: opts[0].testLHS ??
|
|
1392
|
+
opts[0].testString ??
|
|
1393
|
+
getSource(opts[0].test),
|
|
1394
|
+
options: opts.map((opt) => ({
|
|
1395
|
+
value: opt.valueName,
|
|
1396
|
+
style: opt.truthy,
|
|
1397
|
+
label: opt.valueName || 'default',
|
|
1398
|
+
})),
|
|
1399
|
+
},
|
|
1350
1400
|
});
|
|
1351
1401
|
});
|
|
1402
|
+
ordered.sort((a, b) => a.order - b.order);
|
|
1403
|
+
const dimensions = ordered.map((o) => o.dimension);
|
|
1352
1404
|
const results = {};
|
|
1353
1405
|
const recurse = (dimIndex, currentStyle, keyParts) => {
|
|
1354
1406
|
if (dimIndex >= dimensions.length) {
|
|
@@ -1359,18 +1411,19 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1359
1411
|
results[keyParts.join('__')] = className;
|
|
1360
1412
|
return;
|
|
1361
1413
|
}
|
|
1362
|
-
dimensions[dimIndex]
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1414
|
+
const dimension = dimensions[dimIndex];
|
|
1415
|
+
dimension.options.forEach((opt) => recurse(dimIndex + 1, deepMerge(currentStyle, opt.style), dimension.type === 'const'
|
|
1416
|
+
? keyParts
|
|
1417
|
+
: [...keyParts, String(opt.value)]));
|
|
1366
1418
|
};
|
|
1367
|
-
recurse(0,
|
|
1419
|
+
recurse(0, {}, []);
|
|
1368
1420
|
const baseConflictClass = Object.keys(baseConflict).length > 0
|
|
1369
1421
|
? processStyleRecords(baseConflict)
|
|
1370
1422
|
.map((r) => r.hash)
|
|
1371
1423
|
.join(' ')
|
|
1372
1424
|
: '';
|
|
1373
1425
|
const masterKeyExpr = dimensions
|
|
1426
|
+
.filter((dim) => dim.type !== 'const')
|
|
1374
1427
|
.map((dim) => dim.type === 'std'
|
|
1375
1428
|
? `(${dim.testExpr} ? "1" : "0")`
|
|
1376
1429
|
: dim.testExpr || '""')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/unplugin",
|
|
3
|
-
"version": "18.1.
|
|
3
|
+
"version": "18.1.1",
|
|
4
4
|
"description": "Universal Plumeria plugin for various build tools",
|
|
5
5
|
"author": "Refirst 11",
|
|
6
6
|
"license": "MIT",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"dependencies": {
|
|
90
90
|
"@rollup/pluginutils": "^5.4.0",
|
|
91
91
|
"unplugin": "^3.0.0",
|
|
92
|
-
"@plumeria/utils": "^18.1.
|
|
92
|
+
"@plumeria/utils": "^18.1.1"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
95
|
"@swc/core": "1.15.43",
|