@plumeria/webpack-plugin 6.3.1 → 6.3.2
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/index.js +75 -33
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -786,30 +786,44 @@ async function loader(source) {
|
|
|
786
786
|
}
|
|
787
787
|
else {
|
|
788
788
|
const table = {};
|
|
789
|
-
const
|
|
790
|
-
|
|
789
|
+
const groups = {};
|
|
790
|
+
let strayIdCounter = groupIdCounter + 1;
|
|
791
|
+
conditionals.forEach((c) => {
|
|
792
|
+
const gid = c.groupId !== undefined ? c.groupId : strayIdCounter++;
|
|
793
|
+
if (!groups[gid]) {
|
|
794
|
+
groups[gid] = [];
|
|
795
|
+
}
|
|
796
|
+
groups[gid].push(c);
|
|
797
|
+
});
|
|
798
|
+
const sortedGroupIds = Object.keys(groups)
|
|
799
|
+
.map(Number)
|
|
800
|
+
.sort((a, b) => a - b);
|
|
801
|
+
let totalCombinations = 1;
|
|
802
|
+
const groupMeta = sortedGroupIds.map((gid) => {
|
|
803
|
+
const options = groups[gid];
|
|
804
|
+
const isVariantGroup = options[0].groupId !== undefined;
|
|
805
|
+
const size = isVariantGroup ? options.length : 2;
|
|
806
|
+
const stride = totalCombinations;
|
|
807
|
+
totalCombinations *= size;
|
|
808
|
+
return { gid, options, size, stride, isVariantGroup };
|
|
809
|
+
});
|
|
810
|
+
for (let i = 0; i < totalCombinations; i++) {
|
|
791
811
|
let currentStyle = { ...baseStyle };
|
|
792
|
-
const
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
if (conditionals[j].groupId !== undefined) {
|
|
797
|
-
if (seenGroups.has(conditionals[j].groupId)) {
|
|
798
|
-
impossible = true;
|
|
799
|
-
break;
|
|
800
|
-
}
|
|
801
|
-
seenGroups.add(conditionals[j].groupId);
|
|
802
|
-
}
|
|
803
|
-
currentStyle = (0, utils_1.deepMerge)(currentStyle, conditionals[j].truthy);
|
|
812
|
+
for (const meta of groupMeta) {
|
|
813
|
+
const localIndex = Math.floor(i / meta.stride) % meta.size;
|
|
814
|
+
if (meta.isVariantGroup) {
|
|
815
|
+
currentStyle = (0, utils_1.deepMerge)(currentStyle, meta.options[localIndex].truthy);
|
|
804
816
|
}
|
|
805
817
|
else {
|
|
806
|
-
|
|
818
|
+
const cond = meta.options[0];
|
|
819
|
+
if (localIndex === 1) {
|
|
820
|
+
currentStyle = (0, utils_1.deepMerge)(currentStyle, cond.truthy);
|
|
821
|
+
}
|
|
822
|
+
else {
|
|
823
|
+
currentStyle = (0, utils_1.deepMerge)(currentStyle, cond.falsy);
|
|
824
|
+
}
|
|
807
825
|
}
|
|
808
826
|
}
|
|
809
|
-
if (impossible) {
|
|
810
|
-
table[i] = '';
|
|
811
|
-
continue;
|
|
812
|
-
}
|
|
813
827
|
if (process.env.NODE_ENV !== 'production') {
|
|
814
828
|
(0, utils_1.extractOndemandStyles)(currentStyle, extractedSheets, scannedTables);
|
|
815
829
|
}
|
|
@@ -823,22 +837,50 @@ async function loader(source) {
|
|
|
823
837
|
.join(' ');
|
|
824
838
|
table[i] = className;
|
|
825
839
|
}
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
840
|
+
const indexParts = [];
|
|
841
|
+
for (const meta of groupMeta) {
|
|
842
|
+
if (meta.isVariantGroup) {
|
|
843
|
+
const exprs = meta.options
|
|
844
|
+
.map((opt, idx) => {
|
|
845
|
+
if (idx === 0)
|
|
846
|
+
return null;
|
|
847
|
+
let testStr = opt.testString;
|
|
848
|
+
if (!testStr && opt.test) {
|
|
849
|
+
const start = opt.test.span.start - ast.span.start;
|
|
850
|
+
const end = opt.test.span.end - ast.span.start;
|
|
851
|
+
testStr = source.substring(start, end);
|
|
852
|
+
}
|
|
853
|
+
return `(!!(${testStr}) * ${idx})`;
|
|
854
|
+
})
|
|
855
|
+
.filter(Boolean);
|
|
856
|
+
if (exprs.length > 0) {
|
|
857
|
+
const groupSum = `(${exprs.join(' + ')})`;
|
|
858
|
+
if (meta.stride > 1) {
|
|
859
|
+
indexParts.push(`(${groupSum} * ${meta.stride})`);
|
|
860
|
+
}
|
|
861
|
+
else {
|
|
862
|
+
indexParts.push(groupSum);
|
|
863
|
+
}
|
|
834
864
|
}
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
const
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
865
|
+
}
|
|
866
|
+
else {
|
|
867
|
+
const cond = meta.options[0];
|
|
868
|
+
let testStr = cond.testString;
|
|
869
|
+
if (!testStr && cond.test) {
|
|
870
|
+
const start = cond.test.span.start - ast.span.start;
|
|
871
|
+
const end = cond.test.span.end - ast.span.start;
|
|
872
|
+
testStr = source.substring(start, end);
|
|
873
|
+
}
|
|
874
|
+
const expr = `(!!(${testStr}))`;
|
|
875
|
+
if (meta.stride > 1) {
|
|
876
|
+
indexParts.push(`(${expr} * ${meta.stride})`);
|
|
877
|
+
}
|
|
878
|
+
else {
|
|
879
|
+
indexParts.push(`(${expr} * 1)`);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
841
882
|
}
|
|
883
|
+
const indexExpr = indexParts.join(' + ') || '0';
|
|
842
884
|
const tableStr = JSON.stringify(table);
|
|
843
885
|
const replacement = `${tableStr}[${indexExpr}]`;
|
|
844
886
|
replacements.push({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/webpack-plugin",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.2",
|
|
4
4
|
"description": "Plumeria Webpack plugin",
|
|
5
5
|
"author": "Refirst 11",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"zero-virtual.css"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@plumeria/utils": "^6.3.
|
|
25
|
+
"@plumeria/utils": "^6.3.2"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@swc/core": "1.15.8",
|