@plumeria/compiler 18.0.0 → 18.1.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 +43 -4
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -441,6 +441,29 @@ function compileCSS(options) {
|
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
443
|
};
|
|
444
|
+
const resolveBracketGroupStyles = (node) => {
|
|
445
|
+
if (!utils_1.t.isMemberExpression(node) ||
|
|
446
|
+
!utils_1.t.isIdentifier(node.object) ||
|
|
447
|
+
node.property.type !== 'Computed' ||
|
|
448
|
+
utils_1.t.isStringLiteral(node.property.expression)) {
|
|
449
|
+
return null;
|
|
450
|
+
}
|
|
451
|
+
const varName = node.object.value;
|
|
452
|
+
const styleInfo = ctx.localCreateStyles[varName];
|
|
453
|
+
let obj;
|
|
454
|
+
if (styleInfo && styleInfo.type === 'create') {
|
|
455
|
+
obj = styleInfo.obj;
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
const hash = ctx.mergedCreateTable[varName];
|
|
459
|
+
if (hash) {
|
|
460
|
+
obj = ctx.scannedTables.createObjectTable[hash];
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
if (!obj)
|
|
464
|
+
return null;
|
|
465
|
+
return Object.values(obj).filter((v) => typeof v === 'object' && v !== null);
|
|
466
|
+
};
|
|
444
467
|
const collectConditions = (node, currentTestStrings = []) => {
|
|
445
468
|
if (node.type === 'ConditionalExpression') {
|
|
446
469
|
const testSource = getSource(node.test);
|
|
@@ -494,6 +517,19 @@ function compileCSS(options) {
|
|
|
494
517
|
}
|
|
495
518
|
return true;
|
|
496
519
|
}
|
|
520
|
+
if (currentTestStrings.length > 0) {
|
|
521
|
+
const groupStyles = resolveBracketGroupStyles(node);
|
|
522
|
+
if (groupStyles) {
|
|
523
|
+
groupStyles.forEach((style) => conditionals.push({
|
|
524
|
+
test: node,
|
|
525
|
+
testString: currentTestStrings.join(' && '),
|
|
526
|
+
truthy: style,
|
|
527
|
+
falsy: {},
|
|
528
|
+
varName: undefined,
|
|
529
|
+
}));
|
|
530
|
+
return true;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
497
533
|
assertResolvable(node);
|
|
498
534
|
return false;
|
|
499
535
|
};
|
|
@@ -838,11 +874,14 @@ function compileCSS(options) {
|
|
|
838
874
|
processCall(path.node);
|
|
839
875
|
},
|
|
840
876
|
JSXOpeningElement({ node }) {
|
|
841
|
-
if (node.name.type
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
877
|
+
if (node.name.type === 'Identifier') {
|
|
878
|
+
const tagName = node.name.value;
|
|
879
|
+
if (tagName[0] !== tagName[0].toUpperCase())
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
else if (node.name.type !== 'JSXMemberExpression') {
|
|
845
883
|
return;
|
|
884
|
+
}
|
|
846
885
|
node.attributes.forEach((attr) => {
|
|
847
886
|
if (attr.type !== 'JSXAttribute')
|
|
848
887
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/compiler",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.1.0",
|
|
4
4
|
"description": "Plumeria swc based compiler for statically extracting css",
|
|
5
5
|
"author": "Refirst 11",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dist/"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@plumeria/utils": "^18.
|
|
24
|
+
"@plumeria/utils": "^18.1.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@rust-gear/glob": "1.1.0",
|