@immense/vue-pom-generator 1.0.109 → 1.0.111
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 +10 -1
- package/RELEASE_NOTES.md +25 -35
- package/dist/compiler/babel-guards.d.ts +85 -0
- package/dist/compiler/babel-guards.d.ts.map +1 -0
- package/dist/index.cjs +170 -167
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +170 -167
- package/dist/index.mjs.map +1 -1
- package/dist/plugin/types.d.ts +2 -1
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/routing/to-directive.d.ts.map +1 -1
- package/dist/tests/helpers/ast-queries.d.ts +10 -0
- package/dist/tests/helpers/ast-queries.d.ts.map +1 -0
- package/dist/tests/helpers/component-deps.d.ts +3 -0
- package/dist/tests/helpers/component-deps.d.ts.map +1 -0
- package/dist/transform.d.ts.map +1 -1
- package/dist/utils.d.ts +38 -3
- package/dist/utils.d.ts.map +1 -1
- package/package.json +2 -2
- package/sequence-diagram.md +1 -1
package/dist/index.cjs
CHANGED
|
@@ -32,6 +32,7 @@ const compilerCore = require("@vue/compiler-core");
|
|
|
32
32
|
const compilerDom = require("@vue/compiler-dom");
|
|
33
33
|
const compilerSfc = require("@vue/compiler-sfc");
|
|
34
34
|
const tsMorph = require("ts-morph");
|
|
35
|
+
const shared = require("@vue/shared");
|
|
35
36
|
const types = require("@babel/types");
|
|
36
37
|
const node_crypto = require("node:crypto");
|
|
37
38
|
const router = require("./router.cjs");
|
|
@@ -1099,6 +1100,96 @@ function collectAccessibilityReviewWarnings(manifest) {
|
|
|
1099
1100
|
}
|
|
1100
1101
|
return warnings;
|
|
1101
1102
|
}
|
|
1103
|
+
const isNodeType = (node, type) => {
|
|
1104
|
+
return node !== null && node.type === type;
|
|
1105
|
+
};
|
|
1106
|
+
const isIdentifierNode = (node) => {
|
|
1107
|
+
return isNodeType(node, "Identifier") && typeof node.name === "string";
|
|
1108
|
+
};
|
|
1109
|
+
const isStringLiteralNode = (node) => {
|
|
1110
|
+
return isNodeType(node, "StringLiteral") && typeof node.value === "string";
|
|
1111
|
+
};
|
|
1112
|
+
const isBooleanLiteralNode = (node) => {
|
|
1113
|
+
return isNodeType(node, "BooleanLiteral") && typeof node.value === "boolean";
|
|
1114
|
+
};
|
|
1115
|
+
const isNumericLiteralNode = (node) => {
|
|
1116
|
+
return isNodeType(node, "NumericLiteral") && typeof node.value === "number";
|
|
1117
|
+
};
|
|
1118
|
+
const isNullLiteralNode = (node) => {
|
|
1119
|
+
return isNodeType(node, "NullLiteral");
|
|
1120
|
+
};
|
|
1121
|
+
const isMemberExpressionNode = (node) => {
|
|
1122
|
+
if (!isNodeType(node, "MemberExpression"))
|
|
1123
|
+
return false;
|
|
1124
|
+
const n = node;
|
|
1125
|
+
return typeof n.computed === "boolean" && typeof n.object === "object" && n.object !== null && typeof n.property === "object" && n.property !== null;
|
|
1126
|
+
};
|
|
1127
|
+
const isCallExpressionNode = (node) => {
|
|
1128
|
+
if (!isNodeType(node, "CallExpression"))
|
|
1129
|
+
return false;
|
|
1130
|
+
const n = node;
|
|
1131
|
+
return typeof n.callee === "object" && n.callee !== null && Array.isArray(n.arguments);
|
|
1132
|
+
};
|
|
1133
|
+
const isAwaitExpressionNode = (node) => {
|
|
1134
|
+
if (!isNodeType(node, "AwaitExpression"))
|
|
1135
|
+
return false;
|
|
1136
|
+
const n = node;
|
|
1137
|
+
return typeof n.argument === "object" && n.argument !== null;
|
|
1138
|
+
};
|
|
1139
|
+
const isAssignmentExpressionNode = (node) => {
|
|
1140
|
+
if (!isNodeType(node, "AssignmentExpression"))
|
|
1141
|
+
return false;
|
|
1142
|
+
const n = node;
|
|
1143
|
+
return typeof n.left === "object" && n.left !== null && typeof n.right === "object" && n.right !== null;
|
|
1144
|
+
};
|
|
1145
|
+
const isArrowFunctionExpressionNode = (node) => {
|
|
1146
|
+
if (!isNodeType(node, "ArrowFunctionExpression"))
|
|
1147
|
+
return false;
|
|
1148
|
+
const n = node;
|
|
1149
|
+
return typeof n.body === "object" && n.body !== null;
|
|
1150
|
+
};
|
|
1151
|
+
const isBlockStatementNode = (node) => {
|
|
1152
|
+
if (!isNodeType(node, "BlockStatement"))
|
|
1153
|
+
return false;
|
|
1154
|
+
const n = node;
|
|
1155
|
+
return Array.isArray(n.body);
|
|
1156
|
+
};
|
|
1157
|
+
const isExpressionStatementNode = (node) => {
|
|
1158
|
+
if (!isNodeType(node, "ExpressionStatement"))
|
|
1159
|
+
return false;
|
|
1160
|
+
const n = node;
|
|
1161
|
+
return typeof n.expression === "object" && n.expression !== null;
|
|
1162
|
+
};
|
|
1163
|
+
const isReturnStatementNode = (node) => {
|
|
1164
|
+
if (!isNodeType(node, "ReturnStatement"))
|
|
1165
|
+
return false;
|
|
1166
|
+
const n = node;
|
|
1167
|
+
return typeof n.argument === "object" || n.argument === null;
|
|
1168
|
+
};
|
|
1169
|
+
const isObjectExpressionNode = (node) => {
|
|
1170
|
+
if (!isNodeType(node, "ObjectExpression"))
|
|
1171
|
+
return false;
|
|
1172
|
+
const n = node;
|
|
1173
|
+
return Array.isArray(n.properties);
|
|
1174
|
+
};
|
|
1175
|
+
const isObjectPropertyNode = (node) => {
|
|
1176
|
+
if (!isNodeType(node, "ObjectProperty"))
|
|
1177
|
+
return false;
|
|
1178
|
+
const n = node;
|
|
1179
|
+
return typeof n.computed === "boolean" && typeof n.key === "object" && n.key !== null && typeof n.value === "object" && n.value !== null;
|
|
1180
|
+
};
|
|
1181
|
+
const isObjectPropertyNodeShallow = (node) => {
|
|
1182
|
+
if (!isNodeType(node, "ObjectProperty"))
|
|
1183
|
+
return false;
|
|
1184
|
+
const n = node;
|
|
1185
|
+
return typeof n.key === "object" && n.key !== null && typeof n.value === "object" && n.value !== null;
|
|
1186
|
+
};
|
|
1187
|
+
const isLogicalExpressionNode = (node) => {
|
|
1188
|
+
if (!isNodeType(node, "LogicalExpression"))
|
|
1189
|
+
return false;
|
|
1190
|
+
const n = node;
|
|
1191
|
+
return typeof n.operator === "string" && typeof n.left === "object" && n.left !== null && typeof n.right === "object" && n.right !== null;
|
|
1192
|
+
};
|
|
1102
1193
|
function isSimpleExpressionNode(value) {
|
|
1103
1194
|
return value !== null && "type" in value && value.type === compilerCore.NodeTypes.SIMPLE_EXPRESSION;
|
|
1104
1195
|
}
|
|
@@ -1137,27 +1228,6 @@ function buildPlaceholderParams(keys) {
|
|
|
1137
1228
|
params[k] = "__placeholder__";
|
|
1138
1229
|
return params;
|
|
1139
1230
|
}
|
|
1140
|
-
const isNodeType = (node, type) => {
|
|
1141
|
-
return node !== null && node.type === type;
|
|
1142
|
-
};
|
|
1143
|
-
const isStringLiteralNode = (node) => {
|
|
1144
|
-
return isNodeType(node, "StringLiteral") && typeof node.value === "string";
|
|
1145
|
-
};
|
|
1146
|
-
const isIdentifierNode = (node) => {
|
|
1147
|
-
return isNodeType(node, "Identifier") && typeof node.name === "string";
|
|
1148
|
-
};
|
|
1149
|
-
const isObjectPropertyNode = (node) => {
|
|
1150
|
-
if (!isNodeType(node, "ObjectProperty"))
|
|
1151
|
-
return false;
|
|
1152
|
-
const n = node;
|
|
1153
|
-
return typeof n.key === "object" && n.key !== null && typeof n.value === "object" && n.value !== null;
|
|
1154
|
-
};
|
|
1155
|
-
const isObjectExpressionNode = (node) => {
|
|
1156
|
-
if (!isNodeType(node, "ObjectExpression"))
|
|
1157
|
-
return false;
|
|
1158
|
-
const n = node;
|
|
1159
|
-
return Array.isArray(n.properties);
|
|
1160
|
-
};
|
|
1161
1231
|
function materializeResolvedRouteTarget(target, paramKeys) {
|
|
1162
1232
|
if (typeof target === "string")
|
|
1163
1233
|
return target;
|
|
@@ -1433,6 +1503,16 @@ function tryGetClickDirective(node) {
|
|
|
1433
1503
|
function nodeHasClickDirective(node) {
|
|
1434
1504
|
return tryGetClickDirective(node) !== void 0;
|
|
1435
1505
|
}
|
|
1506
|
+
function nodeHasStaticClickDirective(node) {
|
|
1507
|
+
return node.props.some((prop) => {
|
|
1508
|
+
if (prop.type !== compilerCore.NodeTypes.DIRECTIVE) {
|
|
1509
|
+
return false;
|
|
1510
|
+
}
|
|
1511
|
+
const directive = prop;
|
|
1512
|
+
const arg = directive.arg;
|
|
1513
|
+
return directive.name === "on" && arg?.type === compilerCore.NodeTypes.SIMPLE_EXPRESSION && arg.isStatic && arg.content === "click";
|
|
1514
|
+
});
|
|
1515
|
+
}
|
|
1436
1516
|
function findTemplateSlotScopeExpression(node) {
|
|
1437
1517
|
if (node.tag !== "template") {
|
|
1438
1518
|
return null;
|
|
@@ -2147,12 +2227,40 @@ function tryGetContainedInStaticVForSourceLiteralValues(context, _node, _hierarc
|
|
|
2147
2227
|
function getParent(hierarchyMap2, node) {
|
|
2148
2228
|
return hierarchyMap2.get(node) || null;
|
|
2149
2229
|
}
|
|
2150
|
-
function nodeHandlerAttributeValue(node) {
|
|
2151
|
-
return nodeHandlerAttributeInfo(node)?.semanticNameHint ?? null;
|
|
2230
|
+
function nodeHandlerAttributeValue(node, actionPropNames) {
|
|
2231
|
+
return nodeHandlerAttributeInfo(node, actionPropNames)?.semanticNameHint ?? null;
|
|
2232
|
+
}
|
|
2233
|
+
const LOAD_ACTION_PROP_NAMES = ["loadAction", "handler"];
|
|
2234
|
+
function resolveActionPropNames(wrapperConfig) {
|
|
2235
|
+
if (!wrapperConfig || wrapperConfig.actionProp === void 0) {
|
|
2236
|
+
return LOAD_ACTION_PROP_NAMES;
|
|
2237
|
+
}
|
|
2238
|
+
const declared = wrapperConfig.actionProp.trim();
|
|
2239
|
+
if (!declared) {
|
|
2240
|
+
throw new Error(
|
|
2241
|
+
`[vue-pom-generator] nativeWrappers actionProp must name the component's click-action prop (e.g. "loadAction"); got an empty value.`
|
|
2242
|
+
);
|
|
2243
|
+
}
|
|
2244
|
+
return [declared];
|
|
2245
|
+
}
|
|
2246
|
+
function findLoadActionDirective(node, actionPropNames = LOAD_ACTION_PROP_NAMES) {
|
|
2247
|
+
const normalizedNames = new Set(actionPropNames.map((name) => shared.camelize(name)));
|
|
2248
|
+
const directive = node.props.find((prop) => {
|
|
2249
|
+
if (prop.type !== compilerCore.NodeTypes.DIRECTIVE) {
|
|
2250
|
+
return false;
|
|
2251
|
+
}
|
|
2252
|
+
const candidate = prop;
|
|
2253
|
+
if (candidate.name !== "bind" || !candidate.exp) {
|
|
2254
|
+
return false;
|
|
2255
|
+
}
|
|
2256
|
+
const arg = candidate.arg;
|
|
2257
|
+
return arg?.type === compilerCore.NodeTypes.SIMPLE_EXPRESSION && arg.isStatic && normalizedNames.has(shared.camelize(arg.content));
|
|
2258
|
+
});
|
|
2259
|
+
return directive ?? null;
|
|
2152
2260
|
}
|
|
2153
|
-
function nodeHandlerAttributeInfo(node) {
|
|
2154
|
-
const handlerDirective =
|
|
2155
|
-
if (!handlerDirective
|
|
2261
|
+
function nodeHandlerAttributeInfo(node, actionPropNames) {
|
|
2262
|
+
const handlerDirective = findLoadActionDirective(node, actionPropNames);
|
|
2263
|
+
if (!handlerDirective) {
|
|
2156
2264
|
return null;
|
|
2157
2265
|
}
|
|
2158
2266
|
const exp = handlerDirective.exp;
|
|
@@ -2170,103 +2278,19 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2170
2278
|
preferExistingAst: false
|
|
2171
2279
|
});
|
|
2172
2280
|
const fallbackExpr = transformedSource !== authorSource ? tryParseBabelExpressionFromSource(authorSource, ["typescript", "jsx"]) : null;
|
|
2173
|
-
const isNodeType2 = (node2, type) => {
|
|
2174
|
-
return node2 !== null && node2.type === type;
|
|
2175
|
-
};
|
|
2176
|
-
const isIdentifierNode2 = (node2) => {
|
|
2177
|
-
return isNodeType2(node2, "Identifier") && typeof node2.name === "string";
|
|
2178
|
-
};
|
|
2179
|
-
const isStringLiteralNode2 = (node2) => {
|
|
2180
|
-
return isNodeType2(node2, "StringLiteral") && typeof node2.value === "string";
|
|
2181
|
-
};
|
|
2182
|
-
const isBooleanLiteralNode = (node2) => {
|
|
2183
|
-
return isNodeType2(node2, "BooleanLiteral") && typeof node2.value === "boolean";
|
|
2184
|
-
};
|
|
2185
|
-
const isNumericLiteralNode = (node2) => {
|
|
2186
|
-
return isNodeType2(node2, "NumericLiteral") && typeof node2.value === "number";
|
|
2187
|
-
};
|
|
2188
|
-
const isNullLiteralNode = (node2) => {
|
|
2189
|
-
return isNodeType2(node2, "NullLiteral");
|
|
2190
|
-
};
|
|
2191
|
-
const isMemberExpressionNode = (node2) => {
|
|
2192
|
-
if (!isNodeType2(node2, "MemberExpression"))
|
|
2193
|
-
return false;
|
|
2194
|
-
const n = node2;
|
|
2195
|
-
return typeof n.computed === "boolean" && typeof n.object === "object" && n.object !== null && typeof n.property === "object" && n.property !== null;
|
|
2196
|
-
};
|
|
2197
|
-
const isCallExpressionNode = (node2) => {
|
|
2198
|
-
if (!isNodeType2(node2, "CallExpression"))
|
|
2199
|
-
return false;
|
|
2200
|
-
const n = node2;
|
|
2201
|
-
return typeof n.callee === "object" && n.callee !== null && Array.isArray(n.arguments);
|
|
2202
|
-
};
|
|
2203
|
-
const isAwaitExpressionNode = (node2) => {
|
|
2204
|
-
if (!isNodeType2(node2, "AwaitExpression"))
|
|
2205
|
-
return false;
|
|
2206
|
-
const n = node2;
|
|
2207
|
-
return typeof n.argument === "object" && n.argument !== null;
|
|
2208
|
-
};
|
|
2209
|
-
const isAssignmentExpressionNode = (node2) => {
|
|
2210
|
-
if (!isNodeType2(node2, "AssignmentExpression"))
|
|
2211
|
-
return false;
|
|
2212
|
-
const n = node2;
|
|
2213
|
-
return typeof n.left === "object" && n.left !== null && typeof n.right === "object" && n.right !== null;
|
|
2214
|
-
};
|
|
2215
|
-
const isArrowFunctionExpressionNode = (node2) => {
|
|
2216
|
-
if (!isNodeType2(node2, "ArrowFunctionExpression"))
|
|
2217
|
-
return false;
|
|
2218
|
-
const n = node2;
|
|
2219
|
-
return typeof n.body === "object" && n.body !== null;
|
|
2220
|
-
};
|
|
2221
|
-
const isBlockStatementNode = (node2) => {
|
|
2222
|
-
if (!isNodeType2(node2, "BlockStatement"))
|
|
2223
|
-
return false;
|
|
2224
|
-
const n = node2;
|
|
2225
|
-
return Array.isArray(n.body);
|
|
2226
|
-
};
|
|
2227
|
-
const isExpressionStatementNode = (node2) => {
|
|
2228
|
-
if (!isNodeType2(node2, "ExpressionStatement"))
|
|
2229
|
-
return false;
|
|
2230
|
-
const n = node2;
|
|
2231
|
-
return typeof n.expression === "object" && n.expression !== null;
|
|
2232
|
-
};
|
|
2233
|
-
const isReturnStatementNode = (node2) => {
|
|
2234
|
-
if (!isNodeType2(node2, "ReturnStatement"))
|
|
2235
|
-
return false;
|
|
2236
|
-
const n = node2;
|
|
2237
|
-
return typeof n.argument === "object" || n.argument === null;
|
|
2238
|
-
};
|
|
2239
|
-
const isObjectExpressionNode2 = (node2) => {
|
|
2240
|
-
if (!isNodeType2(node2, "ObjectExpression"))
|
|
2241
|
-
return false;
|
|
2242
|
-
const n = node2;
|
|
2243
|
-
return Array.isArray(n.properties);
|
|
2244
|
-
};
|
|
2245
|
-
const isObjectPropertyNode2 = (node2) => {
|
|
2246
|
-
if (!isNodeType2(node2, "ObjectProperty"))
|
|
2247
|
-
return false;
|
|
2248
|
-
const n = node2;
|
|
2249
|
-
return typeof n.computed === "boolean" && typeof n.key === "object" && n.key !== null && typeof n.value === "object" && n.value !== null;
|
|
2250
|
-
};
|
|
2251
|
-
const isLogicalExpressionNode = (node2) => {
|
|
2252
|
-
if (!isNodeType2(node2, "LogicalExpression"))
|
|
2253
|
-
return false;
|
|
2254
|
-
const n = node2;
|
|
2255
|
-
return typeof n.operator === "string" && typeof n.left === "object" && n.left !== null && typeof n.right === "object" && n.right !== null;
|
|
2256
|
-
};
|
|
2257
2281
|
const getLastIdentifierFromMemberChain = (node2) => {
|
|
2258
2282
|
if (!node2)
|
|
2259
2283
|
return null;
|
|
2260
|
-
if (
|
|
2284
|
+
if (isIdentifierNode(node2))
|
|
2261
2285
|
return node2.name;
|
|
2262
2286
|
if (isMemberExpressionNode(node2)) {
|
|
2263
2287
|
const prop = node2.property;
|
|
2264
2288
|
if (node2.computed === false) {
|
|
2265
|
-
if (
|
|
2289
|
+
if (isIdentifierNode(prop))
|
|
2266
2290
|
return prop.name;
|
|
2267
2291
|
}
|
|
2268
2292
|
if (node2.computed === true) {
|
|
2269
|
-
if (
|
|
2293
|
+
if (isStringLiteralNode(prop))
|
|
2270
2294
|
return prop.value;
|
|
2271
2295
|
}
|
|
2272
2296
|
}
|
|
@@ -2276,7 +2300,7 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2276
2300
|
if (!node2) {
|
|
2277
2301
|
return null;
|
|
2278
2302
|
}
|
|
2279
|
-
if (
|
|
2303
|
+
if (isIdentifierNode(node2)) {
|
|
2280
2304
|
return node2.name;
|
|
2281
2305
|
}
|
|
2282
2306
|
if (isMemberExpressionNode(node2)) {
|
|
@@ -2288,11 +2312,11 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2288
2312
|
if (!lhs) {
|
|
2289
2313
|
return null;
|
|
2290
2314
|
}
|
|
2291
|
-
if (
|
|
2315
|
+
if (isIdentifierNode(lhs)) {
|
|
2292
2316
|
return lhs.name;
|
|
2293
2317
|
}
|
|
2294
2318
|
if (isMemberExpressionNode(lhs)) {
|
|
2295
|
-
if (lhs.computed === false &&
|
|
2319
|
+
if (lhs.computed === false && isIdentifierNode(lhs.property) && lhs.property.name === "value") {
|
|
2296
2320
|
return getLastIdentifierFromMemberChain(lhs.object);
|
|
2297
2321
|
}
|
|
2298
2322
|
return getLastIdentifierFromMemberChain(lhs);
|
|
@@ -2300,7 +2324,7 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2300
2324
|
return null;
|
|
2301
2325
|
};
|
|
2302
2326
|
const isTemplateLiteralNode = (node2) => {
|
|
2303
|
-
if (!
|
|
2327
|
+
if (!isNodeType(node2, "TemplateLiteral")) {
|
|
2304
2328
|
return false;
|
|
2305
2329
|
}
|
|
2306
2330
|
const n = node2;
|
|
@@ -2319,7 +2343,7 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2319
2343
|
if (isNullLiteralNode(arg)) {
|
|
2320
2344
|
return "Null";
|
|
2321
2345
|
}
|
|
2322
|
-
if (
|
|
2346
|
+
if (isStringLiteralNode(arg)) {
|
|
2323
2347
|
const cleaned = (arg.value ?? "").trim();
|
|
2324
2348
|
if (!cleaned) {
|
|
2325
2349
|
return null;
|
|
@@ -2345,7 +2369,7 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2345
2369
|
return toPascalCase(stableName.slice(0, 24));
|
|
2346
2370
|
}
|
|
2347
2371
|
}
|
|
2348
|
-
if (
|
|
2372
|
+
if (isIdentifierNode(arg)) {
|
|
2349
2373
|
const firstChar = arg.name.charAt(0);
|
|
2350
2374
|
const isUpperAlpha = firstChar !== "" && firstChar === firstChar.toUpperCase() && firstChar !== firstChar.toLowerCase();
|
|
2351
2375
|
if (isUpperAlpha) {
|
|
@@ -2357,7 +2381,7 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2357
2381
|
const getStableSuffixFromCall = (call) => {
|
|
2358
2382
|
const args = call.arguments ?? [];
|
|
2359
2383
|
const first = args.length > 0 ? args[0] : null;
|
|
2360
|
-
if (!
|
|
2384
|
+
if (!isObjectExpressionNode(first)) {
|
|
2361
2385
|
const parts2 = [];
|
|
2362
2386
|
for (const arg of args.slice(0, 4)) {
|
|
2363
2387
|
const w = stableWordFromValue(arg ?? null);
|
|
@@ -2376,20 +2400,20 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2376
2400
|
}
|
|
2377
2401
|
const parts = [];
|
|
2378
2402
|
for (const prop of first.properties ?? []) {
|
|
2379
|
-
if (!
|
|
2403
|
+
if (!isObjectPropertyNode(prop)) {
|
|
2380
2404
|
continue;
|
|
2381
2405
|
}
|
|
2382
2406
|
if (prop.computed) {
|
|
2383
2407
|
continue;
|
|
2384
2408
|
}
|
|
2385
|
-
const keyName =
|
|
2409
|
+
const keyName = isIdentifierNode(prop.key) ? prop.key.name : isStringLiteralNode(prop.key) ? prop.key.value : null;
|
|
2386
2410
|
if (!keyName) {
|
|
2387
2411
|
continue;
|
|
2388
2412
|
}
|
|
2389
2413
|
let valueWord = null;
|
|
2390
2414
|
if (isBooleanLiteralNode(prop.value)) {
|
|
2391
2415
|
valueWord = prop.value.value ? "True" : "False";
|
|
2392
|
-
} else if (
|
|
2416
|
+
} else if (isStringLiteralNode(prop.value)) {
|
|
2393
2417
|
const cleaned = (prop.value.value ?? "").trim();
|
|
2394
2418
|
if (cleaned) {
|
|
2395
2419
|
valueWord = toPascalCase(cleaned.slice(0, 24));
|
|
@@ -2489,7 +2513,7 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2489
2513
|
return null;
|
|
2490
2514
|
};
|
|
2491
2515
|
const isVueRefValueAccess = (candidate) => {
|
|
2492
|
-
return isMemberExpressionNode(candidate) && candidate.computed === false &&
|
|
2516
|
+
return isMemberExpressionNode(candidate) && candidate.computed === false && isIdentifierNode(candidate.property) && candidate.property.name === "value";
|
|
2493
2517
|
};
|
|
2494
2518
|
const transformedSemanticName = resolveSemanticName(expr);
|
|
2495
2519
|
const fallbackSemanticName = resolveSemanticName(fallbackExpr);
|
|
@@ -2625,36 +2649,15 @@ function toDirectiveObjectFieldNameValue(node) {
|
|
|
2625
2649
|
if (!expr) {
|
|
2626
2650
|
return null;
|
|
2627
2651
|
}
|
|
2628
|
-
|
|
2629
|
-
return n !== null && n.type === type;
|
|
2630
|
-
};
|
|
2631
|
-
const isStringLiteralNode2 = (n) => {
|
|
2632
|
-
return isNodeType2(n, "StringLiteral") && typeof n.value === "string";
|
|
2633
|
-
};
|
|
2634
|
-
const isIdentifierNode2 = (n) => {
|
|
2635
|
-
return isNodeType2(n, "Identifier") && typeof n.name === "string";
|
|
2636
|
-
};
|
|
2637
|
-
const isObjectPropertyNode2 = (n) => {
|
|
2638
|
-
if (!isNodeType2(n, "ObjectProperty"))
|
|
2639
|
-
return false;
|
|
2640
|
-
const nn = n;
|
|
2641
|
-
return typeof nn.key === "object" && nn.key !== null && typeof nn.value === "object" && nn.value !== null;
|
|
2642
|
-
};
|
|
2643
|
-
const isObjectExpressionNode2 = (n) => {
|
|
2644
|
-
if (!isNodeType2(n, "ObjectExpression"))
|
|
2645
|
-
return false;
|
|
2646
|
-
const nn = n;
|
|
2647
|
-
return Array.isArray(nn.properties);
|
|
2648
|
-
};
|
|
2649
|
-
if (!isObjectExpressionNode2(expr))
|
|
2652
|
+
if (!isObjectExpressionNode(expr))
|
|
2650
2653
|
return null;
|
|
2651
2654
|
const nameProp = expr.properties.find((p) => {
|
|
2652
|
-
if (!
|
|
2655
|
+
if (!isObjectPropertyNodeShallow(p))
|
|
2653
2656
|
return false;
|
|
2654
2657
|
const key = p.key;
|
|
2655
|
-
return
|
|
2658
|
+
return isIdentifierNode(key) && key.name === "name" || isStringLiteralNode(key) && key.value === "name";
|
|
2656
2659
|
});
|
|
2657
|
-
if (!nameProp || !
|
|
2660
|
+
if (!nameProp || !isObjectPropertyNodeShallow(nameProp) || !isStringLiteralNode(nameProp.value))
|
|
2658
2661
|
return null;
|
|
2659
2662
|
return toPascalCase(nameProp.value.value);
|
|
2660
2663
|
}
|
|
@@ -9347,26 +9350,17 @@ function tryExtractStableHintFromConditionalExpressionSource(source) {
|
|
|
9347
9350
|
};
|
|
9348
9351
|
try {
|
|
9349
9352
|
const expr = parser.parseExpression(src, { plugins: ["typescript"] });
|
|
9350
|
-
const isNodeType2 = (n, type) => {
|
|
9351
|
-
return n !== null && n.type === type;
|
|
9352
|
-
};
|
|
9353
|
-
const isStringLiteralNode2 = (n) => {
|
|
9354
|
-
return isNodeType2(n, "StringLiteral") && typeof n.value === "string";
|
|
9355
|
-
};
|
|
9356
|
-
const isIdentifierNode2 = (n) => {
|
|
9357
|
-
return isNodeType2(n, "Identifier") && typeof n.name === "string";
|
|
9358
|
-
};
|
|
9359
9353
|
const results = [];
|
|
9360
9354
|
const walk = (n) => {
|
|
9361
9355
|
if (!n)
|
|
9362
9356
|
return;
|
|
9363
|
-
if (
|
|
9357
|
+
if (isStringLiteralNode(n)) {
|
|
9364
9358
|
const v = (n.value ?? "").trim();
|
|
9365
9359
|
if (isIdentifierish(v)) {
|
|
9366
9360
|
results.push(v);
|
|
9367
9361
|
}
|
|
9368
9362
|
}
|
|
9369
|
-
if (
|
|
9363
|
+
if (isIdentifierNode(n)) {
|
|
9370
9364
|
const v = (n.name ?? "").trim();
|
|
9371
9365
|
if (isIdentifierish(v)) {
|
|
9372
9366
|
results.push(v);
|
|
@@ -10032,20 +10026,29 @@ File: ${context.filename ?? "unknown"}:${loc.line}:${loc.column}`
|
|
|
10032
10026
|
});
|
|
10033
10027
|
};
|
|
10034
10028
|
const { nativeWrappersValue, optionDataTestIdPrefixValue, semanticNameHint } = getNativeWrapperTransformInfo(element, componentName, resolvedNativeWrappers);
|
|
10035
|
-
const
|
|
10036
|
-
|
|
10037
|
-
|
|
10038
|
-
const handlerInfo = handlerDirective ? nodeHandlerAttributeInfo(element) : null;
|
|
10039
|
-
if (
|
|
10029
|
+
const wrapperConfig = resolvedNativeWrappers[element.tag];
|
|
10030
|
+
const actionPropNames = resolveActionPropNames(wrapperConfig);
|
|
10031
|
+
const handlerDirective = findLoadActionDirective(element, actionPropNames);
|
|
10032
|
+
const handlerInfo = handlerDirective ? nodeHandlerAttributeInfo(element, actionPropNames) : null;
|
|
10033
|
+
if (wrapperConfig?.role === "button" && handlerDirective && !handlerInfo) {
|
|
10040
10034
|
const loc = element.loc?.start;
|
|
10041
10035
|
const locationHint = loc ? `${loc.line}:${loc.column}` : "unknown";
|
|
10042
10036
|
const handlerSource = (handlerDirective.exp?.loc?.source ?? "").trim() || "<unknown>";
|
|
10037
|
+
const actionArgName = handlerDirective.arg.content;
|
|
10043
10038
|
throw new Error(
|
|
10044
10039
|
`[vue-pom-generator] Could not derive a semantic POM action name for button-like wrapper in ${componentName} (${context.filename ?? "unknown"}:${locationHint}).
|
|
10045
10040
|
Element: <${element.tag}>
|
|
10046
10041
|
Handler: ${handlerSource}
|
|
10047
10042
|
|
|
10048
|
-
Fix: move complex inline logic into a named function (for example, const onAction = () => ...; then bind
|
|
10043
|
+
Fix: move complex inline logic into a named function (for example, const onAction = () => ...; then bind :${actionArgName}="onAction"), or simplify the handler to a direct identifier/call the generator can name.`
|
|
10044
|
+
);
|
|
10045
|
+
}
|
|
10046
|
+
if (wrapperConfig?.actionProp && !handlerDirective && !nodeHasStaticClickDirective(element)) {
|
|
10047
|
+
const loc = element.loc?.start;
|
|
10048
|
+
const locationHint = loc ? `${loc.line}:${loc.column}` : "unknown";
|
|
10049
|
+
throw new Error(
|
|
10050
|
+
`[vue-pom-generator] Wrapper <${element.tag}> declares actionProp "${wrapperConfig.actionProp}" but this usage in ${componentName} (${context.filename ?? "unknown"}:${locationHint}) binds neither :${wrapperConfig.actionProp} nor @click.
|
|
10051
|
+
Fix: bind :${wrapperConfig.actionProp}="onAction" (or @click="...") so the usage exposes an actionable POM member, or remove actionProp from the wrapper config if this component is not action-driven.`
|
|
10049
10052
|
);
|
|
10050
10053
|
}
|
|
10051
10054
|
if (nativeWrappersValue) {
|
|
@@ -10206,7 +10209,7 @@ Fix: remove the explicit ${attrLabel}, or change existingIdBehavior to "overwrit
|
|
|
10206
10209
|
if (!isRecognizedInteractiveRole) {
|
|
10207
10210
|
return;
|
|
10208
10211
|
}
|
|
10209
|
-
const identifierHint = getStaticIdOrNameHint(element) || nodeHandlerAttributeValue(element) || innerText || existingElementDataTestId.value || conditionalHint || void 0;
|
|
10212
|
+
const identifierHint = getStaticIdOrNameHint(element) || nodeHandlerAttributeValue(element, actionPropNames) || innerText || existingElementDataTestId.value || conditionalHint || void 0;
|
|
10210
10213
|
const preferredGeneratedValue = existingElementDataTestId.isDynamic ? templateAttributeValue(existingElementDataTestId.template) : staticAttributeValue(existingElementDataTestId.value);
|
|
10211
10214
|
applyResolvedDataTestIdForElement({
|
|
10212
10215
|
preferredGeneratedValue,
|