@astralsight/astroforge-rsbuild-plugin 0.0.5 → 0.0.6
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/index.mjs +9 -2
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1079,7 +1079,7 @@ function attrFromValue(name, value, filename) {
|
|
|
1079
1079
|
const staticObject = staticAttrLiteral(expression);
|
|
1080
1080
|
if (staticObject !== void 0) return {
|
|
1081
1081
|
kind: "static",
|
|
1082
|
-
value: staticObject
|
|
1082
|
+
value: name === "style" ? normalizeStyleLiteral(staticObject) : staticObject
|
|
1083
1083
|
};
|
|
1084
1084
|
if (name === "style") {
|
|
1085
1085
|
const styleObject = styleObjectAttr(expression, filename);
|
|
@@ -1099,7 +1099,7 @@ function styleObjectAttr(expression, filename) {
|
|
|
1099
1099
|
const slots = [];
|
|
1100
1100
|
for (const property of node.properties) {
|
|
1101
1101
|
if (property.type !== "ObjectProperty" || property.computed) throw new Error(`${filename ?? "TSX"}: style 对象暂不支持展开、方法或计算键`);
|
|
1102
|
-
const key = objectPropertyKey(property.key, filename);
|
|
1102
|
+
const key = kebabToCamel(objectPropertyKey(property.key, filename));
|
|
1103
1103
|
const value = staticAttrLiteral(property.value);
|
|
1104
1104
|
if (value !== void 0) {
|
|
1105
1105
|
slots.push({
|
|
@@ -1121,6 +1121,10 @@ function styleObjectAttr(expression, filename) {
|
|
|
1121
1121
|
}
|
|
1122
1122
|
return slots;
|
|
1123
1123
|
}
|
|
1124
|
+
function normalizeStyleLiteral(value) {
|
|
1125
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return value;
|
|
1126
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [kebabToCamel(key), item]));
|
|
1127
|
+
}
|
|
1124
1128
|
function staticAttrLiteral(expression) {
|
|
1125
1129
|
const node = unwrapExpression(expression);
|
|
1126
1130
|
const literal = literalValue(node);
|
|
@@ -1274,6 +1278,9 @@ function unwrapExpression(node) {
|
|
|
1274
1278
|
function kebabCase(value) {
|
|
1275
1279
|
return value.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/_/g, "-").toLowerCase();
|
|
1276
1280
|
}
|
|
1281
|
+
function kebabToCamel(value) {
|
|
1282
|
+
return value.replace(/-([a-z])/g, (_, ch) => ch.toUpperCase());
|
|
1283
|
+
}
|
|
1277
1284
|
//#endregion
|
|
1278
1285
|
//#region src/project.ts
|
|
1279
1286
|
const PAGE_EXTENSIONS = new Set([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astralsight/astroforge-rsbuild-plugin",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "AstroForge Plugin for RsBuild",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@babel/parser": "^7.29.3",
|
|
41
|
-
"@astralsight/astroforge-core": "^0.0.
|
|
41
|
+
"@astralsight/astroforge-core": "^0.0.6"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsdown"
|