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