@immense/vue-pom-generator 1.0.64 → 1.0.66

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
@@ -1854,6 +1854,12 @@ function nodeHandlerAttributeInfo(node) {
1854
1854
  const n = node2;
1855
1855
  return typeof n.computed === "boolean" && typeof n.key === "object" && n.key !== null && typeof n.value === "object" && n.value !== null;
1856
1856
  };
1857
+ const isLogicalExpressionNode = (node2) => {
1858
+ if (!isNodeType2(node2, "LogicalExpression"))
1859
+ return false;
1860
+ const n = node2;
1861
+ return typeof n.operator === "string" && typeof n.left === "object" && n.left !== null && typeof n.right === "object" && n.right !== null;
1862
+ };
1857
1863
  const getLastIdentifierFromMemberChain = (node2) => {
1858
1864
  if (!node2)
1859
1865
  return null;
@@ -2024,48 +2030,66 @@ function nodeHandlerAttributeInfo(node) {
2024
2030
  const semanticNameHint2 = suffix ? `${toPascalCase(name)}${suffix}` : toPascalCase(name);
2025
2031
  return semanticNameHint2;
2026
2032
  };
2033
+ const unwrapSemanticHelperCall = (candidateExpr) => {
2034
+ if (!isCallExpressionNode(candidateExpr)) {
2035
+ return null;
2036
+ }
2037
+ const calleeName = getLastIdentifierFromMemberChain(candidateExpr.callee);
2038
+ if (calleeName !== "_unref" && calleeName !== "unref" && calleeName !== "_withModifiers" && calleeName !== "withModifiers") {
2039
+ return null;
2040
+ }
2041
+ const firstArg = candidateExpr.arguments[0];
2042
+ return typeof firstArg === "object" && firstArg !== null ? firstArg : null;
2043
+ };
2027
2044
  const resolveSemanticName = (candidateExpr) => {
2028
2045
  if (!candidateExpr) {
2029
2046
  return null;
2030
2047
  }
2048
+ const unwrappedHelperCandidate = unwrapSemanticHelperCall(candidateExpr);
2049
+ if (unwrappedHelperCandidate) {
2050
+ return resolveSemanticName(unwrappedHelperCandidate);
2051
+ }
2031
2052
  const direct = getLastIdentifierFromMemberChain(candidateExpr);
2032
2053
  if (direct) {
2033
2054
  return toPascalCase(direct);
2034
2055
  }
2056
+ const directCall = tryFromCallExpression(candidateExpr);
2057
+ if (directCall) {
2058
+ return directCall;
2059
+ }
2060
+ if (isAssignmentExpressionNode(candidateExpr)) {
2061
+ const lhs = getAssignmentTargetName(candidateExpr.left);
2062
+ if (lhs) {
2063
+ const rhs = stableWordFromValue(candidateExpr.right);
2064
+ return `Set${toPascalCase(lhs)}${rhs ?? ""}`;
2065
+ }
2066
+ }
2067
+ if (isLogicalExpressionNode(candidateExpr) && candidateExpr.operator === "&&") {
2068
+ return resolveSemanticName(candidateExpr.right);
2069
+ }
2035
2070
  if (isArrowFunctionExpressionNode(candidateExpr)) {
2036
2071
  const body = candidateExpr.body;
2037
- const directCall = tryFromCallExpression(body);
2038
- if (directCall) {
2039
- return directCall;
2040
- }
2041
- if (isAssignmentExpressionNode(body)) {
2042
- const lhs = getAssignmentTargetName(body.left);
2043
- if (lhs) {
2044
- const rhs = stableWordFromValue(body.right);
2045
- return `Set${toPascalCase(lhs)}${rhs ?? ""}`;
2046
- }
2047
- }
2048
2072
  if (isBlockStatementNode(body)) {
2049
2073
  const stmts = body.body ?? [];
2050
2074
  if (stmts.length > 0) {
2051
2075
  const firstStmt = stmts[0];
2052
2076
  if (isReturnStatementNode(firstStmt)) {
2053
- const fromReturn = tryFromCallExpression(firstStmt.argument ?? null);
2077
+ const fromReturn = resolveSemanticName(firstStmt.argument ?? null);
2054
2078
  if (fromReturn) {
2055
2079
  return fromReturn;
2056
2080
  }
2057
2081
  }
2058
2082
  if (isExpressionStatementNode(firstStmt)) {
2059
- const fromExpr = tryFromCallExpression(firstStmt.expression ?? null);
2083
+ const fromExpr = resolveSemanticName(firstStmt.expression ?? null);
2060
2084
  if (fromExpr) {
2061
2085
  return fromExpr;
2062
2086
  }
2063
2087
  }
2064
2088
  }
2065
2089
  }
2066
- const bodyName = getLastIdentifierFromMemberChain(body);
2090
+ const bodyName = resolveSemanticName(body);
2067
2091
  if (bodyName) {
2068
- return toPascalCase(bodyName);
2092
+ return bodyName;
2069
2093
  }
2070
2094
  }
2071
2095
  return null;
@@ -5536,9 +5560,9 @@ function prepareViewObjectModelClass(componentName, dependencies, componentHiera
5536
5560
  members.push(...getComponentInstances(componentRefsForInstances, componentHierarchyMap, attachmentsForThisClass, widgetInstances));
5537
5561
  members.push(getConstructor(componentRefsForInstances, componentHierarchyMap, attachmentsForThisClass, widgetInstances, { testIdAttribute }));
5538
5562
  }
5539
- if (!isView && attachmentsForThisClass.length > 0) {
5540
- members.push(...getComponentInstances(/* @__PURE__ */ new Set(), componentHierarchyMap, attachmentsForThisClass));
5541
- members.push(getConstructor(/* @__PURE__ */ new Set(), componentHierarchyMap, attachmentsForThisClass, [], { testIdAttribute }));
5563
+ if (!isView && (componentRefsForInstances.size > 0 || attachmentsForThisClass.length > 0)) {
5564
+ members.push(...getComponentInstances(componentRefsForInstances, componentHierarchyMap, attachmentsForThisClass));
5565
+ members.push(getConstructor(componentRefsForInstances, componentHierarchyMap, attachmentsForThisClass, [], { testIdAttribute }));
5542
5566
  }
5543
5567
  members.push(
5544
5568
  ...getAttachmentPassthroughMethods(componentName, dependencies, attachmentsForThisClass, reservedAttachmentPassthroughNames)
@@ -5582,7 +5606,7 @@ function generateViewObjectModelContent(componentName, dependencies, componentHi
5582
5606
  const basePageImport = path.relative(fromAbs, toAbs).replace(/\\/g, "/");
5583
5607
  const basePageImportNoExt = stripExtension(basePageImport).replace(/\\/g, "/");
5584
5608
  const basePageImportSpecifier = basePageImportNoExt.startsWith(".") ? basePageImportNoExt : `./${basePageImportNoExt}`;
5585
- const needsPlaywrightPageImport = prepared.isView || prepared.attachmentsForThisClass.length > 0;
5609
+ const needsPlaywrightPageImport = prepared.isView || prepared.attachmentsForThisClass.length > 0 || prepared.componentRefsForInstances.size > 0 || prepared.widgetInstances.length > 0;
5586
5610
  const customPomImportSpecifiersByClass = options.customPomImportSpecifiersByClass ?? {};
5587
5611
  const customImports = Array.from(
5588
5612
  /* @__PURE__ */ new Set([