@immense/vue-pom-generator 1.0.82 → 1.0.84

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.
Files changed (56) hide show
  1. package/RELEASE_NOTES.md +54 -54
  2. package/class-generation/playwright-types.ts +120 -2
  3. package/dist/class-generation/playwright-types.d.ts +256 -2
  4. package/dist/class-generation/playwright-types.d.ts.map +1 -1
  5. package/dist/compiler-metadata-utils.d.ts.map +1 -1
  6. package/dist/eslint.config.d.ts.map +1 -1
  7. package/dist/index.cjs +37 -41
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.mjs +37 -41
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/plugin/runtime/annotator/client.d.ts +13 -0
  12. package/dist/plugin/runtime/annotator/client.d.ts.map +1 -1
  13. package/dist/plugin/runtime/annotator/format.d.ts.map +1 -1
  14. package/dist/plugin/runtime/annotator/plugin.d.ts +16 -0
  15. package/dist/plugin/runtime/annotator/plugin.d.ts.map +1 -1
  16. package/dist/plugin/runtime/annotator/text-utils.d.ts +15 -0
  17. package/dist/plugin/runtime/annotator/text-utils.d.ts.map +1 -0
  18. package/dist/plugin/runtime/annotator/vue-detector.d.ts +49 -0
  19. package/dist/plugin/runtime/annotator/vue-detector.d.ts.map +1 -1
  20. package/dist/pom-discoverability.d.ts.map +1 -1
  21. package/dist/pom-patterns.d.ts +28 -4
  22. package/dist/pom-patterns.d.ts.map +1 -1
  23. package/dist/tests/annotator-runtime-helpers.test.d.ts +2 -0
  24. package/dist/tests/annotator-runtime-helpers.test.d.ts.map +1 -0
  25. package/dist/tests/broad/accessibility-audit-ts.test.d.ts +2 -0
  26. package/dist/tests/broad/accessibility-audit-ts.test.d.ts.map +1 -0
  27. package/dist/tests/broad/class-generation-base-page-ts.test.d.ts +2 -0
  28. package/dist/tests/broad/class-generation-base-page-ts.test.d.ts.map +1 -0
  29. package/dist/tests/broad/compiler-metadata-utils-ts.test.d.ts +2 -0
  30. package/dist/tests/broad/compiler-metadata-utils-ts.test.d.ts.map +1 -0
  31. package/dist/tests/broad/helpers/fake-runtime.d.ts +162 -0
  32. package/dist/tests/broad/helpers/fake-runtime.d.ts.map +1 -0
  33. package/dist/tests/broad/manifest-generator-ts.test.d.ts +2 -0
  34. package/dist/tests/broad/manifest-generator-ts.test.d.ts.map +1 -0
  35. package/dist/tests/broad/metadata-collector-ts.test.d.ts +2 -0
  36. package/dist/tests/broad/metadata-collector-ts.test.d.ts.map +1 -0
  37. package/dist/tests/broad/plugin-logger-ts.test.d.ts +2 -0
  38. package/dist/tests/broad/plugin-logger-ts.test.d.ts.map +1 -0
  39. package/dist/tests/broad/plugin-resolved-generation-options-ts.test.d.ts +2 -0
  40. package/dist/tests/broad/plugin-resolved-generation-options-ts.test.d.ts.map +1 -0
  41. package/dist/tests/broad/plugin-runtime-annotator-format-ts.test.d.ts +2 -0
  42. package/dist/tests/broad/plugin-runtime-annotator-format-ts.test.d.ts.map +1 -0
  43. package/dist/tests/broad/typescript-codegen-ts.test.d.ts +2 -0
  44. package/dist/tests/broad/typescript-codegen-ts.test.d.ts.map +1 -0
  45. package/dist/tests/helpers/typed-mocks.d.ts +58 -0
  46. package/dist/tests/helpers/typed-mocks.d.ts.map +1 -0
  47. package/dist/transform.d.ts +36 -5
  48. package/dist/transform.d.ts.map +1 -1
  49. package/dist/utils.d.ts +261 -2
  50. package/dist/utils.d.ts.map +1 -1
  51. package/package.json +1 -1
  52. package/plugin/runtime/annotator/client.ts +24 -12
  53. package/plugin/runtime/annotator/format.ts +5 -7
  54. package/plugin/runtime/annotator/plugin.ts +24 -6
  55. package/plugin/runtime/annotator/text-utils.ts +23 -0
  56. package/plugin/runtime/annotator/vue-detector.ts +56 -0
package/dist/index.cjs CHANGED
@@ -472,25 +472,11 @@ function pomMethodSignatureEquals(left, right) {
472
472
  function isParameterizedPomPattern(kind) {
473
473
  return kind === "parameterized";
474
474
  }
475
- function getTemplateVariables(formatted) {
476
- const out = [];
477
- const seen = /* @__PURE__ */ new Set();
478
- const matches = formatted.matchAll(/\$\{(\w+)\}/g);
479
- for (const match of matches) {
480
- const variableName = match[1];
481
- if (seen.has(variableName)) {
482
- continue;
483
- }
484
- seen.add(variableName);
485
- out.push(variableName);
486
- }
487
- return out;
488
- }
489
- function createPomStringPattern(formatted, patternKind) {
475
+ function createPomStringPattern(formatted, patternKind, templateVariables) {
490
476
  return {
491
477
  formatted,
492
478
  patternKind,
493
- templateVariables: getTemplateVariables(formatted)
479
+ templateVariables: [...templateVariables]
494
480
  };
495
481
  }
496
482
  function getPomPatternVariables(patterns, options = {}) {
@@ -602,14 +588,14 @@ function uniquePomStringPatterns(primary, alternates) {
602
588
  }
603
589
  return out;
604
590
  }
605
- function splitDiscoverabilityWords(value) {
591
+ function splitWords(value) {
606
592
  const normalized = value.replace(/ByKey/g, "").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/[._-]+/g, " ").trim();
607
593
  if (!normalized) {
608
594
  return [];
609
595
  }
610
596
  return normalized.split(/\s+/).map((word) => word.toLowerCase()).filter(Boolean);
611
597
  }
612
- function joinDiscoverabilityWords(words) {
598
+ function joinWords(words) {
613
599
  return words.join(" ").replace(/\s+/g, " ").trim();
614
600
  }
615
601
  function toSentenceCase(value) {
@@ -641,7 +627,7 @@ function removeTrailingRoleWord(words, roleWord) {
641
627
  return words.slice(0, -1);
642
628
  }
643
629
  function humanizePomMethodName(methodName) {
644
- return joinDiscoverabilityWords(splitDiscoverabilityWords(methodName));
630
+ return joinWords(splitWords(methodName));
645
631
  }
646
632
  function stripPomActionPrefix(actionName) {
647
633
  for (const prefix of ["click", "select", "type", "goTo"]) {
@@ -658,13 +644,13 @@ function normalizePomRoleLabel(nativeRole) {
658
644
  return nativeRole || "element";
659
645
  }
660
646
  function buildPomLocatorDescription(args) {
661
- const componentWords = splitDiscoverabilityWords(args.componentName ? stripComponentKindSuffix(args.componentName) : "");
647
+ const componentWords = splitWords(args.componentName ? stripComponentKindSuffix(args.componentName) : "");
662
648
  const roleWord = normalizePomRoleLabel(args.nativeRole).toLowerCase();
663
649
  const semanticWords = removeLeadingWords(
664
- removeTrailingRoleWord(splitDiscoverabilityWords(args.methodName), roleWord),
650
+ removeTrailingRoleWord(splitWords(args.methodName), roleWord),
665
651
  componentWords
666
652
  );
667
- const phrase = joinDiscoverabilityWords([
653
+ const phrase = joinWords([
668
654
  ...componentWords,
669
655
  ...semanticWords,
670
656
  roleWord
@@ -1216,6 +1202,9 @@ function upperFirst(value) {
1216
1202
  }
1217
1203
  return value.charAt(0).toUpperCase() + value.slice(1);
1218
1204
  }
1205
+ function collapseWhitespace(value) {
1206
+ return value.replace(/\s+/g, " ").trim();
1207
+ }
1219
1208
  function isAsciiUppercaseLetterCode(code) {
1220
1209
  return code >= 65 && code <= 90;
1221
1210
  }
@@ -2890,13 +2879,15 @@ function safeMethodNameFromParts(parts) {
2890
2879
  function toPomKeyPattern(templateValue) {
2891
2880
  const { templateLiteral } = templateValue.parsedTemplate;
2892
2881
  let out = "";
2882
+ let hasExpression = false;
2893
2883
  for (let i = 0; i < templateLiteral.quasis.length; i += 1) {
2894
2884
  out += templateLiteral.quasis[i]?.value.raw ?? "";
2895
2885
  if (templateLiteral.expressions[i]) {
2896
2886
  out += "${key}";
2887
+ hasExpression = true;
2897
2888
  }
2898
2889
  }
2899
- return out;
2890
+ return { formatted: out, templateVariables: hasExpression ? ["key"] : [] };
2900
2891
  }
2901
2892
  function applyResolvedDataTestId(args) {
2902
2893
  const addHtmlAttribute = args.addHtmlAttribute ?? true;
@@ -3020,9 +3011,11 @@ Fix: either (1) include ${bestKeyPreservePlaceholder} in your :${attrLabel} temp
3020
3011
  };
3021
3012
  const normalizedRole = normalizeNativeRole(args.nativeRole) ?? "button";
3022
3013
  const targetPageObjectModelClass = entryOverrides.targetPageObjectModelClass;
3023
- const formattedDataTestIdForPom = dataTestId.kind === "template" ? toPomKeyPattern(dataTestId) : dataTestId.value;
3014
+ const pomKeyPattern = dataTestId.kind === "template" ? toPomKeyPattern(dataTestId) : null;
3015
+ const formattedDataTestIdForPom = dataTestId.kind === "template" ? pomKeyPattern.formatted : dataTestId.value;
3024
3016
  const selectorPatternKind = dataTestId.kind === "template" ? "parameterized" : "static";
3025
- const selectorPattern = createPomStringPattern(formattedDataTestIdForPom, selectorPatternKind);
3017
+ const selectorTemplateVariables = dataTestId.kind === "template" ? pomKeyPattern.templateVariables : [];
3018
+ const selectorPattern = createPomStringPattern(formattedDataTestIdForPom, selectorPatternKind, selectorTemplateVariables);
3026
3019
  const selectorIsParameterized = selectorPatternKind === "parameterized";
3027
3020
  const deriveBaseMethodNameFromHint = (hint) => {
3028
3021
  const hintRaw = (hint ?? "").trim();
@@ -3300,7 +3293,8 @@ Fix: make the element identifiable (e.g. add id/name/inner text or use a more sp
3300
3293
  const dataTestIdEntry = {
3301
3294
  selectorValue: entryOverrides.selectorValue ?? createPomStringPattern(
3302
3295
  getAttributeValueText(dataTestId),
3303
- dataTestId.kind === "template" ? "parameterized" : "static"
3296
+ dataTestId.kind === "template" ? "parameterized" : "static",
3297
+ selectorTemplateVariables
3304
3298
  ),
3305
3299
  templateLiteral: entryOverrides.templateLiteral,
3306
3300
  targetPageObjectModelClass: entryOverrides.targetPageObjectModelClass
@@ -3527,8 +3521,8 @@ Fix: make the element identifiable (e.g. add id/name/inner text or use a more sp
3527
3521
  name: generatedName2,
3528
3522
  selector: {
3529
3523
  kind: "withinTestIdByLabel",
3530
- rootTestId: createPomStringPattern(wrapperTestId, selectorPatternKind),
3531
- label: createPomStringPattern(label, "static"),
3524
+ rootTestId: createPomStringPattern(wrapperTestId, selectorPatternKind, selectorTemplateVariables),
3525
+ label: createPomStringPattern(label, "static", []),
3532
3526
  exact: true
3533
3527
  },
3534
3528
  parameters: [createPomParameterSpec("annotationText", `string = ""`)]
@@ -3549,8 +3543,8 @@ Fix: make the element identifiable (e.g. add id/name/inner text or use a more sp
3549
3543
  name: generatedName,
3550
3544
  selector: {
3551
3545
  kind: "withinTestIdByLabel",
3552
- rootTestId: createPomStringPattern(wrapperTestId, selectorPatternKind),
3553
- label: createPomStringPattern("${value}", "parameterized"),
3546
+ rootTestId: createPomStringPattern(wrapperTestId, selectorPatternKind, selectorTemplateVariables),
3547
+ label: createPomStringPattern("${value}", "parameterized", ["value"]),
3554
3548
  exact: true
3555
3549
  },
3556
3550
  parameters: [
@@ -8907,8 +8901,11 @@ const DEFAULT_ENTRY_SUFFIXES = [
8907
8901
  "/src/main.tsx",
8908
8902
  "/src/main.jsx"
8909
8903
  ];
8904
+ function normalizePathSeparators(filePath) {
8905
+ return filePath.replace(/\\/g, "/");
8906
+ }
8910
8907
  function toFsImportPath(filePath) {
8911
- return `/@fs/${filePath.replace(/\\/g, "/")}`;
8908
+ return `/@fs/${normalizePathSeparators(filePath)}`;
8912
8909
  }
8913
8910
  function resolveAnnotatorClientPath() {
8914
8911
  const candidates = [
@@ -8953,7 +8950,7 @@ function createAnnotatorUiPlugin(options) {
8953
8950
  if (!options.enabled) {
8954
8951
  return null;
8955
8952
  }
8956
- const normalizedId = id.replace(/\\/g, "/");
8953
+ const normalizedId = normalizePathSeparators(id);
8957
8954
  if (!DEFAULT_ENTRY_SUFFIXES.some((suffix) => normalizedId.endsWith(suffix))) {
8958
8955
  return null;
8959
8956
  }
@@ -9132,7 +9129,7 @@ function collectStaticTextContent(children) {
9132
9129
  const visit = (nodes) => {
9133
9130
  for (const node of nodes) {
9134
9131
  if (node.type === compilerCore.NodeTypes.TEXT) {
9135
- const text2 = node.content.replace(/\s+/g, " ").trim();
9132
+ const text2 = collapseWhitespace(node.content);
9136
9133
  if (text2) {
9137
9134
  parts.push(text2);
9138
9135
  }
@@ -9144,7 +9141,7 @@ function collectStaticTextContent(children) {
9144
9141
  }
9145
9142
  };
9146
9143
  visit(children);
9147
- const text = parts.join(" ").replace(/\s+/g, " ").trim();
9144
+ const text = collapseWhitespace(parts.join(" "));
9148
9145
  return text || void 0;
9149
9146
  }
9150
9147
  function tryCreateElementMetadata(args) {
@@ -10499,10 +10496,6 @@ const SHORTCUT_LABELS = {
10499
10496
  settings: ",",
10500
10497
  cancel: "Esc"
10501
10498
  };
10502
- function normalizeText(value) {
10503
- const normalized = value?.replace(/\s+/g, " ").trim();
10504
- return normalized || void 0;
10505
- }
10506
10499
  function formatShortcutTitle(label, shortcut) {
10507
10500
  return shortcut ? `${label} (${shortcut})` : label;
10508
10501
  }
@@ -10543,11 +10536,11 @@ function getElementPath(element) {
10543
10536
  return segments.join(" > ");
10544
10537
  }
10545
10538
  function getNearbyText(element) {
10546
- const ownText = normalizeText(element.textContent || void 0);
10539
+ const ownText = normalizeInlineText(element.textContent || void 0);
10547
10540
  if (ownText && ownText.length >= 2) {
10548
10541
  return ownText.length > 160 ? `${ownText.slice(0, 160)}...` : ownText;
10549
10542
  }
10550
- const parentText = normalizeText(element.parentElement?.textContent || void 0);
10543
+ const parentText = normalizeInlineText(element.parentElement?.textContent || void 0);
10551
10544
  if (parentText) {
10552
10545
  return parentText.length > 160 ? `${parentText.slice(0, 160)}...` : parentText;
10553
10546
  }
@@ -10570,6 +10563,9 @@ function createFloatingArrow() {
10570
10563
  function toCssPixels(value) {
10571
10564
  return `${Math.round(value)}px`;
10572
10565
  }
10566
+ function placementPrimarySide(placement) {
10567
+ return placement.split("-")[0];
10568
+ }
10573
10569
  function clamp(value, min, max) {
10574
10570
  return Math.min(Math.max(value, min), max);
10575
10571
  }
@@ -11058,7 +11054,7 @@ class AnnotatorRuntime {
11058
11054
  panel.style.top = toCssPixels(result.y);
11059
11055
  panel.style.visibility = "visible";
11060
11056
  const arrowData = result.middlewareData.arrow;
11061
- const side = result.placement.split("-")[0];
11057
+ const side = placementPrimarySide(result.placement);
11062
11058
  const staticSide = side === "top" ? "bottom" : side === "bottom" ? "top" : side === "left" ? "right" : "left";
11063
11059
  arrowEl.style.removeProperty("top");
11064
11060
  arrowEl.style.removeProperty("right");