@immense/vue-pom-generator 1.0.85 → 1.0.87

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.cjs CHANGED
@@ -277,6 +277,7 @@ function resolveInjectionSupportOptions(options) {
277
277
  layoutDirs: isNuxt ? ["app/layouts"] : options.layoutDirs ?? ["src/layouts"],
278
278
  wrapperSearchRoots: isNuxt ? [] : options.wrapperSearchRoots ?? [],
279
279
  nativeWrappers: options.nativeWrappers ?? {},
280
+ optionKeyAttribute: options.optionKeyAttribute ?? {},
280
281
  excludedComponents: options.excludedComponents ?? [],
281
282
  existingIdBehavior: options.existingIdBehavior ?? "error",
282
283
  testIdAttribute: (options.testIdAttribute ?? "data-testid").trim() || "data-testid"
@@ -1327,12 +1328,13 @@ function findDirectiveByName(node, directiveName, argumentName) {
1327
1328
  return matchesDirective;
1328
1329
  });
1329
1330
  }
1331
+ const ACTION_EVENTS = /* @__PURE__ */ new Set(["click", "change", "mousedown"]);
1330
1332
  function isClickDirective(prop) {
1331
1333
  if (prop.type !== compilerCore.NodeTypes.DIRECTIVE) {
1332
1334
  return false;
1333
1335
  }
1334
1336
  const directive = prop;
1335
- return directive.name === "on" && directive.arg?.type === compilerCore.NodeTypes.SIMPLE_EXPRESSION && directive.arg.content === "click";
1337
+ return directive.name === "on" && directive.arg?.type === compilerCore.NodeTypes.SIMPLE_EXPRESSION && ACTION_EVENTS.has(directive.arg.content);
1336
1338
  }
1337
1339
  function tryGetClickDirective(node) {
1338
1340
  return node.props.find((p) => isClickDirective(p));
@@ -1734,6 +1736,17 @@ function getKeyDirectiveInfo(node) {
1734
1736
  const runtimeSource = getVueExpressionSource(keyExpression, "loc", "compiled");
1735
1737
  return toResolvedKeyInfo(selectorSource, runtimeSource);
1736
1738
  }
1739
+ function getBindingKeyInfo(node, attrName) {
1740
+ const directive = findDirectiveByName(node, "bind", attrName);
1741
+ const exp = directive?.exp;
1742
+ if (!exp || exp.type !== compilerCore.NodeTypes.SIMPLE_EXPRESSION && exp.type !== compilerCore.NodeTypes.COMPOUND_EXPRESSION) {
1743
+ return null;
1744
+ }
1745
+ const expression = exp;
1746
+ const selectorSource = getVueExpressionSource(expression, "compiled", "loc");
1747
+ const runtimeSource = getVueExpressionSource(expression, "loc", "compiled");
1748
+ return toResolvedKeyInfo(selectorSource, runtimeSource);
1749
+ }
1737
1750
  function getModelBindingValues(node) {
1738
1751
  let vModel = "";
1739
1752
  const vModelDirective = findDirectiveByName(node, "model");
@@ -1753,6 +1766,15 @@ function getModelBindingValues(node) {
1753
1766
  }
1754
1767
  return { vModel, modelValue };
1755
1768
  }
1769
+ function getBindingValueHint(node) {
1770
+ const directive = findDirectiveByName(node, "bind", "value");
1771
+ const exp = directive?.exp;
1772
+ if (!exp || exp.type !== compilerCore.NodeTypes.SIMPLE_EXPRESSION && exp.type !== compilerCore.NodeTypes.COMPOUND_EXPRESSION) {
1773
+ return null;
1774
+ }
1775
+ const source = getVueExpressionSource(exp, "loc", "content");
1776
+ return source || null;
1777
+ }
1756
1778
  function getStaticIdOrNameHint(node) {
1757
1779
  let idAttr = findAttributeByKey(node, "id");
1758
1780
  if (!idAttr) {
@@ -6875,10 +6897,10 @@ function getConstructor(childrenComponent, componentHierarchyMap, attachmentsFor
6875
6897
  statements: (writer) => {
6876
6898
  writer.writeLine(`super(page, { testIdAttribute: ${JSON.stringify(attr)} });`);
6877
6899
  for (const a of attachmentsForThisView) {
6878
- writer.writeLine(`this.${a.propertyName} = new ${a.className}(page, this);`);
6900
+ writer.writeLine(`this.${a.propertyName} = new ${a.className}(this.page, this);`);
6879
6901
  }
6880
6902
  for (const w of widgetInstances) {
6881
- writer.writeLine(`this.${w.propertyName} = new ${w.className}(page, ${JSON.stringify(w.testId)});`);
6903
+ writer.writeLine(`this.${w.propertyName} = new ${w.className}(this.page, ${JSON.stringify(w.testId)});`);
6882
6904
  }
6883
6905
  childrenComponent.forEach((child) => {
6884
6906
  if (componentHierarchyMap.has(child) && componentHierarchyMap.get(child)?.dataTestIdSet.size) {
@@ -7531,6 +7553,7 @@ function createTestIdTransform(componentName, componentHierarchyMap, nativeWrapp
7531
7553
  const wrapperSearchRoots = options.wrapperSearchRoots ?? [];
7532
7554
  const annotatorMetadata = options.annotatorMetadata ?? null;
7533
7555
  const crossFileKeyRegistry = options.crossFileKeyRegistry;
7556
+ const optionKeyAttribute = options.optionKeyAttribute ?? {};
7534
7557
  const safeRealpath2 = (p) => {
7535
7558
  try {
7536
7559
  return fs.existsSync(p) ? fs.realpathSync(p) : p;
@@ -7711,6 +7734,13 @@ Fix: set \`role\` explicitly in nativeWrappers (e.g. { "${element.tag}": { role:
7711
7734
  const getBestAvailableKeyInfo = () => {
7712
7735
  const parentNode = context.parent && typeof context.parent === "object" ? context.parent : null;
7713
7736
  const isDirectVForChild = parentNode?.type === compilerCore.NodeTypes.FOR;
7737
+ const configuredAttrName = optionKeyAttribute[componentName];
7738
+ if (configuredAttrName && configuredAttrName !== "key") {
7739
+ const bindingKeyInfo = getBindingKeyInfo(element, configuredAttrName);
7740
+ if (bindingKeyInfo) {
7741
+ return bindingKeyInfo;
7742
+ }
7743
+ }
7714
7744
  const vForKeyInfo = (isDirectVForChild ? getKeyDirectiveInfo(element) : null) || getContainedInVForDirectiveKeyInfo(context, element, hierarchyMap);
7715
7745
  if (vForKeyInfo) {
7716
7746
  return vForKeyInfo;
@@ -7918,7 +7948,8 @@ Fix: remove the explicit ${attrLabel}, or change existingIdBehavior to "overwrit
7918
7948
  const rawIdentifier = getStaticAttributeContent(element, "id") || getStaticAttributeContent(element, "name");
7919
7949
  const labelText = getAssociatedLabelText(element, hierarchyMap);
7920
7950
  const { vModel, modelValue } = getModelBindingValues(element);
7921
- const bindingHint = modelValue || vModel || null;
7951
+ const valueBindingHint = nativeHtmlRole === "radio" || nativeHtmlRole === "checkbox" ? getBindingValueHint(element) : null;
7952
+ const bindingHint = modelValue || vModel || valueBindingHint || null;
7922
7953
  const labelToken = labelText ? toPascalCase(labelText) : "";
7923
7954
  const bindingToken = bindingHint ? toPascalCase(bindingHint) : "";
7924
7955
  let identifierToken = null;
@@ -8089,6 +8120,7 @@ function createBuildProcessorPlugin(options) {
8089
8120
  generation,
8090
8121
  projectRootRef,
8091
8122
  nativeWrappers,
8123
+ optionKeyAttribute,
8092
8124
  excludedComponents,
8093
8125
  getWrapperSearchRoots,
8094
8126
  getResolvedRouterEntry,
@@ -8221,7 +8253,8 @@ function createBuildProcessorPlugin(options) {
8221
8253
  warn: (message) => loggerRef.current.warn(message),
8222
8254
  vueFilesPathMap,
8223
8255
  wrapperSearchRoots: getWrapperSearchRoots(),
8224
- crossFileKeyRegistry
8256
+ crossFileKeyRegistry,
8257
+ optionKeyAttribute
8225
8258
  }
8226
8259
  )
8227
8260
  ]
@@ -8340,6 +8373,7 @@ function createBuildProcessorPlugin(options) {
8340
8373
  function createDevProcessorPlugin(options) {
8341
8374
  const {
8342
8375
  nativeWrappers,
8376
+ optionKeyAttribute,
8343
8377
  excludedComponents,
8344
8378
  getPageDirs,
8345
8379
  getComponentDirs,
@@ -8573,7 +8607,8 @@ function createDevProcessorPlugin(options) {
8573
8607
  warn: (message) => loggerRef.current.warn(message),
8574
8608
  vueFilesPathMap: provisionalVuePathMap,
8575
8609
  wrapperSearchRoots: getWrapperSearchRoots(),
8576
- crossFileKeyRegistry: provisionalKeyRegistry
8610
+ crossFileKeyRegistry: provisionalKeyRegistry,
8611
+ optionKeyAttribute
8577
8612
  }
8578
8613
  )
8579
8614
  ]
@@ -9104,6 +9139,7 @@ function createInternalPlugins(options) {
9104
9139
  elementMetadata,
9105
9140
  vueFilesPathMap,
9106
9141
  nativeWrappers,
9142
+ optionKeyAttribute,
9107
9143
  excludedComponents,
9108
9144
  getPageDirs,
9109
9145
  getComponentDirs,
@@ -9154,6 +9190,7 @@ function createInternalPlugins(options) {
9154
9190
  generation,
9155
9191
  projectRootRef,
9156
9192
  nativeWrappers,
9193
+ optionKeyAttribute,
9157
9194
  excludedComponents,
9158
9195
  getWrapperSearchRoots,
9159
9196
  getResolvedRouterEntry: resolveRouterEntry2,
@@ -9161,6 +9198,7 @@ function createInternalPlugins(options) {
9161
9198
  });
9162
9199
  const devProcessor = createDevProcessorPlugin({
9163
9200
  nativeWrappers,
9201
+ optionKeyAttribute,
9164
9202
  excludedComponents,
9165
9203
  getPageDirs,
9166
9204
  getComponentDirs,
@@ -9365,6 +9403,7 @@ function createVuePluginWithTestIds(options) {
9365
9403
  nameCollisionBehavior,
9366
9404
  missingSemanticNameBehavior = "error",
9367
9405
  nativeWrappers,
9406
+ optionKeyAttribute,
9368
9407
  elementMetadata,
9369
9408
  semanticNameMap,
9370
9409
  componentHierarchyMap,
@@ -9439,7 +9478,8 @@ function createVuePluginWithTestIds(options) {
9439
9478
  vueFilesPathMap,
9440
9479
  wrapperSearchRoots: getWrapperSearchRoots(),
9441
9480
  annotatorMetadata,
9442
- crossFileKeyRegistry
9481
+ crossFileKeyRegistry,
9482
+ optionKeyAttribute
9443
9483
  }
9444
9484
  )
9445
9485
  );
@@ -9496,7 +9536,8 @@ function createVuePluginWithTestIds(options) {
9496
9536
  vueFilesPathMap,
9497
9537
  wrapperSearchRoots: getWrapperSearchRoots(),
9498
9538
  annotatorMetadata,
9499
- crossFileKeyRegistry
9539
+ crossFileKeyRegistry,
9540
+ optionKeyAttribute
9500
9541
  }
9501
9542
  );
9502
9543
  perFileTransform.set(componentName, transform);
@@ -9833,6 +9874,7 @@ function createVuePomGeneratorPlugins(options = {}) {
9833
9874
  layoutDirs: injection.layoutDirs,
9834
9875
  wrapperSearchRoots: injection.wrapperSearchRoots,
9835
9876
  nativeWrappers: injection.nativeWrappers,
9877
+ optionKeyAttribute: injection.optionKeyAttribute,
9836
9878
  excludedComponents: injection.excludeComponents,
9837
9879
  existingIdBehavior: injection.existingIdBehavior,
9838
9880
  testIdAttribute: injection.attribute
@@ -9840,6 +9882,7 @@ function createVuePomGeneratorPlugins(options = {}) {
9840
9882
  };
9841
9883
  const resolvedInjectionOptions = resolvedInjectionOptionsRef.current;
9842
9884
  const nativeWrappers = resolvedInjectionOptions.nativeWrappers;
9885
+ const optionKeyAttribute = resolvedInjectionOptions.optionKeyAttribute;
9843
9886
  const excludedComponents = resolvedInjectionOptions.excludedComponents;
9844
9887
  const testIdAttribute = resolvedInjectionOptions.testIdAttribute;
9845
9888
  const routerEntry = !isNuxt ? vueGenerationOptions?.router?.entry : void 0;
@@ -9962,6 +10005,7 @@ function createVuePomGeneratorPlugins(options = {}) {
9962
10005
  nameCollisionBehavior: resolvedGenerationOptions.nameCollisionBehavior,
9963
10006
  missingSemanticNameBehavior: resolvedGenerationOptions.missingSemanticNameBehavior,
9964
10007
  nativeWrappers,
10008
+ optionKeyAttribute,
9965
10009
  elementMetadata,
9966
10010
  semanticNameMap,
9967
10011
  componentHierarchyMap,
@@ -9987,6 +10031,7 @@ function createVuePomGeneratorPlugins(options = {}) {
9987
10031
  elementMetadata,
9988
10032
  vueFilesPathMap,
9989
10033
  nativeWrappers,
10034
+ optionKeyAttribute,
9990
10035
  excludedComponents,
9991
10036
  getPageDirs,
9992
10037
  getComponentDirs,