@plumeria/compiler 18.0.1 → 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.
Files changed (2) hide show
  1. package/dist/index.js +36 -0
  2. 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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/compiler",
3
- "version": "18.0.1",
3
+ "version": "18.1.1",
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.0.1"
24
+ "@plumeria/utils": "^18.1.1"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@rust-gear/glob": "1.1.0",