@mbler/mcx-core 0.1.1-rc.1 → 0.1.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/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1063,8 +1063,10 @@ async function Comp$2(ctx) {
|
|
|
1063
1063
|
function pushToTree(name, params, content) {
|
|
1064
1064
|
parsedObj.push(t.objectExpression([
|
|
1065
1065
|
t.objectProperty(t.identifier("type"), t.stringLiteral(name)),
|
|
1066
|
-
t.objectProperty(t.identifier("params"), t.objectExpression(Object.entries(params).map((
|
|
1067
|
-
|
|
1066
|
+
t.objectProperty(t.identifier("params"), t.objectExpression(Object.entries(params).map(([key, value]) => {
|
|
1067
|
+
const isDynamic = key.startsWith(":");
|
|
1068
|
+
const paramName = isDynamic ? key.slice(1) : key;
|
|
1069
|
+
return t.objectProperty(t.identifier(paramName), isDynamic ? t.objectExpression([t.objectProperty(t.identifier("useProp"), t.stringLiteral(String(value)))]) : typeof value == "boolean" ? t.booleanLiteral(value) : t.stringLiteral(value));
|
|
1068
1070
|
}))),
|
|
1069
1071
|
t.objectProperty(t.identifier("content"), content.startsWith("{{ ") && content.endsWith(" }}") ? t.objectExpression([t.objectProperty(t.identifier("useProp"), t.stringLiteral(content.slice(3, content.length - 3).trim()))]) : t.stringLiteral(content))
|
|
1070
1072
|
]));
|
|
@@ -1098,22 +1100,22 @@ async function Comp$2(ctx) {
|
|
|
1098
1100
|
"label"
|
|
1099
1101
|
].includes(name)) pushToTree(name, tp.arr, tp.content);
|
|
1100
1102
|
else if (name == "button") {
|
|
1101
|
-
if (MCXUIType !== "
|
|
1103
|
+
if (MCXUIType !== "ActionFormData" && MCXUIType) internalCtx.rollupContext.error("[UI]: don't support use button for messageFormData", tp.loc ? {
|
|
1102
1104
|
line: tp.loc.start.line,
|
|
1103
1105
|
column: tp.loc.start.column
|
|
1104
1106
|
} : void 0);
|
|
1105
1107
|
pushToTree(name, tp.arr, tp.content);
|
|
1106
|
-
MCXUIType = "
|
|
1108
|
+
MCXUIType = "ActionFormData";
|
|
1107
1109
|
} else internalCtx.rollupContext.error("[UI]: don't support tag: " + name, tp.loc ? {
|
|
1108
1110
|
line: tp.loc.start.line,
|
|
1109
1111
|
column: tp.loc.start.column
|
|
1110
1112
|
} : void 0);
|
|
1111
1113
|
}
|
|
1112
|
-
if (!MCXUIType) MCXUIType = "
|
|
1114
|
+
if (!MCXUIType) MCXUIType = "ActionFormData";
|
|
1113
1115
|
const finallyData = t.objectExpression([
|
|
1114
1116
|
t.objectProperty(t.identifier("layout"), t.arrayExpression(parsedObj)),
|
|
1115
1117
|
t.objectProperty(t.identifier("use"), t.memberExpression(t.identifier("__minecraft__ui"), t.identifier(MCXUIType))),
|
|
1116
|
-
t.objectProperty(t.identifier("
|
|
1118
|
+
t.objectProperty(t.identifier("UI"), t.identifier("__minecraft__ui"))
|
|
1117
1119
|
]);
|
|
1118
1120
|
ctx.app([t.objectProperty(t.identifier("ui"), t.newExpression(t.identifier("__mcx__ui"), [finallyData, t.identifier(config_default.scriptCompileFn)]))]);
|
|
1119
1121
|
}
|