@plumeria/unplugin 11.0.1 → 11.0.2

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/README.md CHANGED
@@ -139,17 +139,13 @@ await Bun.build({
139
139
  ```
140
140
  ## Options
141
141
 
142
- You can control the files to be converted by passing options when calling the plugin. By default, `\.(ts|tsx|js|jsx)$` is targeted.
142
+ You can control the files to be converted by passing options when calling the plugin. By default `ts/tsx/js/jsx` is targeted.
143
143
 
144
144
  ```js
145
145
  plumeria.vite({
146
- // Files to be converted
147
- include: [/\.[jt]sx?$/],
148
- // Files to exclude from conversion
149
- exclude: [/node_modules/],
150
-
151
- // Whether to emit styles to disk in development mode
152
- devEmitToDisk: false,
146
+ include: ['**/*.{ts,tsx}'],
147
+ exclude: ['**/node_modules/**'],
148
+ devEmitToDisk: false,
153
149
  });
154
150
  ```
155
151
  ## Development Mode and HMR (Hot Module Replacement)
package/dist/core.js CHANGED
@@ -1094,19 +1094,23 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
1094
1094
  if (styleInfo?.functions?.[propKey]) {
1095
1095
  const func = styleInfo.functions[propKey];
1096
1096
  const callArgs = innerExpr.arguments;
1097
- const tempStaticTable = { ...mergedStaticTable };
1098
- if (callArgs.length === 1 && !callArgs[0].spread) {
1099
- const argExpr = callArgs[0].expression;
1097
+ const hasSpread = callArgs.some((a) => a.spread);
1098
+ if (!hasSpread && callArgs.length >= 1) {
1099
+ const tempStaticTable = { ...mergedStaticTable };
1100
1100
  const cssVarInfo = {};
1101
- if (argExpr.type === 'ObjectExpression') {
1102
- const argObj = (0, utils_1.objectExpressionToObject)(argExpr, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedCreateThemeHashTable, scannedTables.createThemeObjectTable, mergedCreateTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable, mergedVariantsTable);
1101
+ if (callArgs.length === 1 &&
1102
+ callArgs[0].expression.type === 'ObjectExpression') {
1103
+ const argObj = (0, utils_1.objectExpressionToObject)(callArgs[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedCreateThemeHashTable, scannedTables.createThemeObjectTable, mergedCreateTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable, mergedVariantsTable);
1103
1104
  func.params.forEach((p) => {
1104
1105
  if (argObj[p] !== undefined)
1105
1106
  tempStaticTable[p] = argObj[p];
1106
1107
  });
1107
1108
  }
1108
1109
  else {
1109
- func.params.forEach((p) => {
1110
+ callArgs.forEach((_callArg, i) => {
1111
+ const p = func.params[i];
1112
+ if (!p)
1113
+ return;
1110
1114
  const cssVar = `--${propKey}-${p}`;
1111
1115
  tempStaticTable[p] = `var(${cssVar})`;
1112
1116
  cssVarInfo[p] = { cssVar, propKey: '' };
@@ -1119,12 +1123,16 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
1119
1123
  if (hashes)
1120
1124
  dynamicClassParts.push(JSON.stringify(hashes));
1121
1125
  if (Object.keys(cssVarInfo).length > 0) {
1122
- Object.entries(cssVarInfo).forEach(([_, info]) => {
1126
+ Object.entries(cssVarInfo).forEach(([paramName, info]) => {
1123
1127
  const targetProp = Object.keys(substituted).find((k) => typeof substituted[k] === 'string' &&
1124
1128
  substituted[k].includes(info.cssVar));
1125
1129
  if (targetProp) {
1126
- const argStart = argExpr.span.start - baseByteOffset;
1127
- const argEnd = argExpr.span.end - baseByteOffset;
1130
+ const paramIndex = func.params.indexOf(paramName);
1131
+ const srcArg = paramIndex >= 0 && callArgs[paramIndex]
1132
+ ? callArgs[paramIndex].expression
1133
+ : callArgs[0].expression;
1134
+ const argStart = srcArg.span.start - baseByteOffset;
1135
+ const argEnd = srcArg.span.end - baseByteOffset;
1128
1136
  const argSource = sourceBuffer
1129
1137
  .subarray(argStart, argEnd)
1130
1138
  .toString('utf-8');
package/dist/core.mjs CHANGED
@@ -1058,19 +1058,23 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
1058
1058
  if (styleInfo?.functions?.[propKey]) {
1059
1059
  const func = styleInfo.functions[propKey];
1060
1060
  const callArgs = innerExpr.arguments;
1061
- const tempStaticTable = { ...mergedStaticTable };
1062
- if (callArgs.length === 1 && !callArgs[0].spread) {
1063
- const argExpr = callArgs[0].expression;
1061
+ const hasSpread = callArgs.some((a) => a.spread);
1062
+ if (!hasSpread && callArgs.length >= 1) {
1063
+ const tempStaticTable = { ...mergedStaticTable };
1064
1064
  const cssVarInfo = {};
1065
- if (argExpr.type === 'ObjectExpression') {
1066
- const argObj = objectExpressionToObject(argExpr, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedCreateThemeHashTable, scannedTables.createThemeObjectTable, mergedCreateTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable, mergedVariantsTable);
1065
+ if (callArgs.length === 1 &&
1066
+ callArgs[0].expression.type === 'ObjectExpression') {
1067
+ const argObj = objectExpressionToObject(callArgs[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedCreateThemeHashTable, scannedTables.createThemeObjectTable, mergedCreateTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable, mergedVariantsTable);
1067
1068
  func.params.forEach((p) => {
1068
1069
  if (argObj[p] !== undefined)
1069
1070
  tempStaticTable[p] = argObj[p];
1070
1071
  });
1071
1072
  }
1072
1073
  else {
1073
- func.params.forEach((p) => {
1074
+ callArgs.forEach((_callArg, i) => {
1075
+ const p = func.params[i];
1076
+ if (!p)
1077
+ return;
1074
1078
  const cssVar = `--${propKey}-${p}`;
1075
1079
  tempStaticTable[p] = `var(${cssVar})`;
1076
1080
  cssVarInfo[p] = { cssVar, propKey: '' };
@@ -1083,12 +1087,16 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
1083
1087
  if (hashes)
1084
1088
  dynamicClassParts.push(JSON.stringify(hashes));
1085
1089
  if (Object.keys(cssVarInfo).length > 0) {
1086
- Object.entries(cssVarInfo).forEach(([_, info]) => {
1090
+ Object.entries(cssVarInfo).forEach(([paramName, info]) => {
1087
1091
  const targetProp = Object.keys(substituted).find((k) => typeof substituted[k] === 'string' &&
1088
1092
  substituted[k].includes(info.cssVar));
1089
1093
  if (targetProp) {
1090
- const argStart = argExpr.span.start - baseByteOffset;
1091
- const argEnd = argExpr.span.end - baseByteOffset;
1094
+ const paramIndex = func.params.indexOf(paramName);
1095
+ const srcArg = paramIndex >= 0 && callArgs[paramIndex]
1096
+ ? callArgs[paramIndex].expression
1097
+ : callArgs[0].expression;
1098
+ const argStart = srcArg.span.start - baseByteOffset;
1099
+ const argEnd = srcArg.span.end - baseByteOffset;
1092
1100
  const argSource = sourceBuffer
1093
1101
  .subarray(argStart, argEnd)
1094
1102
  .toString('utf-8');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/unplugin",
3
- "version": "11.0.1",
3
+ "version": "11.0.2",
4
4
  "description": "Universal Plumeria plugin for various build tools",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",
@@ -86,7 +86,7 @@
86
86
  ],
87
87
  "dependencies": {
88
88
  "unplugin": "^3.0.0",
89
- "@plumeria/utils": "^11.0.1"
89
+ "@plumeria/utils": "^11.0.2"
90
90
  },
91
91
  "devDependencies": {
92
92
  "@swc/core": "1.15.21",