@plumeria/vite-plugin 7.1.2 → 7.2.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 +7 -81
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -84,7 +84,7 @@ export function plumeria(options = {}) {
84
84
  }
85
85
  }
86
86
  }
87
- const scannedTables = scanAll();
87
+ const scannedTables = scanAll(true);
88
88
  const localConsts = collectLocalConsts(ast);
89
89
  const resourcePath = id;
90
90
  const importMap = {};
@@ -320,8 +320,7 @@ export function plumeria(options = {}) {
320
320
  }
321
321
  return undefined;
322
322
  });
323
- const { hashMap, sheets } = processVariants(obj);
324
- sheets.forEach(addSheet);
323
+ const { hashMap } = processVariants(obj);
325
324
  localCreateStyles[node.id.value] = {
326
325
  name: node.id.value,
327
326
  type: 'variant',
@@ -424,7 +423,6 @@ export function plumeria(options = {}) {
424
423
  const obj = objectExpressionToObject(args[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedCreateThemeHashTable, scannedTables.createThemeObjectTable, mergedCreateTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable, mergedVariantsTable);
425
424
  const hash = genBase36Hash(obj, 1, 8);
426
425
  scannedTables.keyframesObjectTable[hash] = obj;
427
- extractOndemandStyles({ kf: `kf-${hash}` }, extractedSheets, scannedTables);
428
426
  replacements.push({
429
427
  start: node.span.start - ast.span.start,
430
428
  end: node.span.end - ast.span.start,
@@ -437,7 +435,6 @@ export function plumeria(options = {}) {
437
435
  const obj = objectExpressionToObject(args[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedCreateThemeHashTable, scannedTables.createThemeObjectTable, mergedCreateTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable, mergedVariantsTable);
438
436
  const hash = genBase36Hash(obj, 1, 8);
439
437
  scannedTables.viewTransitionObjectTable[hash] = obj;
440
- extractOndemandStyles({ vt: `vt-${hash}` }, extractedSheets, scannedTables);
441
438
  replacements.push({
442
439
  start: node.span.start - ast.span.start,
443
440
  end: node.span.end - ast.span.start,
@@ -468,13 +465,6 @@ export function plumeria(options = {}) {
468
465
  const obj = objectExpressionToObject(args[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedCreateThemeHashTable, scannedTables.createThemeObjectTable, mergedCreateTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable, mergedVariantsTable);
469
466
  const hash = genBase36Hash(obj, 1, 8);
470
467
  scannedTables.createObjectTable[hash] = obj;
471
- Object.entries(obj).forEach(([_key, style]) => {
472
- if (typeof style === 'object' && style !== null) {
473
- const records = getStyleRecords(style);
474
- extractOndemandStyles(style, extractedSheets, scannedTables);
475
- records.forEach((r) => addSheet(r.sheet));
476
- }
477
- });
478
468
  }
479
469
  }
480
470
  },
@@ -539,63 +529,11 @@ export function plumeria(options = {}) {
539
529
  return;
540
530
  const styleInfo = localCreateStyles[node.value];
541
531
  if (styleInfo) {
542
- if (styleInfo.type === 'variant') {
543
- const hashMap = styleInfo.hashMap;
544
- const independentKeys = Object.keys(hashMap).filter((k) => k !== '_compound');
545
- const compoundGroups = hashMap._compound || [];
546
- const independentChecks = independentKeys
547
- .map((key) => {
548
- const mapObj = hashMap[key];
549
- if (typeof mapObj === 'string') {
550
- return `classes.push("${mapObj}");`;
551
- }
552
- const mapStr = JSON.stringify(mapObj);
553
- return `
554
- var v${key} = ${mapStr};
555
- if (props["${key}"] && v${key}[props["${key}"]]) {
556
- classes.push(v${key}[props["${key}"]]);
557
- } else if (v${key}["default"]) {
558
- classes.push(v${key}["default"]);
559
- }
560
- `;
561
- })
562
- .join('\n');
563
- const compoundChecks = compoundGroups
564
- .map((group) => {
565
- const keys = group.keys;
566
- const mapObj = group.map;
567
- const mapStr = JSON.stringify(mapObj);
568
- const keyExpr = keys
569
- .map((k) => `(props["${k}"] || "default")`)
570
- .join(' + ":" + ');
571
- return `
572
- var c${keys.join('_')} = ${mapStr};
573
- var k = ${keyExpr};
574
- if (c${keys.join('_')}[k]) {
575
- classes.push(c${keys.join('_')}[k]);
576
- }
577
- `;
578
- })
579
- .join('\n');
580
- const runtimeFn = `(props) => {
581
- var classes = [];
582
- ${independentChecks}
583
- ${compoundChecks}
584
- return classes.join(" ");
585
- }`;
586
- replacements.push({
587
- start: node.span.start - ast.span.start,
588
- end: node.span.end - ast.span.start,
589
- content: runtimeFn,
590
- });
591
- }
592
- else {
593
- replacements.push({
594
- start: node.span.start - ast.span.start,
595
- end: node.span.end - ast.span.start,
596
- content: JSON.stringify(styleInfo.hashMap),
597
- });
598
- }
532
+ replacements.push({
533
+ start: node.span.start - ast.span.start,
534
+ end: node.span.end - ast.span.start,
535
+ content: JSON.stringify(styleInfo.hashMap),
536
+ });
599
537
  return;
600
538
  }
601
539
  const varName = node.value;
@@ -943,9 +881,7 @@ export function plumeria(options = {}) {
943
881
  if (isOptimizable &&
944
882
  (args.length > 0 || Object.keys(baseStyle).length > 0)) {
945
883
  if (conditionals.length === 0) {
946
- extractOndemandStyles(baseStyle, extractedSheets, scannedTables);
947
884
  const records = getStyleRecords(baseStyle);
948
- records.forEach((r) => addSheet(r.sheet));
949
885
  const className = records
950
886
  .map((r) => r.hash)
951
887
  .join(' ');
@@ -1057,9 +993,7 @@ export function plumeria(options = {}) {
1057
993
  conditionals.forEach(splitConditional);
1058
994
  const classParts = [];
1059
995
  if (Object.keys(baseIndependent).length > 0) {
1060
- extractOndemandStyles(baseIndependent, extractedSheets, scannedTables);
1061
996
  const records = getStyleRecords(baseIndependent);
1062
- records.forEach((r) => addSheet(r.sheet));
1063
997
  const className = records.map((r) => r.hash).join(' ');
1064
998
  if (className)
1065
999
  classParts.push(JSON.stringify(className));
@@ -1069,9 +1003,7 @@ export function plumeria(options = {}) {
1069
1003
  const processBranch = (style) => {
1070
1004
  if (Object.keys(style).length === 0)
1071
1005
  return '""';
1072
- extractOndemandStyles(style, extractedSheets, scannedTables);
1073
1006
  const records = getStyleRecords(style);
1074
- records.forEach((r) => addSheet(r.sheet));
1075
1007
  return JSON.stringify(records.map((r) => r.hash).join(' '));
1076
1008
  };
1077
1009
  const tClass = processBranch(c.truthy);
@@ -1110,9 +1042,7 @@ export function plumeria(options = {}) {
1110
1042
  }
1111
1043
  options.forEach((opt) => {
1112
1044
  if (opt.valueName && opt.truthy) {
1113
- extractOndemandStyles(opt.truthy, extractedSheets, scannedTables);
1114
1045
  const records = getStyleRecords(opt.truthy);
1115
- records.forEach((r) => addSheet(r.sheet));
1116
1046
  const className = records.map((r) => r.hash).join(' ');
1117
1047
  if (className) {
1118
1048
  lookupMap[opt.valueName] = className;
@@ -1185,9 +1115,7 @@ export function plumeria(options = {}) {
1185
1115
  const results = {};
1186
1116
  const recurse = (dimIndex, currentStyle, keyParts) => {
1187
1117
  if (dimIndex >= dimensions.length) {
1188
- extractOndemandStyles(currentStyle, extractedSheets, scannedTables);
1189
1118
  const records = getStyleRecords(currentStyle);
1190
- records.forEach((r) => addSheet(r.sheet));
1191
1119
  const className = records.map((r) => r.hash).join(' ');
1192
1120
  const finalKey = keyParts.join('__');
1193
1121
  if (className)
@@ -1206,9 +1134,7 @@ export function plumeria(options = {}) {
1206
1134
  recurse(0, baseConflict, []);
1207
1135
  let baseConflictClass = '';
1208
1136
  if (Object.keys(baseConflict).length > 0) {
1209
- extractOndemandStyles(baseConflict, extractedSheets, scannedTables);
1210
1137
  const records = getStyleRecords(baseConflict);
1211
- records.forEach((r) => addSheet(r.sheet));
1212
1138
  baseConflictClass = records.map((r) => r.hash).join(' ');
1213
1139
  }
1214
1140
  const keyExprs = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/vite-plugin",
3
- "version": "7.1.2",
3
+ "version": "7.2.1",
4
4
  "type": "module",
5
5
  "description": "Plumeria Vite plugin",
6
6
  "author": "Refirst 11",
@@ -22,7 +22,7 @@
22
22
  "dist/"
23
23
  ],
24
24
  "dependencies": {
25
- "@plumeria/utils": "^7.1.2"
25
+ "@plumeria/utils": "^7.2.1"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@swc/core": "1.15.8",