@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/dist/index.mjs CHANGED
@@ -9,6 +9,7 @@ import * as compilerDom from "@vue/compiler-dom";
9
9
  import { parse as parse$2, NodeTypes as NodeTypes$1 } from "@vue/compiler-dom";
10
10
  import { parse as parse$1, compileScript } from "@vue/compiler-sfc";
11
11
  import { Project, QuoteKind, NewLineKind, IndentationText, CodeBlockWriter, StructureKind, VariableDeclarationKind } from "ts-morph";
12
+ import { camelize } from "@vue/shared";
12
13
  import { isIdentifier, isObjectPattern, isRestElement, isObjectProperty, isArrayExpression, isStringLiteral, isTemplateLiteral, isArrowFunctionExpression, isExpressionStatement, isAssignmentPattern, isMemberExpression, isOptionalMemberExpression, isCallExpression, isOptionalCallExpression, isAssignmentExpression, isObjectExpression, isFile, isBlockStatement, isLogicalExpression, isConditionalExpression, isSequenceExpression, isProgram, isArrayPattern, VISITOR_KEYS, isBooleanLiteral, isNumericLiteral, isNullLiteral, isImportDeclaration, isImportSpecifier, isExportDefaultDeclaration, isExpression, isVariableDeclaration, isFunctionDeclaration, isFunctionExpression, isReturnStatement, isTSAsExpression, isTSTypeAssertion, isTSNonNullExpression, isForInStatement, isIfStatement } from "@babel/types";
13
14
  import { createHash, randomUUID } from "node:crypto";
14
15
  import { POM_ROUTER_GLOBAL_NAME } from "./router.mjs";
@@ -1058,6 +1059,96 @@ function collectAccessibilityReviewWarnings(manifest) {
1058
1059
  }
1059
1060
  return warnings;
1060
1061
  }
1062
+ const isNodeType = (node, type) => {
1063
+ return node !== null && node.type === type;
1064
+ };
1065
+ const isIdentifierNode = (node) => {
1066
+ return isNodeType(node, "Identifier") && typeof node.name === "string";
1067
+ };
1068
+ const isStringLiteralNode = (node) => {
1069
+ return isNodeType(node, "StringLiteral") && typeof node.value === "string";
1070
+ };
1071
+ const isBooleanLiteralNode = (node) => {
1072
+ return isNodeType(node, "BooleanLiteral") && typeof node.value === "boolean";
1073
+ };
1074
+ const isNumericLiteralNode = (node) => {
1075
+ return isNodeType(node, "NumericLiteral") && typeof node.value === "number";
1076
+ };
1077
+ const isNullLiteralNode = (node) => {
1078
+ return isNodeType(node, "NullLiteral");
1079
+ };
1080
+ const isMemberExpressionNode = (node) => {
1081
+ if (!isNodeType(node, "MemberExpression"))
1082
+ return false;
1083
+ const n = node;
1084
+ return typeof n.computed === "boolean" && typeof n.object === "object" && n.object !== null && typeof n.property === "object" && n.property !== null;
1085
+ };
1086
+ const isCallExpressionNode = (node) => {
1087
+ if (!isNodeType(node, "CallExpression"))
1088
+ return false;
1089
+ const n = node;
1090
+ return typeof n.callee === "object" && n.callee !== null && Array.isArray(n.arguments);
1091
+ };
1092
+ const isAwaitExpressionNode = (node) => {
1093
+ if (!isNodeType(node, "AwaitExpression"))
1094
+ return false;
1095
+ const n = node;
1096
+ return typeof n.argument === "object" && n.argument !== null;
1097
+ };
1098
+ const isAssignmentExpressionNode = (node) => {
1099
+ if (!isNodeType(node, "AssignmentExpression"))
1100
+ return false;
1101
+ const n = node;
1102
+ return typeof n.left === "object" && n.left !== null && typeof n.right === "object" && n.right !== null;
1103
+ };
1104
+ const isArrowFunctionExpressionNode = (node) => {
1105
+ if (!isNodeType(node, "ArrowFunctionExpression"))
1106
+ return false;
1107
+ const n = node;
1108
+ return typeof n.body === "object" && n.body !== null;
1109
+ };
1110
+ const isBlockStatementNode = (node) => {
1111
+ if (!isNodeType(node, "BlockStatement"))
1112
+ return false;
1113
+ const n = node;
1114
+ return Array.isArray(n.body);
1115
+ };
1116
+ const isExpressionStatementNode = (node) => {
1117
+ if (!isNodeType(node, "ExpressionStatement"))
1118
+ return false;
1119
+ const n = node;
1120
+ return typeof n.expression === "object" && n.expression !== null;
1121
+ };
1122
+ const isReturnStatementNode = (node) => {
1123
+ if (!isNodeType(node, "ReturnStatement"))
1124
+ return false;
1125
+ const n = node;
1126
+ return typeof n.argument === "object" || n.argument === null;
1127
+ };
1128
+ const isObjectExpressionNode = (node) => {
1129
+ if (!isNodeType(node, "ObjectExpression"))
1130
+ return false;
1131
+ const n = node;
1132
+ return Array.isArray(n.properties);
1133
+ };
1134
+ const isObjectPropertyNode = (node) => {
1135
+ if (!isNodeType(node, "ObjectProperty"))
1136
+ return false;
1137
+ const n = node;
1138
+ return typeof n.computed === "boolean" && typeof n.key === "object" && n.key !== null && typeof n.value === "object" && n.value !== null;
1139
+ };
1140
+ const isObjectPropertyNodeShallow = (node) => {
1141
+ if (!isNodeType(node, "ObjectProperty"))
1142
+ return false;
1143
+ const n = node;
1144
+ return typeof n.key === "object" && n.key !== null && typeof n.value === "object" && n.value !== null;
1145
+ };
1146
+ const isLogicalExpressionNode = (node) => {
1147
+ if (!isNodeType(node, "LogicalExpression"))
1148
+ return false;
1149
+ const n = node;
1150
+ return typeof n.operator === "string" && typeof n.left === "object" && n.left !== null && typeof n.right === "object" && n.right !== null;
1151
+ };
1061
1152
  function isSimpleExpressionNode(value) {
1062
1153
  return value !== null && "type" in value && value.type === NodeTypes.SIMPLE_EXPRESSION;
1063
1154
  }
@@ -1096,27 +1187,6 @@ function buildPlaceholderParams(keys) {
1096
1187
  params[k] = "__placeholder__";
1097
1188
  return params;
1098
1189
  }
1099
- const isNodeType = (node, type) => {
1100
- return node !== null && node.type === type;
1101
- };
1102
- const isStringLiteralNode = (node) => {
1103
- return isNodeType(node, "StringLiteral") && typeof node.value === "string";
1104
- };
1105
- const isIdentifierNode = (node) => {
1106
- return isNodeType(node, "Identifier") && typeof node.name === "string";
1107
- };
1108
- const isObjectPropertyNode = (node) => {
1109
- if (!isNodeType(node, "ObjectProperty"))
1110
- return false;
1111
- const n = node;
1112
- return typeof n.key === "object" && n.key !== null && typeof n.value === "object" && n.value !== null;
1113
- };
1114
- const isObjectExpressionNode = (node) => {
1115
- if (!isNodeType(node, "ObjectExpression"))
1116
- return false;
1117
- const n = node;
1118
- return Array.isArray(n.properties);
1119
- };
1120
1190
  function materializeResolvedRouteTarget(target, paramKeys) {
1121
1191
  if (typeof target === "string")
1122
1192
  return target;
@@ -1392,6 +1462,16 @@ function tryGetClickDirective(node) {
1392
1462
  function nodeHasClickDirective(node) {
1393
1463
  return tryGetClickDirective(node) !== void 0;
1394
1464
  }
1465
+ function nodeHasStaticClickDirective(node) {
1466
+ return node.props.some((prop) => {
1467
+ if (prop.type !== NodeTypes.DIRECTIVE) {
1468
+ return false;
1469
+ }
1470
+ const directive = prop;
1471
+ const arg = directive.arg;
1472
+ return directive.name === "on" && arg?.type === NodeTypes.SIMPLE_EXPRESSION && arg.isStatic && arg.content === "click";
1473
+ });
1474
+ }
1395
1475
  function findTemplateSlotScopeExpression(node) {
1396
1476
  if (node.tag !== "template") {
1397
1477
  return null;
@@ -2106,12 +2186,40 @@ function tryGetContainedInStaticVForSourceLiteralValues(context, _node, _hierarc
2106
2186
  function getParent(hierarchyMap2, node) {
2107
2187
  return hierarchyMap2.get(node) || null;
2108
2188
  }
2109
- function nodeHandlerAttributeValue(node) {
2110
- return nodeHandlerAttributeInfo(node)?.semanticNameHint ?? null;
2189
+ function nodeHandlerAttributeValue(node, actionPropNames) {
2190
+ return nodeHandlerAttributeInfo(node, actionPropNames)?.semanticNameHint ?? null;
2191
+ }
2192
+ const LOAD_ACTION_PROP_NAMES = ["loadAction", "handler"];
2193
+ function resolveActionPropNames(wrapperConfig) {
2194
+ if (!wrapperConfig || wrapperConfig.actionProp === void 0) {
2195
+ return LOAD_ACTION_PROP_NAMES;
2196
+ }
2197
+ const declared = wrapperConfig.actionProp.trim();
2198
+ if (!declared) {
2199
+ throw new Error(
2200
+ `[vue-pom-generator] nativeWrappers actionProp must name the component's click-action prop (e.g. "loadAction"); got an empty value.`
2201
+ );
2202
+ }
2203
+ return [declared];
2204
+ }
2205
+ function findLoadActionDirective(node, actionPropNames = LOAD_ACTION_PROP_NAMES) {
2206
+ const normalizedNames = new Set(actionPropNames.map((name) => camelize(name)));
2207
+ const directive = node.props.find((prop) => {
2208
+ if (prop.type !== NodeTypes.DIRECTIVE) {
2209
+ return false;
2210
+ }
2211
+ const candidate = prop;
2212
+ if (candidate.name !== "bind" || !candidate.exp) {
2213
+ return false;
2214
+ }
2215
+ const arg = candidate.arg;
2216
+ return arg?.type === NodeTypes.SIMPLE_EXPRESSION && arg.isStatic && normalizedNames.has(camelize(arg.content));
2217
+ });
2218
+ return directive ?? null;
2111
2219
  }
2112
- function nodeHandlerAttributeInfo(node) {
2113
- const handlerDirective = findDirectiveByName(node, "bind", "handler");
2114
- if (!handlerDirective?.exp) {
2220
+ function nodeHandlerAttributeInfo(node, actionPropNames) {
2221
+ const handlerDirective = findLoadActionDirective(node, actionPropNames);
2222
+ if (!handlerDirective) {
2115
2223
  return null;
2116
2224
  }
2117
2225
  const exp = handlerDirective.exp;
@@ -2129,103 +2237,19 @@ function nodeHandlerAttributeInfo(node) {
2129
2237
  preferExistingAst: false
2130
2238
  });
2131
2239
  const fallbackExpr = transformedSource !== authorSource ? tryParseBabelExpressionFromSource(authorSource, ["typescript", "jsx"]) : null;
2132
- const isNodeType2 = (node2, type) => {
2133
- return node2 !== null && node2.type === type;
2134
- };
2135
- const isIdentifierNode2 = (node2) => {
2136
- return isNodeType2(node2, "Identifier") && typeof node2.name === "string";
2137
- };
2138
- const isStringLiteralNode2 = (node2) => {
2139
- return isNodeType2(node2, "StringLiteral") && typeof node2.value === "string";
2140
- };
2141
- const isBooleanLiteralNode = (node2) => {
2142
- return isNodeType2(node2, "BooleanLiteral") && typeof node2.value === "boolean";
2143
- };
2144
- const isNumericLiteralNode = (node2) => {
2145
- return isNodeType2(node2, "NumericLiteral") && typeof node2.value === "number";
2146
- };
2147
- const isNullLiteralNode = (node2) => {
2148
- return isNodeType2(node2, "NullLiteral");
2149
- };
2150
- const isMemberExpressionNode = (node2) => {
2151
- if (!isNodeType2(node2, "MemberExpression"))
2152
- return false;
2153
- const n = node2;
2154
- return typeof n.computed === "boolean" && typeof n.object === "object" && n.object !== null && typeof n.property === "object" && n.property !== null;
2155
- };
2156
- const isCallExpressionNode = (node2) => {
2157
- if (!isNodeType2(node2, "CallExpression"))
2158
- return false;
2159
- const n = node2;
2160
- return typeof n.callee === "object" && n.callee !== null && Array.isArray(n.arguments);
2161
- };
2162
- const isAwaitExpressionNode = (node2) => {
2163
- if (!isNodeType2(node2, "AwaitExpression"))
2164
- return false;
2165
- const n = node2;
2166
- return typeof n.argument === "object" && n.argument !== null;
2167
- };
2168
- const isAssignmentExpressionNode = (node2) => {
2169
- if (!isNodeType2(node2, "AssignmentExpression"))
2170
- return false;
2171
- const n = node2;
2172
- return typeof n.left === "object" && n.left !== null && typeof n.right === "object" && n.right !== null;
2173
- };
2174
- const isArrowFunctionExpressionNode = (node2) => {
2175
- if (!isNodeType2(node2, "ArrowFunctionExpression"))
2176
- return false;
2177
- const n = node2;
2178
- return typeof n.body === "object" && n.body !== null;
2179
- };
2180
- const isBlockStatementNode = (node2) => {
2181
- if (!isNodeType2(node2, "BlockStatement"))
2182
- return false;
2183
- const n = node2;
2184
- return Array.isArray(n.body);
2185
- };
2186
- const isExpressionStatementNode = (node2) => {
2187
- if (!isNodeType2(node2, "ExpressionStatement"))
2188
- return false;
2189
- const n = node2;
2190
- return typeof n.expression === "object" && n.expression !== null;
2191
- };
2192
- const isReturnStatementNode = (node2) => {
2193
- if (!isNodeType2(node2, "ReturnStatement"))
2194
- return false;
2195
- const n = node2;
2196
- return typeof n.argument === "object" || n.argument === null;
2197
- };
2198
- const isObjectExpressionNode2 = (node2) => {
2199
- if (!isNodeType2(node2, "ObjectExpression"))
2200
- return false;
2201
- const n = node2;
2202
- return Array.isArray(n.properties);
2203
- };
2204
- const isObjectPropertyNode2 = (node2) => {
2205
- if (!isNodeType2(node2, "ObjectProperty"))
2206
- return false;
2207
- const n = node2;
2208
- return typeof n.computed === "boolean" && typeof n.key === "object" && n.key !== null && typeof n.value === "object" && n.value !== null;
2209
- };
2210
- const isLogicalExpressionNode = (node2) => {
2211
- if (!isNodeType2(node2, "LogicalExpression"))
2212
- return false;
2213
- const n = node2;
2214
- return typeof n.operator === "string" && typeof n.left === "object" && n.left !== null && typeof n.right === "object" && n.right !== null;
2215
- };
2216
2240
  const getLastIdentifierFromMemberChain = (node2) => {
2217
2241
  if (!node2)
2218
2242
  return null;
2219
- if (isIdentifierNode2(node2))
2243
+ if (isIdentifierNode(node2))
2220
2244
  return node2.name;
2221
2245
  if (isMemberExpressionNode(node2)) {
2222
2246
  const prop = node2.property;
2223
2247
  if (node2.computed === false) {
2224
- if (isIdentifierNode2(prop))
2248
+ if (isIdentifierNode(prop))
2225
2249
  return prop.name;
2226
2250
  }
2227
2251
  if (node2.computed === true) {
2228
- if (isStringLiteralNode2(prop))
2252
+ if (isStringLiteralNode(prop))
2229
2253
  return prop.value;
2230
2254
  }
2231
2255
  }
@@ -2235,7 +2259,7 @@ function nodeHandlerAttributeInfo(node) {
2235
2259
  if (!node2) {
2236
2260
  return null;
2237
2261
  }
2238
- if (isIdentifierNode2(node2)) {
2262
+ if (isIdentifierNode(node2)) {
2239
2263
  return node2.name;
2240
2264
  }
2241
2265
  if (isMemberExpressionNode(node2)) {
@@ -2247,11 +2271,11 @@ function nodeHandlerAttributeInfo(node) {
2247
2271
  if (!lhs) {
2248
2272
  return null;
2249
2273
  }
2250
- if (isIdentifierNode2(lhs)) {
2274
+ if (isIdentifierNode(lhs)) {
2251
2275
  return lhs.name;
2252
2276
  }
2253
2277
  if (isMemberExpressionNode(lhs)) {
2254
- if (lhs.computed === false && isIdentifierNode2(lhs.property) && lhs.property.name === "value") {
2278
+ if (lhs.computed === false && isIdentifierNode(lhs.property) && lhs.property.name === "value") {
2255
2279
  return getLastIdentifierFromMemberChain(lhs.object);
2256
2280
  }
2257
2281
  return getLastIdentifierFromMemberChain(lhs);
@@ -2259,7 +2283,7 @@ function nodeHandlerAttributeInfo(node) {
2259
2283
  return null;
2260
2284
  };
2261
2285
  const isTemplateLiteralNode = (node2) => {
2262
- if (!isNodeType2(node2, "TemplateLiteral")) {
2286
+ if (!isNodeType(node2, "TemplateLiteral")) {
2263
2287
  return false;
2264
2288
  }
2265
2289
  const n = node2;
@@ -2278,7 +2302,7 @@ function nodeHandlerAttributeInfo(node) {
2278
2302
  if (isNullLiteralNode(arg)) {
2279
2303
  return "Null";
2280
2304
  }
2281
- if (isStringLiteralNode2(arg)) {
2305
+ if (isStringLiteralNode(arg)) {
2282
2306
  const cleaned = (arg.value ?? "").trim();
2283
2307
  if (!cleaned) {
2284
2308
  return null;
@@ -2304,7 +2328,7 @@ function nodeHandlerAttributeInfo(node) {
2304
2328
  return toPascalCase(stableName.slice(0, 24));
2305
2329
  }
2306
2330
  }
2307
- if (isIdentifierNode2(arg)) {
2331
+ if (isIdentifierNode(arg)) {
2308
2332
  const firstChar = arg.name.charAt(0);
2309
2333
  const isUpperAlpha = firstChar !== "" && firstChar === firstChar.toUpperCase() && firstChar !== firstChar.toLowerCase();
2310
2334
  if (isUpperAlpha) {
@@ -2316,7 +2340,7 @@ function nodeHandlerAttributeInfo(node) {
2316
2340
  const getStableSuffixFromCall = (call) => {
2317
2341
  const args = call.arguments ?? [];
2318
2342
  const first = args.length > 0 ? args[0] : null;
2319
- if (!isObjectExpressionNode2(first)) {
2343
+ if (!isObjectExpressionNode(first)) {
2320
2344
  const parts2 = [];
2321
2345
  for (const arg of args.slice(0, 4)) {
2322
2346
  const w = stableWordFromValue(arg ?? null);
@@ -2335,20 +2359,20 @@ function nodeHandlerAttributeInfo(node) {
2335
2359
  }
2336
2360
  const parts = [];
2337
2361
  for (const prop of first.properties ?? []) {
2338
- if (!isObjectPropertyNode2(prop)) {
2362
+ if (!isObjectPropertyNode(prop)) {
2339
2363
  continue;
2340
2364
  }
2341
2365
  if (prop.computed) {
2342
2366
  continue;
2343
2367
  }
2344
- const keyName = isIdentifierNode2(prop.key) ? prop.key.name : isStringLiteralNode2(prop.key) ? prop.key.value : null;
2368
+ const keyName = isIdentifierNode(prop.key) ? prop.key.name : isStringLiteralNode(prop.key) ? prop.key.value : null;
2345
2369
  if (!keyName) {
2346
2370
  continue;
2347
2371
  }
2348
2372
  let valueWord = null;
2349
2373
  if (isBooleanLiteralNode(prop.value)) {
2350
2374
  valueWord = prop.value.value ? "True" : "False";
2351
- } else if (isStringLiteralNode2(prop.value)) {
2375
+ } else if (isStringLiteralNode(prop.value)) {
2352
2376
  const cleaned = (prop.value.value ?? "").trim();
2353
2377
  if (cleaned) {
2354
2378
  valueWord = toPascalCase(cleaned.slice(0, 24));
@@ -2448,7 +2472,7 @@ function nodeHandlerAttributeInfo(node) {
2448
2472
  return null;
2449
2473
  };
2450
2474
  const isVueRefValueAccess = (candidate) => {
2451
- return isMemberExpressionNode(candidate) && candidate.computed === false && isIdentifierNode2(candidate.property) && candidate.property.name === "value";
2475
+ return isMemberExpressionNode(candidate) && candidate.computed === false && isIdentifierNode(candidate.property) && candidate.property.name === "value";
2452
2476
  };
2453
2477
  const transformedSemanticName = resolveSemanticName(expr);
2454
2478
  const fallbackSemanticName = resolveSemanticName(fallbackExpr);
@@ -2584,36 +2608,15 @@ function toDirectiveObjectFieldNameValue(node) {
2584
2608
  if (!expr) {
2585
2609
  return null;
2586
2610
  }
2587
- const isNodeType2 = (n, type) => {
2588
- return n !== null && n.type === type;
2589
- };
2590
- const isStringLiteralNode2 = (n) => {
2591
- return isNodeType2(n, "StringLiteral") && typeof n.value === "string";
2592
- };
2593
- const isIdentifierNode2 = (n) => {
2594
- return isNodeType2(n, "Identifier") && typeof n.name === "string";
2595
- };
2596
- const isObjectPropertyNode2 = (n) => {
2597
- if (!isNodeType2(n, "ObjectProperty"))
2598
- return false;
2599
- const nn = n;
2600
- return typeof nn.key === "object" && nn.key !== null && typeof nn.value === "object" && nn.value !== null;
2601
- };
2602
- const isObjectExpressionNode2 = (n) => {
2603
- if (!isNodeType2(n, "ObjectExpression"))
2604
- return false;
2605
- const nn = n;
2606
- return Array.isArray(nn.properties);
2607
- };
2608
- if (!isObjectExpressionNode2(expr))
2611
+ if (!isObjectExpressionNode(expr))
2609
2612
  return null;
2610
2613
  const nameProp = expr.properties.find((p) => {
2611
- if (!isObjectPropertyNode2(p))
2614
+ if (!isObjectPropertyNodeShallow(p))
2612
2615
  return false;
2613
2616
  const key = p.key;
2614
- return isIdentifierNode2(key) && key.name === "name" || isStringLiteralNode2(key) && key.value === "name";
2617
+ return isIdentifierNode(key) && key.name === "name" || isStringLiteralNode(key) && key.value === "name";
2615
2618
  });
2616
- if (!nameProp || !isObjectPropertyNode2(nameProp) || !isStringLiteralNode2(nameProp.value))
2619
+ if (!nameProp || !isObjectPropertyNodeShallow(nameProp) || !isStringLiteralNode(nameProp.value))
2617
2620
  return null;
2618
2621
  return toPascalCase(nameProp.value.value);
2619
2622
  }
@@ -9306,26 +9309,17 @@ function tryExtractStableHintFromConditionalExpressionSource(source) {
9306
9309
  };
9307
9310
  try {
9308
9311
  const expr = parseExpression(src, { plugins: ["typescript"] });
9309
- const isNodeType2 = (n, type) => {
9310
- return n !== null && n.type === type;
9311
- };
9312
- const isStringLiteralNode2 = (n) => {
9313
- return isNodeType2(n, "StringLiteral") && typeof n.value === "string";
9314
- };
9315
- const isIdentifierNode2 = (n) => {
9316
- return isNodeType2(n, "Identifier") && typeof n.name === "string";
9317
- };
9318
9312
  const results = [];
9319
9313
  const walk = (n) => {
9320
9314
  if (!n)
9321
9315
  return;
9322
- if (isStringLiteralNode2(n)) {
9316
+ if (isStringLiteralNode(n)) {
9323
9317
  const v = (n.value ?? "").trim();
9324
9318
  if (isIdentifierish(v)) {
9325
9319
  results.push(v);
9326
9320
  }
9327
9321
  }
9328
- if (isIdentifierNode2(n)) {
9322
+ if (isIdentifierNode(n)) {
9329
9323
  const v = (n.name ?? "").trim();
9330
9324
  if (isIdentifierish(v)) {
9331
9325
  results.push(v);
@@ -9991,20 +9985,29 @@ File: ${context.filename ?? "unknown"}:${loc.line}:${loc.column}`
9991
9985
  });
9992
9986
  };
9993
9987
  const { nativeWrappersValue, optionDataTestIdPrefixValue, semanticNameHint } = getNativeWrapperTransformInfo(element, componentName, resolvedNativeWrappers);
9994
- const handlerDirective = element.props.find((p) => {
9995
- return p.type === NodeTypes.DIRECTIVE && p.name === "bind" && p.arg?.type === NodeTypes.SIMPLE_EXPRESSION && p.arg.content === "handler" && !!p.exp;
9996
- }) ?? null;
9997
- const handlerInfo = handlerDirective ? nodeHandlerAttributeInfo(element) : null;
9998
- if (resolvedNativeWrappers[element.tag]?.role === "button" && handlerDirective && !handlerInfo) {
9988
+ const wrapperConfig = resolvedNativeWrappers[element.tag];
9989
+ const actionPropNames = resolveActionPropNames(wrapperConfig);
9990
+ const handlerDirective = findLoadActionDirective(element, actionPropNames);
9991
+ const handlerInfo = handlerDirective ? nodeHandlerAttributeInfo(element, actionPropNames) : null;
9992
+ if (wrapperConfig?.role === "button" && handlerDirective && !handlerInfo) {
9999
9993
  const loc = element.loc?.start;
10000
9994
  const locationHint = loc ? `${loc.line}:${loc.column}` : "unknown";
10001
9995
  const handlerSource = (handlerDirective.exp?.loc?.source ?? "").trim() || "<unknown>";
9996
+ const actionArgName = handlerDirective.arg.content;
10002
9997
  throw new Error(
10003
9998
  `[vue-pom-generator] Could not derive a semantic POM action name for button-like wrapper in ${componentName} (${context.filename ?? "unknown"}:${locationHint}).
10004
9999
  Element: <${element.tag}>
10005
10000
  Handler: ${handlerSource}
10006
10001
 
10007
- Fix: move complex inline logic into a named function (for example, const onAction = () => ...; then bind :handler="onAction"), or simplify the handler to a direct identifier/call the generator can name.`
10002
+ 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.`
10003
+ );
10004
+ }
10005
+ if (wrapperConfig?.actionProp && !handlerDirective && !nodeHasStaticClickDirective(element)) {
10006
+ const loc = element.loc?.start;
10007
+ const locationHint = loc ? `${loc.line}:${loc.column}` : "unknown";
10008
+ throw new Error(
10009
+ `[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.
10010
+ 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.`
10008
10011
  );
10009
10012
  }
10010
10013
  if (nativeWrappersValue) {
@@ -10165,7 +10168,7 @@ Fix: remove the explicit ${attrLabel}, or change existingIdBehavior to "overwrit
10165
10168
  if (!isRecognizedInteractiveRole) {
10166
10169
  return;
10167
10170
  }
10168
- const identifierHint = getStaticIdOrNameHint(element) || nodeHandlerAttributeValue(element) || innerText || existingElementDataTestId.value || conditionalHint || void 0;
10171
+ const identifierHint = getStaticIdOrNameHint(element) || nodeHandlerAttributeValue(element, actionPropNames) || innerText || existingElementDataTestId.value || conditionalHint || void 0;
10169
10172
  const preferredGeneratedValue = existingElementDataTestId.isDynamic ? templateAttributeValue(existingElementDataTestId.template) : staticAttributeValue(existingElementDataTestId.value);
10170
10173
  applyResolvedDataTestIdForElement({
10171
10174
  preferredGeneratedValue,