@plumeria/webpack-plugin 6.3.1 → 7.0.0
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 +80 -40
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -222,7 +222,7 @@ async function loader(source) {
|
|
|
222
222
|
if (obj) {
|
|
223
223
|
const hashMap = {};
|
|
224
224
|
Object.entries(obj).forEach(([key, style]) => {
|
|
225
|
-
const records = (0, utils_1.getStyleRecords)(
|
|
225
|
+
const records = (0, utils_1.getStyleRecords)(style);
|
|
226
226
|
if (!isProduction) {
|
|
227
227
|
(0, utils_1.extractOndemandStyles)(style, extractedSheets, scannedTables);
|
|
228
228
|
records.forEach((r) => {
|
|
@@ -420,9 +420,9 @@ async function loader(source) {
|
|
|
420
420
|
const obj = (0, utils_1.objectExpressionToObject)(args[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedCreateThemeHashTable, scannedTables.createThemeObjectTable, mergedCreateTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable, mergedVariantsTable);
|
|
421
421
|
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
422
422
|
scannedTables.createObjectTable[hash] = obj;
|
|
423
|
-
Object.entries(obj).forEach(([
|
|
423
|
+
Object.entries(obj).forEach(([_key, style]) => {
|
|
424
424
|
if (typeof style === 'object' && style !== null) {
|
|
425
|
-
const records = (0, utils_1.getStyleRecords)(
|
|
425
|
+
const records = (0, utils_1.getStyleRecords)(style);
|
|
426
426
|
if (!isProduction) {
|
|
427
427
|
(0, utils_1.extractOndemandStyles)(style, extractedSheets, scannedTables);
|
|
428
428
|
records.forEach((r) => addSheet(r.sheet));
|
|
@@ -772,8 +772,7 @@ async function loader(source) {
|
|
|
772
772
|
if (!isProduction) {
|
|
773
773
|
(0, utils_1.extractOndemandStyles)(baseStyle, extractedSheets, scannedTables);
|
|
774
774
|
}
|
|
775
|
-
const
|
|
776
|
-
const records = (0, utils_1.getStyleRecords)(hash, baseStyle);
|
|
775
|
+
const records = (0, utils_1.getStyleRecords)(baseStyle);
|
|
777
776
|
if (!isProduction) {
|
|
778
777
|
records.forEach((r) => addSheet(r.sheet));
|
|
779
778
|
}
|
|
@@ -786,35 +785,48 @@ async function loader(source) {
|
|
|
786
785
|
}
|
|
787
786
|
else {
|
|
788
787
|
const table = {};
|
|
789
|
-
const
|
|
790
|
-
|
|
788
|
+
const groups = {};
|
|
789
|
+
let strayIdCounter = groupIdCounter + 1;
|
|
790
|
+
conditionals.forEach((c) => {
|
|
791
|
+
const gid = c.groupId !== undefined ? c.groupId : strayIdCounter++;
|
|
792
|
+
if (!groups[gid]) {
|
|
793
|
+
groups[gid] = [];
|
|
794
|
+
}
|
|
795
|
+
groups[gid].push(c);
|
|
796
|
+
});
|
|
797
|
+
const sortedGroupIds = Object.keys(groups)
|
|
798
|
+
.map(Number)
|
|
799
|
+
.sort((a, b) => a - b);
|
|
800
|
+
let totalCombinations = 1;
|
|
801
|
+
const groupMeta = sortedGroupIds.map((gid) => {
|
|
802
|
+
const options = groups[gid];
|
|
803
|
+
const isVariantGroup = options[0].groupId !== undefined;
|
|
804
|
+
const size = isVariantGroup ? options.length : 2;
|
|
805
|
+
const stride = totalCombinations;
|
|
806
|
+
totalCombinations *= size;
|
|
807
|
+
return { gid, options, size, stride, isVariantGroup };
|
|
808
|
+
});
|
|
809
|
+
for (let i = 0; i < totalCombinations; i++) {
|
|
791
810
|
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);
|
|
811
|
+
for (const meta of groupMeta) {
|
|
812
|
+
const localIndex = Math.floor(i / meta.stride) % meta.size;
|
|
813
|
+
if (meta.isVariantGroup) {
|
|
814
|
+
currentStyle = (0, utils_1.deepMerge)(currentStyle, meta.options[localIndex].truthy);
|
|
804
815
|
}
|
|
805
816
|
else {
|
|
806
|
-
|
|
817
|
+
const cond = meta.options[0];
|
|
818
|
+
if (localIndex === 1) {
|
|
819
|
+
currentStyle = (0, utils_1.deepMerge)(currentStyle, cond.truthy);
|
|
820
|
+
}
|
|
821
|
+
else {
|
|
822
|
+
currentStyle = (0, utils_1.deepMerge)(currentStyle, cond.falsy);
|
|
823
|
+
}
|
|
807
824
|
}
|
|
808
825
|
}
|
|
809
|
-
if (impossible) {
|
|
810
|
-
table[i] = '';
|
|
811
|
-
continue;
|
|
812
|
-
}
|
|
813
826
|
if (process.env.NODE_ENV !== 'production') {
|
|
814
827
|
(0, utils_1.extractOndemandStyles)(currentStyle, extractedSheets, scannedTables);
|
|
815
828
|
}
|
|
816
|
-
const
|
|
817
|
-
const records = (0, utils_1.getStyleRecords)(hash, currentStyle);
|
|
829
|
+
const records = (0, utils_1.getStyleRecords)(currentStyle);
|
|
818
830
|
if (process.env.NODE_ENV !== 'production') {
|
|
819
831
|
records.forEach((r) => extractedSheets.push(r.sheet));
|
|
820
832
|
}
|
|
@@ -823,22 +835,50 @@ async function loader(source) {
|
|
|
823
835
|
.join(' ');
|
|
824
836
|
table[i] = className;
|
|
825
837
|
}
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
838
|
+
const indexParts = [];
|
|
839
|
+
for (const meta of groupMeta) {
|
|
840
|
+
if (meta.isVariantGroup) {
|
|
841
|
+
const exprs = meta.options
|
|
842
|
+
.map((opt, idx) => {
|
|
843
|
+
if (idx === 0)
|
|
844
|
+
return null;
|
|
845
|
+
let testStr = opt.testString;
|
|
846
|
+
if (!testStr && opt.test) {
|
|
847
|
+
const start = opt.test.span.start - ast.span.start;
|
|
848
|
+
const end = opt.test.span.end - ast.span.start;
|
|
849
|
+
testStr = source.substring(start, end);
|
|
850
|
+
}
|
|
851
|
+
return `(!!(${testStr}) * ${idx})`;
|
|
852
|
+
})
|
|
853
|
+
.filter(Boolean);
|
|
854
|
+
if (exprs.length > 0) {
|
|
855
|
+
const groupSum = `(${exprs.join(' + ')})`;
|
|
856
|
+
if (meta.stride > 1) {
|
|
857
|
+
indexParts.push(`(${groupSum} * ${meta.stride})`);
|
|
858
|
+
}
|
|
859
|
+
else {
|
|
860
|
+
indexParts.push(groupSum);
|
|
861
|
+
}
|
|
834
862
|
}
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
const
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
863
|
+
}
|
|
864
|
+
else {
|
|
865
|
+
const cond = meta.options[0];
|
|
866
|
+
let testStr = cond.testString;
|
|
867
|
+
if (!testStr && cond.test) {
|
|
868
|
+
const start = cond.test.span.start - ast.span.start;
|
|
869
|
+
const end = cond.test.span.end - ast.span.start;
|
|
870
|
+
testStr = source.substring(start, end);
|
|
871
|
+
}
|
|
872
|
+
const expr = `(!!(${testStr}))`;
|
|
873
|
+
if (meta.stride > 1) {
|
|
874
|
+
indexParts.push(`(${expr} * ${meta.stride})`);
|
|
875
|
+
}
|
|
876
|
+
else {
|
|
877
|
+
indexParts.push(`(${expr} * 1)`);
|
|
878
|
+
}
|
|
879
|
+
}
|
|
841
880
|
}
|
|
881
|
+
const indexExpr = indexParts.join(' + ') || '0';
|
|
842
882
|
const tableStr = JSON.stringify(table);
|
|
843
883
|
const replacement = `${tableStr}[${indexExpr}]`;
|
|
844
884
|
replacements.push({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/webpack-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Plumeria Webpack plugin",
|
|
5
5
|
"author": "Refirst 11",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"zero-virtual.css"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@plumeria/utils": "^
|
|
25
|
+
"@plumeria/utils": "^7.0.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@swc/core": "1.15.8",
|
|
29
29
|
"webpack": "5.101.0",
|
|
30
|
-
"zss-engine": "2.2.
|
|
30
|
+
"zss-engine": "2.2.3"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public",
|