@immense/vue-pom-generator 1.0.61 → 1.0.62
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/RELEASE_NOTES.md +22 -32
- package/dist/index.cjs +66 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +66 -53
- package/dist/index.mjs.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1761,11 +1761,12 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
1761
1761
|
return null;
|
|
1762
1762
|
}
|
|
1763
1763
|
const exp = handlerDirective.exp;
|
|
1764
|
-
const
|
|
1765
|
-
|
|
1764
|
+
const transformedSource = getVueExpressionSource(exp, "content", "compiled");
|
|
1765
|
+
const authorSource = getVueExpressionSource(exp, "loc", "content", "compiled");
|
|
1766
|
+
if (!authorSource) {
|
|
1766
1767
|
return null;
|
|
1767
1768
|
}
|
|
1768
|
-
const mergeKey = `handler:expr:${
|
|
1769
|
+
const mergeKey = `handler:expr:${authorSource}`;
|
|
1769
1770
|
const expr = tryGetDirectiveBabelAst(handlerDirective, {
|
|
1770
1771
|
preferredViews: ["content", "compiled"],
|
|
1771
1772
|
plugins: ["typescript", "jsx"],
|
|
@@ -1773,9 +1774,7 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
1773
1774
|
// That is fine for Vue codegen, but our semantic-name extraction needs a normal Babel parse tree.
|
|
1774
1775
|
preferExistingAst: false
|
|
1775
1776
|
});
|
|
1776
|
-
|
|
1777
|
-
return null;
|
|
1778
|
-
}
|
|
1777
|
+
const fallbackExpr = transformedSource !== authorSource ? tryParseBabelExpressionFromSource(authorSource, ["typescript", "jsx"]) : null;
|
|
1779
1778
|
const isNodeType2 = (node2, type) => {
|
|
1780
1779
|
return node2 !== null && node2.type === type;
|
|
1781
1780
|
};
|
|
@@ -2011,59 +2010,73 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2011
2010
|
const limited = parts.slice(0, 2);
|
|
2012
2011
|
return limited.map((p) => `${toPascalCase(p.key)}${p.value}`).join("");
|
|
2013
2012
|
};
|
|
2014
|
-
const
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
const
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2013
|
+
const tryFromCallExpression = (call) => {
|
|
2014
|
+
const resolvedCall = isAwaitExpressionNode(call) ? call.argument : call;
|
|
2015
|
+
if (!isCallExpressionNode(resolvedCall)) {
|
|
2016
|
+
return null;
|
|
2017
|
+
}
|
|
2018
|
+
const name = getLastIdentifierFromMemberChain(resolvedCall.callee);
|
|
2019
|
+
if (!name) {
|
|
2020
|
+
return null;
|
|
2021
|
+
}
|
|
2022
|
+
const suffix = getStableSuffixFromCall(resolvedCall);
|
|
2023
|
+
const semanticNameHint2 = suffix ? `${toPascalCase(name)}${suffix}` : toPascalCase(name);
|
|
2024
|
+
return semanticNameHint2;
|
|
2025
|
+
};
|
|
2026
|
+
const resolveSemanticName = (candidateExpr) => {
|
|
2027
|
+
if (!candidateExpr) {
|
|
2028
|
+
return null;
|
|
2029
|
+
}
|
|
2030
|
+
const direct = getLastIdentifierFromMemberChain(candidateExpr);
|
|
2031
|
+
if (direct) {
|
|
2032
|
+
return toPascalCase(direct);
|
|
2033
|
+
}
|
|
2034
|
+
if (isArrowFunctionExpressionNode(candidateExpr)) {
|
|
2035
|
+
const body = candidateExpr.body;
|
|
2036
|
+
const directCall = tryFromCallExpression(body);
|
|
2037
|
+
if (directCall) {
|
|
2038
|
+
return directCall;
|
|
2039
|
+
}
|
|
2040
|
+
if (isAssignmentExpressionNode(body)) {
|
|
2041
|
+
const lhs = getAssignmentTargetName(body.left);
|
|
2042
|
+
if (lhs) {
|
|
2043
|
+
const rhs = stableWordFromValue(body.right);
|
|
2044
|
+
return `Set${toPascalCase(lhs)}${rhs ?? ""}`;
|
|
2045
|
+
}
|
|
2028
2046
|
}
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
const lhs = getAssignmentTargetName(body.left);
|
|
2039
|
-
if (lhs) {
|
|
2040
|
-
const rhs = stableWordFromValue(body.right);
|
|
2041
|
-
const semanticNameHint = `Set${toPascalCase(lhs)}${rhs ?? ""}`;
|
|
2042
|
-
return { semanticNameHint, mergeKey };
|
|
2043
|
-
}
|
|
2044
|
-
}
|
|
2045
|
-
if (isBlockStatementNode(body)) {
|
|
2046
|
-
const stmts = body.body ?? [];
|
|
2047
|
-
if (stmts.length > 0) {
|
|
2048
|
-
const firstStmt = stmts[0];
|
|
2049
|
-
if (isReturnStatementNode(firstStmt)) {
|
|
2050
|
-
const fromReturn = tryFromCallExpression(firstStmt.argument ?? null);
|
|
2051
|
-
if (fromReturn) {
|
|
2052
|
-
return { semanticNameHint: fromReturn, mergeKey };
|
|
2047
|
+
if (isBlockStatementNode(body)) {
|
|
2048
|
+
const stmts = body.body ?? [];
|
|
2049
|
+
if (stmts.length > 0) {
|
|
2050
|
+
const firstStmt = stmts[0];
|
|
2051
|
+
if (isReturnStatementNode(firstStmt)) {
|
|
2052
|
+
const fromReturn = tryFromCallExpression(firstStmt.argument ?? null);
|
|
2053
|
+
if (fromReturn) {
|
|
2054
|
+
return fromReturn;
|
|
2055
|
+
}
|
|
2053
2056
|
}
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2057
|
+
if (isExpressionStatementNode(firstStmt)) {
|
|
2058
|
+
const fromExpr = tryFromCallExpression(firstStmt.expression ?? null);
|
|
2059
|
+
if (fromExpr) {
|
|
2060
|
+
return fromExpr;
|
|
2061
|
+
}
|
|
2059
2062
|
}
|
|
2060
2063
|
}
|
|
2061
2064
|
}
|
|
2065
|
+
const bodyName = getLastIdentifierFromMemberChain(body);
|
|
2066
|
+
if (bodyName) {
|
|
2067
|
+
return toPascalCase(bodyName);
|
|
2068
|
+
}
|
|
2062
2069
|
}
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2070
|
+
return null;
|
|
2071
|
+
};
|
|
2072
|
+
const isVueRefValueAccess = (candidate) => {
|
|
2073
|
+
return isMemberExpressionNode(candidate) && candidate.computed === false && isIdentifierNode2(candidate.property) && candidate.property.name === "value";
|
|
2074
|
+
};
|
|
2075
|
+
const transformedSemanticName = resolveSemanticName(expr);
|
|
2076
|
+
const fallbackSemanticName = resolveSemanticName(fallbackExpr);
|
|
2077
|
+
const semanticNameHint = fallbackSemanticName && transformedSource !== authorSource && isVueRefValueAccess(expr) ? fallbackSemanticName : transformedSemanticName ?? fallbackSemanticName;
|
|
2078
|
+
if (semanticNameHint) {
|
|
2079
|
+
return { semanticNameHint, mergeKey };
|
|
2067
2080
|
}
|
|
2068
2081
|
return null;
|
|
2069
2082
|
}
|