@immense/vue-pom-generator 1.0.81 → 1.0.83
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 +4 -3
- package/RELEASE_NOTES.md +34 -24
- package/class-generation/base-page.ts +1 -2
- package/dist/class-generation/base-page.d.ts.map +1 -1
- package/dist/compiler-metadata-utils.d.ts.map +1 -1
- package/dist/index.cjs +70 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +70 -41
- package/dist/index.mjs.map +1 -1
- package/dist/plugin/internal-plugins.d.ts.map +1 -1
- package/dist/plugin/runtime/annotator/client.d.ts +13 -0
- package/dist/plugin/runtime/annotator/client.d.ts.map +1 -1
- package/dist/plugin/runtime/annotator/format.d.ts.map +1 -1
- package/dist/plugin/runtime/annotator/plugin.d.ts +16 -0
- package/dist/plugin/runtime/annotator/plugin.d.ts.map +1 -1
- package/dist/plugin/runtime/annotator/text-utils.d.ts +15 -0
- package/dist/plugin/runtime/annotator/text-utils.d.ts.map +1 -0
- package/dist/plugin/runtime/annotator/vue-detector.d.ts +49 -0
- package/dist/plugin/runtime/annotator/vue-detector.d.ts.map +1 -1
- package/dist/pom-discoverability.d.ts.map +1 -1
- package/dist/pom-patterns.d.ts.map +1 -1
- package/dist/transform.d.ts.map +1 -1
- package/dist/utils.d.ts +2 -2
- package/dist/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/plugin/runtime/annotator/client.ts +24 -8
- package/plugin/runtime/annotator/format.ts +7 -5
- package/plugin/runtime/annotator/plugin.ts +24 -2
- package/plugin/runtime/annotator/text-utils.ts +23 -0
- package/plugin/runtime/annotator/vue-detector.ts +70 -0
package/dist/index.mjs
CHANGED
|
@@ -561,14 +561,14 @@ function uniquePomStringPatterns(primary, alternates) {
|
|
|
561
561
|
}
|
|
562
562
|
return out;
|
|
563
563
|
}
|
|
564
|
-
function
|
|
564
|
+
function splitWords(value) {
|
|
565
565
|
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();
|
|
566
566
|
if (!normalized) {
|
|
567
567
|
return [];
|
|
568
568
|
}
|
|
569
569
|
return normalized.split(/\s+/).map((word) => word.toLowerCase()).filter(Boolean);
|
|
570
570
|
}
|
|
571
|
-
function
|
|
571
|
+
function joinWords(words) {
|
|
572
572
|
return words.join(" ").replace(/\s+/g, " ").trim();
|
|
573
573
|
}
|
|
574
574
|
function toSentenceCase(value) {
|
|
@@ -600,7 +600,7 @@ function removeTrailingRoleWord(words, roleWord) {
|
|
|
600
600
|
return words.slice(0, -1);
|
|
601
601
|
}
|
|
602
602
|
function humanizePomMethodName(methodName) {
|
|
603
|
-
return
|
|
603
|
+
return joinWords(splitWords(methodName));
|
|
604
604
|
}
|
|
605
605
|
function stripPomActionPrefix(actionName) {
|
|
606
606
|
for (const prefix of ["click", "select", "type", "goTo"]) {
|
|
@@ -617,13 +617,13 @@ function normalizePomRoleLabel(nativeRole) {
|
|
|
617
617
|
return nativeRole || "element";
|
|
618
618
|
}
|
|
619
619
|
function buildPomLocatorDescription(args) {
|
|
620
|
-
const componentWords =
|
|
620
|
+
const componentWords = splitWords(args.componentName ? stripComponentKindSuffix(args.componentName) : "");
|
|
621
621
|
const roleWord = normalizePomRoleLabel(args.nativeRole).toLowerCase();
|
|
622
622
|
const semanticWords = removeLeadingWords(
|
|
623
|
-
removeTrailingRoleWord(
|
|
623
|
+
removeTrailingRoleWord(splitWords(args.methodName), roleWord),
|
|
624
624
|
componentWords
|
|
625
625
|
);
|
|
626
|
-
const phrase =
|
|
626
|
+
const phrase = joinWords([
|
|
627
627
|
...componentWords,
|
|
628
628
|
...semanticWords,
|
|
629
629
|
roleWord
|
|
@@ -2206,6 +2206,11 @@ function getNativeWrapperTransformInfo(node, componentName, nativeWrappers) {
|
|
|
2206
2206
|
return { nativeWrappersValue: null, optionDataTestIdPrefixValue: null, semanticNameHint: null };
|
|
2207
2207
|
}
|
|
2208
2208
|
const { role, valueAttribute, requiresOptionDataTestIdPrefix, inferred } = wrapperConfig;
|
|
2209
|
+
if (!role) {
|
|
2210
|
+
throw new Error(
|
|
2211
|
+
`[vue-pom-generator] Native wrapper <${node.tag}> has no resolved role in getNativeWrapperTransformInfo. The transform infers or declares a role before reaching this point; if calling this helper directly, pass a config with \`role\` set.`
|
|
2212
|
+
);
|
|
2213
|
+
}
|
|
2209
2214
|
if (nodeHasClickDirective(node) && role === "button") {
|
|
2210
2215
|
return { nativeWrappersValue: null, optionDataTestIdPrefixValue: null, semanticNameHint: null };
|
|
2211
2216
|
}
|
|
@@ -2294,7 +2299,13 @@ function generateToDirectiveDataTestId(componentName, node, toDirective, context
|
|
|
2294
2299
|
}
|
|
2295
2300
|
function formatTagName(node, nativeWrappers) {
|
|
2296
2301
|
if (Object.keys(nativeWrappers).includes(node.tag)) {
|
|
2297
|
-
|
|
2302
|
+
const role = nativeWrappers[node.tag].role;
|
|
2303
|
+
if (!role) {
|
|
2304
|
+
throw new Error(
|
|
2305
|
+
`[vue-pom-generator] Native wrapper <${node.tag}> has no resolved role in formatTagName. The transform infers or declares a role before reaching this point; if calling this helper directly, pass a config with \`role\` set.`
|
|
2306
|
+
);
|
|
2307
|
+
}
|
|
2308
|
+
return `-${role}`;
|
|
2298
2309
|
}
|
|
2299
2310
|
const nodeName = node.tag.replace(/-/g, "").toLowerCase();
|
|
2300
2311
|
return `-${nodeName}`;
|
|
@@ -2898,7 +2909,7 @@ Fix: reduce the template to a single key-based interpolation, or remove the expl
|
|
|
2898
2909
|
);
|
|
2899
2910
|
}
|
|
2900
2911
|
const hasExact = requiredKeyTemplateValue ? templateFragmentContainsSingleExpression(existingTemplateValue.parsedTemplate, requiredKeyTemplateValue.parsedTemplate) : false;
|
|
2901
|
-
const hasVarAccess = getBestKeyAccessCandidates(bestKeyVariable).
|
|
2912
|
+
const hasVarAccess = getBestKeyAccessCandidates(bestKeyVariable).includes(existingTemplateFragment.expressionSource);
|
|
2902
2913
|
if (!hasExact && !hasVarAccess && bestKeyPreservePlaceholder) {
|
|
2903
2914
|
throw new Error(
|
|
2904
2915
|
`[vue-pom-generator] Existing ${attrLabel} appears to be missing the key placeholder needed to keep it unique.
|
|
@@ -2960,6 +2971,7 @@ Fix: either (1) include ${bestKeyPreservePlaceholder} in your :${attrLabel} temp
|
|
|
2960
2971
|
case "toggle":
|
|
2961
2972
|
case "radio":
|
|
2962
2973
|
case "grid":
|
|
2974
|
+
case "link":
|
|
2963
2975
|
return role;
|
|
2964
2976
|
default:
|
|
2965
2977
|
return void 0;
|
|
@@ -3581,7 +3593,8 @@ const STANDALONE_WRAPPER_FALLBACK_ROLES = /* @__PURE__ */ new Set([
|
|
|
3581
3593
|
"vselect",
|
|
3582
3594
|
"checkbox",
|
|
3583
3595
|
"toggle",
|
|
3584
|
-
"radio"
|
|
3596
|
+
"radio",
|
|
3597
|
+
"link"
|
|
3585
3598
|
]);
|
|
3586
3599
|
function stripTrailingAsciiDigits(value) {
|
|
3587
3600
|
let end = value.length;
|
|
@@ -7127,6 +7140,18 @@ ${buildSearchRootsKey(normalizedSearchRoots)}`;
|
|
|
7127
7140
|
});
|
|
7128
7141
|
return (typeAttr?.value?.content ?? "").toLowerCase();
|
|
7129
7142
|
};
|
|
7143
|
+
const hasHrefAttribute = (element) => {
|
|
7144
|
+
return element.props.some((prop) => {
|
|
7145
|
+
if (prop.type === NodeTypes.ATTRIBUTE) {
|
|
7146
|
+
return prop.name === "href";
|
|
7147
|
+
}
|
|
7148
|
+
if (prop.type === NodeTypes.DIRECTIVE) {
|
|
7149
|
+
const directive = prop;
|
|
7150
|
+
return directive.name === "bind" && directive.arg?.type === NodeTypes.SIMPLE_EXPRESSION && directive.arg.content === "href";
|
|
7151
|
+
}
|
|
7152
|
+
return false;
|
|
7153
|
+
});
|
|
7154
|
+
};
|
|
7130
7155
|
let inferRoleFromNode;
|
|
7131
7156
|
const inferRoleFromElement = (element) => {
|
|
7132
7157
|
const elementTag = (element.tag || "").toLowerCase();
|
|
@@ -7146,6 +7171,10 @@ ${buildSearchRootsKey(normalizedSearchRoots)}`;
|
|
|
7146
7171
|
return { role: "vselect" };
|
|
7147
7172
|
if (elementTag === "button" || elementTag === "ubutton")
|
|
7148
7173
|
return { role: "button" };
|
|
7174
|
+
if (elementTag === "router-link" || elementTag === "routerlink")
|
|
7175
|
+
return { role: "link" };
|
|
7176
|
+
if ((elementTag === "a" || elementTag === "ua") && hasHrefAttribute(element))
|
|
7177
|
+
return { role: "link" };
|
|
7149
7178
|
if (isComponentLikeTag(element.tag) && element.tag !== tag) {
|
|
7150
7179
|
const nested = tryInferNativeWrapperRoleFromSfc(element.tag, vueFilesPathMap, normalizedSearchRoots, nextSeen);
|
|
7151
7180
|
if (nested)
|
|
@@ -7440,11 +7469,6 @@ function createTestIdTransform(componentName, componentHierarchyMap, nativeWrapp
|
|
|
7440
7469
|
}
|
|
7441
7470
|
const element = node;
|
|
7442
7471
|
const parentIsRoot = context?.parent?.type === NodeTypes.ROOT;
|
|
7443
|
-
{
|
|
7444
|
-
element.props.find(
|
|
7445
|
-
(p) => p.type === NodeTypes.DIRECTIVE && p.name === "bind" && p.arg?.type === NodeTypes.SIMPLE_EXPRESSION && p.arg.content === testIdAttribute && !!p.exp
|
|
7446
|
-
);
|
|
7447
|
-
}
|
|
7448
7472
|
const grandParent = context.grandParent;
|
|
7449
7473
|
const parentElement = !parentIsRoot && context?.parent?.type === NodeTypes.ELEMENT ? context.parent : !parentIsRoot && grandParent?.type === NodeTypes.ELEMENT ? grandParent : null;
|
|
7450
7474
|
hierarchyMap.set(element, parentElement);
|
|
@@ -7502,7 +7526,8 @@ function createTestIdTransform(componentName, componentHierarchyMap, nativeWrapp
|
|
|
7502
7526
|
}
|
|
7503
7527
|
}
|
|
7504
7528
|
}
|
|
7505
|
-
|
|
7529
|
+
const existingWrapperConfig = nativeWrappers[element.tag];
|
|
7530
|
+
if (!existingWrapperConfig) {
|
|
7506
7531
|
const inferred = tryInferNativeWrapperRoleFromSfc(element.tag, vueFilesPathMap, wrapperSearchRoots);
|
|
7507
7532
|
if (inferred?.role) {
|
|
7508
7533
|
nativeWrappers[element.tag] = { role: inferred.role, inferred: true };
|
|
@@ -7511,6 +7536,22 @@ function createTestIdTransform(componentName, componentHierarchyMap, nativeWrapp
|
|
|
7511
7536
|
} else if (element.tag === "DxDataGrid") {
|
|
7512
7537
|
nativeWrappers[element.tag] = { role: "grid" };
|
|
7513
7538
|
}
|
|
7539
|
+
} else if (!existingWrapperConfig.role) {
|
|
7540
|
+
const inferred = tryInferNativeWrapperRoleFromSfc(element.tag, vueFilesPathMap, wrapperSearchRoots);
|
|
7541
|
+
if (!inferred?.role) {
|
|
7542
|
+
const loc = element.loc?.start;
|
|
7543
|
+
const locationHint = loc ? `${loc.line}:${loc.column}` : "unknown";
|
|
7544
|
+
throw new Error(
|
|
7545
|
+
`[vue-pom-generator] Could not infer a native role for declared wrapper <${element.tag}> in ${componentName} (${context.filename ?? "unknown"}:${locationHint}).
|
|
7546
|
+
The component's template does not render a recognized native control (input, textarea, select, button, vselect, a[href]/RouterLink, radio, checkbox).
|
|
7547
|
+
|
|
7548
|
+
Fix: set \`role\` explicitly in nativeWrappers (e.g. { "${element.tag}": { role: "button", ... } }).`
|
|
7549
|
+
);
|
|
7550
|
+
}
|
|
7551
|
+
nativeWrappers[element.tag] = {
|
|
7552
|
+
...existingWrapperConfig,
|
|
7553
|
+
role: inferred.role
|
|
7554
|
+
};
|
|
7514
7555
|
}
|
|
7515
7556
|
const getBestAvailableKeyInfo = () => {
|
|
7516
7557
|
const parentNode = context.parent && typeof context.parent === "object" ? context.parent : null;
|
|
@@ -7820,7 +7861,7 @@ Fix: remove the explicit ${attrLabel}, or change existingIdBehavior to "overwrit
|
|
|
7820
7861
|
}
|
|
7821
7862
|
if (existingElementDataTestId) {
|
|
7822
7863
|
const inferredRole = getNativeRoleFromTagSuffix().toLowerCase();
|
|
7823
|
-
const isRecognizedInteractiveRole = inferredRole === "button" || inferredRole === "input" || inferredRole === "select" || inferredRole === "vselect" || inferredRole === "checkbox" || inferredRole === "toggle" || inferredRole === "radio" || inferredRole === "grid" || isComponentLikeTag(element.tag);
|
|
7864
|
+
const isRecognizedInteractiveRole = inferredRole === "button" || inferredRole === "input" || inferredRole === "select" || inferredRole === "vselect" || inferredRole === "checkbox" || inferredRole === "toggle" || inferredRole === "radio" || inferredRole === "grid" || inferredRole === "link" || isComponentLikeTag(element.tag);
|
|
7824
7865
|
if (!isRecognizedInteractiveRole) {
|
|
7825
7866
|
return;
|
|
7826
7867
|
}
|
|
@@ -8825,8 +8866,11 @@ const DEFAULT_ENTRY_SUFFIXES = [
|
|
|
8825
8866
|
"/src/main.tsx",
|
|
8826
8867
|
"/src/main.jsx"
|
|
8827
8868
|
];
|
|
8869
|
+
function normalizePathSeparators(filePath) {
|
|
8870
|
+
return filePath.replace(/\\/g, "/");
|
|
8871
|
+
}
|
|
8828
8872
|
function toFsImportPath(filePath) {
|
|
8829
|
-
return `/@fs/${filePath
|
|
8873
|
+
return `/@fs/${normalizePathSeparators(filePath)}`;
|
|
8830
8874
|
}
|
|
8831
8875
|
function resolveAnnotatorClientPath() {
|
|
8832
8876
|
const candidates = [
|
|
@@ -8871,7 +8915,7 @@ function createAnnotatorUiPlugin(options) {
|
|
|
8871
8915
|
if (!options.enabled) {
|
|
8872
8916
|
return null;
|
|
8873
8917
|
}
|
|
8874
|
-
const normalizedId = id
|
|
8918
|
+
const normalizedId = normalizePathSeparators(id);
|
|
8875
8919
|
if (!DEFAULT_ENTRY_SUFFIXES.some((suffix) => normalizedId.endsWith(suffix))) {
|
|
8876
8920
|
return null;
|
|
8877
8921
|
}
|
|
@@ -8919,23 +8963,9 @@ function createInternalPlugins(options) {
|
|
|
8919
8963
|
annotatorRuntime
|
|
8920
8964
|
} = options;
|
|
8921
8965
|
const {
|
|
8922
|
-
outDir,
|
|
8923
|
-
emitLanguages,
|
|
8924
|
-
typescriptOutputStructure,
|
|
8925
|
-
csharp,
|
|
8926
|
-
generateFixtures,
|
|
8927
|
-
customPomAttachments,
|
|
8928
|
-
customPomDir,
|
|
8929
|
-
requireCustomPomDir,
|
|
8930
|
-
customPomImportAliases,
|
|
8931
|
-
customPomImportNameCollisionBehavior,
|
|
8932
|
-
nameCollisionBehavior,
|
|
8933
|
-
existingIdBehavior,
|
|
8934
|
-
testIdAttribute,
|
|
8935
8966
|
routerAwarePoms,
|
|
8936
8967
|
routerEntry,
|
|
8937
|
-
routerType
|
|
8938
|
-
routerModuleShims
|
|
8968
|
+
routerType
|
|
8939
8969
|
} = generation;
|
|
8940
8970
|
const resolveRouterEntry2 = () => {
|
|
8941
8971
|
if (!routerAwarePoms)
|
|
@@ -9057,7 +9087,7 @@ function findStaticAttributeValue(element, attributeName) {
|
|
|
9057
9087
|
(prop) => prop.type === NodeTypes.ATTRIBUTE && prop.name === attributeName
|
|
9058
9088
|
);
|
|
9059
9089
|
const value = attribute?.value?.content?.trim();
|
|
9060
|
-
return value
|
|
9090
|
+
return value || void 0;
|
|
9061
9091
|
}
|
|
9062
9092
|
function collectStaticTextContent(children) {
|
|
9063
9093
|
const parts = [];
|
|
@@ -10431,10 +10461,6 @@ const SHORTCUT_LABELS = {
|
|
|
10431
10461
|
settings: ",",
|
|
10432
10462
|
cancel: "Esc"
|
|
10433
10463
|
};
|
|
10434
|
-
function normalizeText(value) {
|
|
10435
|
-
const normalized = value?.replace(/\s+/g, " ").trim();
|
|
10436
|
-
return normalized || void 0;
|
|
10437
|
-
}
|
|
10438
10464
|
function formatShortcutTitle(label, shortcut) {
|
|
10439
10465
|
return shortcut ? `${label} (${shortcut})` : label;
|
|
10440
10466
|
}
|
|
@@ -10475,11 +10501,11 @@ function getElementPath(element) {
|
|
|
10475
10501
|
return segments.join(" > ");
|
|
10476
10502
|
}
|
|
10477
10503
|
function getNearbyText(element) {
|
|
10478
|
-
const ownText =
|
|
10504
|
+
const ownText = normalizeInlineText(element.textContent || void 0);
|
|
10479
10505
|
if (ownText && ownText.length >= 2) {
|
|
10480
10506
|
return ownText.length > 160 ? `${ownText.slice(0, 160)}...` : ownText;
|
|
10481
10507
|
}
|
|
10482
|
-
const parentText =
|
|
10508
|
+
const parentText = normalizeInlineText(element.parentElement?.textContent || void 0);
|
|
10483
10509
|
if (parentText) {
|
|
10484
10510
|
return parentText.length > 160 ? `${parentText.slice(0, 160)}...` : parentText;
|
|
10485
10511
|
}
|
|
@@ -10502,6 +10528,9 @@ function createFloatingArrow() {
|
|
|
10502
10528
|
function toCssPixels(value) {
|
|
10503
10529
|
return `${Math.round(value)}px`;
|
|
10504
10530
|
}
|
|
10531
|
+
function placementPrimarySide(placement) {
|
|
10532
|
+
return placement.split("-")[0];
|
|
10533
|
+
}
|
|
10505
10534
|
function clamp(value, min, max) {
|
|
10506
10535
|
return Math.min(Math.max(value, min), max);
|
|
10507
10536
|
}
|
|
@@ -10990,7 +11019,7 @@ class AnnotatorRuntime {
|
|
|
10990
11019
|
panel.style.top = toCssPixels(result.y);
|
|
10991
11020
|
panel.style.visibility = "visible";
|
|
10992
11021
|
const arrowData = result.middlewareData.arrow;
|
|
10993
|
-
const side = result.placement
|
|
11022
|
+
const side = placementPrimarySide(result.placement);
|
|
10994
11023
|
const staticSide = side === "top" ? "bottom" : side === "bottom" ? "top" : side === "left" ? "right" : "left";
|
|
10995
11024
|
arrowEl.style.removeProperty("top");
|
|
10996
11025
|
arrowEl.style.removeProperty("right");
|