@plumeria/unplugin 18.2.14 → 18.2.15

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/core.js CHANGED
@@ -322,8 +322,8 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
322
322
  extractedSheets.push(sheet);
323
323
  }
324
324
  };
325
- const processStyleRecords = (style) => {
326
- const records = (0, utils_1.getStyleRecords)(style);
325
+ const processStyleRecords = (style, weights) => {
326
+ const records = (0, utils_1.getStyleRecords)(style, weights);
327
327
  (0, utils_1.extractOndemandStyles)(style, extractedSheets, scannedTables);
328
328
  records.forEach((r) => {
329
329
  addSheet(r.sheet);
@@ -1470,6 +1470,13 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
1470
1470
  dynamicVars,
1471
1471
  };
1472
1472
  }
1473
+ const stateSources = baseChunks.map(({ order, style }) => ({ order, style: style }));
1474
+ conditionals.forEach((c) => {
1475
+ const order = c.order ?? 0;
1476
+ stateSources.push({ order, style: c.truthy });
1477
+ stateSources.push({ order, style: c.falsy });
1478
+ });
1479
+ const stateWeights = (0, utils_1.getStateWeights)(stateSources);
1473
1480
  const participation = {};
1474
1481
  const registerParticipation = (style, sourceId) => {
1475
1482
  Object.keys(style).forEach((key) => {
@@ -1555,7 +1562,7 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
1555
1562
  if (existingClass)
1556
1563
  classParts.push(existingClass);
1557
1564
  if (Object.keys(baseIndependent).length > 0) {
1558
- const className = processStyleRecords(baseIndependent)
1565
+ const className = processStyleRecords(baseIndependent, stateWeights)
1559
1566
  .map((r) => r.hash)
1560
1567
  .join(' ');
1561
1568
  if (className)
@@ -1567,7 +1574,7 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
1567
1574
  const processBranch = (style) => {
1568
1575
  if (Object.keys(style).length === 0)
1569
1576
  return '""';
1570
- return JSON.stringify(processStyleRecords(style)
1577
+ return JSON.stringify(processStyleRecords(style, stateWeights)
1571
1578
  .map((r) => r.hash)
1572
1579
  .join(' '));
1573
1580
  };
@@ -1589,7 +1596,7 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
1589
1596
  const lookupMap = {};
1590
1597
  options.forEach((opt) => {
1591
1598
  if (opt.valueName !== undefined && opt.truthy) {
1592
- const className = processStyleRecords(opt.truthy)
1599
+ const className = processStyleRecords(opt.truthy, stateWeights)
1593
1600
  .map((r) => r.hash)
1594
1601
  .join(' ');
1595
1602
  if (className)
@@ -1689,7 +1696,7 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
1689
1696
  const results = {};
1690
1697
  const recurse = (dimIndex, currentStyle, keyParts) => {
1691
1698
  if (dimIndex >= dimensions.length) {
1692
- const className = processStyleRecords(currentStyle)
1699
+ const className = processStyleRecords(currentStyle, stateWeights)
1693
1700
  .map((r) => r.hash)
1694
1701
  .join(' ');
1695
1702
  if (className)
@@ -1703,7 +1710,7 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
1703
1710
  };
1704
1711
  recurse(0, {}, []);
1705
1712
  const baseConflictClass = Object.keys(baseConflict).length > 0
1706
- ? processStyleRecords(baseConflict)
1713
+ ? processStyleRecords(baseConflict, stateWeights)
1707
1714
  .map((r) => r.hash)
1708
1715
  .join(' ')
1709
1716
  : '';
package/dist/core.mjs CHANGED
@@ -2,7 +2,7 @@ import { createFilter } from '@rollup/pluginutils';
2
2
  import { parseSync } from '@swc/core';
3
3
  import * as path from 'path';
4
4
  import { applyCssValue, genBase36Hash, exceptionCamelCase, camelToKebabCase, isAtRule, } from 'zss-engine';
5
- import { traverse, collectReferenceIdentifiers, getStyleRecords, collectLocalConsts, objectExpressionToObject, t, getRootIdentifier, extractOndemandStyles, deepMerge, scanAll, resolveImportPath, getLeadingCommentLength, optimizer, getFileDependencies, resolveExport, resolveComponentKey, DEFAULT_STYLE_PROP, } from '@plumeria/utils';
5
+ import { traverse, collectReferenceIdentifiers, getStyleRecords, getStateWeights, collectLocalConsts, objectExpressionToObject, t, getRootIdentifier, extractOndemandStyles, deepMerge, scanAll, resolveImportPath, getLeadingCommentLength, optimizer, getFileDependencies, resolveExport, resolveComponentKey, DEFAULT_STYLE_PROP, } from '@plumeria/utils';
6
6
  export const TARGET_EXTENSIONS = ['ts', 'tsx', 'js', 'jsx'];
7
7
  export const EXTENSION_PATTERN = /\.(ts|tsx|js|jsx)$/;
8
8
  const isStaticArgValue = (node) => node.type === 'StringLiteral' ||
@@ -286,8 +286,8 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
286
286
  extractedSheets.push(sheet);
287
287
  }
288
288
  };
289
- const processStyleRecords = (style) => {
290
- const records = getStyleRecords(style);
289
+ const processStyleRecords = (style, weights) => {
290
+ const records = getStyleRecords(style, weights);
291
291
  extractOndemandStyles(style, extractedSheets, scannedTables);
292
292
  records.forEach((r) => {
293
293
  addSheet(r.sheet);
@@ -1434,6 +1434,13 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
1434
1434
  dynamicVars,
1435
1435
  };
1436
1436
  }
1437
+ const stateSources = baseChunks.map(({ order, style }) => ({ order, style: style }));
1438
+ conditionals.forEach((c) => {
1439
+ const order = c.order ?? 0;
1440
+ stateSources.push({ order, style: c.truthy });
1441
+ stateSources.push({ order, style: c.falsy });
1442
+ });
1443
+ const stateWeights = getStateWeights(stateSources);
1437
1444
  const participation = {};
1438
1445
  const registerParticipation = (style, sourceId) => {
1439
1446
  Object.keys(style).forEach((key) => {
@@ -1519,7 +1526,7 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
1519
1526
  if (existingClass)
1520
1527
  classParts.push(existingClass);
1521
1528
  if (Object.keys(baseIndependent).length > 0) {
1522
- const className = processStyleRecords(baseIndependent)
1529
+ const className = processStyleRecords(baseIndependent, stateWeights)
1523
1530
  .map((r) => r.hash)
1524
1531
  .join(' ');
1525
1532
  if (className)
@@ -1531,7 +1538,7 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
1531
1538
  const processBranch = (style) => {
1532
1539
  if (Object.keys(style).length === 0)
1533
1540
  return '""';
1534
- return JSON.stringify(processStyleRecords(style)
1541
+ return JSON.stringify(processStyleRecords(style, stateWeights)
1535
1542
  .map((r) => r.hash)
1536
1543
  .join(' '));
1537
1544
  };
@@ -1553,7 +1560,7 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
1553
1560
  const lookupMap = {};
1554
1561
  options.forEach((opt) => {
1555
1562
  if (opt.valueName !== undefined && opt.truthy) {
1556
- const className = processStyleRecords(opt.truthy)
1563
+ const className = processStyleRecords(opt.truthy, stateWeights)
1557
1564
  .map((r) => r.hash)
1558
1565
  .join(' ');
1559
1566
  if (className)
@@ -1653,7 +1660,7 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
1653
1660
  const results = {};
1654
1661
  const recurse = (dimIndex, currentStyle, keyParts) => {
1655
1662
  if (dimIndex >= dimensions.length) {
1656
- const className = processStyleRecords(currentStyle)
1663
+ const className = processStyleRecords(currentStyle, stateWeights)
1657
1664
  .map((r) => r.hash)
1658
1665
  .join(' ');
1659
1666
  if (className)
@@ -1667,7 +1674,7 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
1667
1674
  };
1668
1675
  recurse(0, {}, []);
1669
1676
  const baseConflictClass = Object.keys(baseConflict).length > 0
1670
- ? processStyleRecords(baseConflict)
1677
+ ? processStyleRecords(baseConflict, stateWeights)
1671
1678
  .map((r) => r.hash)
1672
1679
  .join(' ')
1673
1680
  : '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/unplugin",
3
- "version": "18.2.14",
3
+ "version": "18.2.15",
4
4
  "description": "Universal Plumeria plugin for various build tools",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",
@@ -89,12 +89,12 @@
89
89
  "dependencies": {
90
90
  "@rollup/pluginutils": "^5.4.0",
91
91
  "unplugin": "^3.0.0",
92
- "@plumeria/utils": "^18.2.14"
92
+ "@plumeria/utils": "^18.2.15"
93
93
  },
94
94
  "devDependencies": {
95
95
  "@swc/core": "1.15.47",
96
96
  "vite": "^8.0.13",
97
- "zss-engine": "2.5.0"
97
+ "zss-engine": "2.6.0"
98
98
  },
99
99
  "publishConfig": {
100
100
  "access": "public",