@plumeria/unplugin 11.0.1 → 11.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/README.md +4 -8
- package/dist/core.js +17 -9
- package/dist/core.mjs +17 -9
- package/package.json +2 -2
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
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
|
1098
|
-
if (callArgs.length
|
|
1099
|
-
const
|
|
1097
|
+
const hasSpread = callArgs.some((a) => a.spread);
|
|
1098
|
+
if (!hasSpread && callArgs.length >= 1) {
|
|
1099
|
+
const tempStaticTable = { ...mergedStaticTable };
|
|
1100
1100
|
const cssVarInfo = {};
|
|
1101
|
-
if (
|
|
1102
|
-
|
|
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
|
-
|
|
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(([
|
|
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
|
|
1127
|
-
const
|
|
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
|
|
1062
|
-
if (callArgs.length
|
|
1063
|
-
const
|
|
1061
|
+
const hasSpread = callArgs.some((a) => a.spread);
|
|
1062
|
+
if (!hasSpread && callArgs.length >= 1) {
|
|
1063
|
+
const tempStaticTable = { ...mergedStaticTable };
|
|
1064
1064
|
const cssVarInfo = {};
|
|
1065
|
-
if (
|
|
1066
|
-
|
|
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
|
-
|
|
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(([
|
|
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
|
|
1091
|
-
const
|
|
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
|
|
3
|
+
"version": "11.1.0",
|
|
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
|
|
89
|
+
"@plumeria/utils": "^11.1.0"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@swc/core": "1.15.21",
|