@immense/vue-pom-generator 1.0.99 → 1.0.101
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 +14 -6
- package/RELEASE_NOTES.md +27 -48
- package/dist/index.cjs +90 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +91 -16
- package/dist/index.mjs.map +1 -1
- package/dist/plugin/types.d.ts +10 -7
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/transform.d.ts +2 -3
- package/dist/transform.d.ts.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -787,12 +787,20 @@ misleading API. Components that do not forward the marker to a DOM root are omit
|
|
|
787
787
|
component-instance composition rather than falling back to page-wide selectors; their
|
|
788
788
|
own standalone fixture is still generated normally.
|
|
789
789
|
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
790
|
+
Repeated option controls use their semantic identity automatically:
|
|
791
|
+
|
|
792
|
+
- radio inputs require `:value` and generate `selectByValue(value)`;
|
|
793
|
+
- elements with `role="option"` require `:data-value` and generate a keyed option action;
|
|
794
|
+
- other repeated controls continue to use their Vue `:key` identity.
|
|
795
|
+
|
|
796
|
+
When the template does not expose a finite set of values, the generated option parameter
|
|
797
|
+
accepts primitive HTML values (`string | number | boolean | bigint`) so domain enums can be
|
|
798
|
+
passed without string conversion.
|
|
799
|
+
|
|
800
|
+
Use `injection.optionKeyAttribute` only to override those conventions for a component.
|
|
801
|
+
Map the component to `"key"` to explicitly use Vue's reconciliation key, or to another
|
|
802
|
+
bound attribute such as `"data-option-id"`. A configured binding is required on recognized
|
|
803
|
+
option controls; generation fails instead of silently choosing a different identity.
|
|
796
804
|
|
|
797
805
|
`data-pom-instance` is generator-owned. Do not author it in Vue templates.
|
|
798
806
|
|
package/RELEASE_NOTES.md
CHANGED
|
@@ -1,65 +1,44 @@
|
|
|
1
|
-
I'll verify which PRs
|
|
1
|
+
I'll verify which PRs actually fall within the release window by querying the GitHub API for merge
|
|
2
|
+
timestamps.
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Now I understand the picture. v1.0.98 tag is at commit f495936 (#61 "Clear Knip findings"), so #61
|
|
6
|
-
is excluded. Only #55 and #63 are in v1.0.99. Let me examine the actual diffs to write accurate
|
|
7
|
-
notes.
|
|
8
|
-
|
|
9
|
-
I now have a complete picture. v1.0.99 includes exactly two PRs (#55 and #63); #61 was the v1.0.98
|
|
10
|
-
release commit itself and is excluded. Here are the release notes:
|
|
4
|
+
Only PR #64 is in the v1.0.100..HEAD range. Let me examine the diff to write accurate notes.
|
|
11
5
|
|
|
12
6
|
Highlights
|
|
13
7
|
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
-
|
|
8
|
+
- Generator-injected dynamic bindings (e.g. :data-testid, annotator metadata attributes) now retain
|
|
9
|
+
correct runtime scope, resolving against setup vars, props, and v-for/slot locals just like
|
|
10
|
+
authored bindings.
|
|
11
|
+
- upsertAttribute processes template-literal expressions through Vue's processExpression when
|
|
12
|
+
prefixIdentifiers is active, so injected identifiers are properly rewritten ($props.subject.id,
|
|
13
|
+
$setup.getPanelKey($setup.state), _ctx.subject.key).
|
|
14
|
+
- Slot-scope fallback key expressions in the cross-file key registry are likewise scope-preserved.
|
|
15
|
+
- New regression tests cover both cross-file key expressions and keyed component-instance markers.
|
|
21
16
|
|
|
22
17
|
Changes
|
|
23
18
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
(class-generation/base-page.ts)
|
|
35
|
-
- When preferAssociatedLabel is set, BasePage.clickTestId now locates the nested native checkable
|
|
36
|
-
control inside the wrapper and uses it as the click target instead of the wrapper element
|
|
37
|
-
- Keyboard activation (Space) and cursor animation now target the nested control rather than the
|
|
38
|
-
wrapper
|
|
39
|
-
|
|
40
|
-
Documentation
|
|
41
|
-
|
|
42
|
-
- README: documented that templates without a finite value set accept primitive HTML values so
|
|
43
|
-
domain enums can be passed directly
|
|
19
|
+
- transform.ts: slot-scope fallback key expression is now run through createSimpleExpression +
|
|
20
|
+
processExpression before being resolved, ensuring runtime identifiers are prefixed correctly;
|
|
21
|
+
context is threaded into upsertAttribute calls for POM-instance and option-prefix attributes.
|
|
22
|
+
- utils.ts: upsertAttribute gains an optional TransformContext parameter; template-kind bindings
|
|
23
|
+
are processed via processExpression when context.prefixIdentifiers is set. applyResolvedDataTestId
|
|
24
|
+
forwards context to all annotator metadata and data-testid attribute writes.
|
|
25
|
+
- tests/transform.test.ts: compileWithRuntimeTemplateOptions extended with inline,
|
|
26
|
+
crossFileKeyRegistry, vueFilesPathMap, and wrapperSearchRoots options; added tests asserting
|
|
27
|
+
runtime-scope rewriting for cross-file key expressions and keyed component-instance markers; updated
|
|
28
|
+
an existing assertion to expect _ctx.subject.* prefixes.
|
|
44
29
|
|
|
45
30
|
Breaking Changes
|
|
46
31
|
|
|
47
|
-
None.
|
|
48
|
-
corrects behavior without altering the generated POM API surface.
|
|
32
|
+
None.
|
|
49
33
|
|
|
50
34
|
Pull Requests Included
|
|
51
35
|
|
|
52
|
-
- ]8;id=md-
|
|
53
|
-
- ]8;id=md-1f8vu20;https://github.com/immense/vue-pom-generator/pull/55#55 fix(runtime): activate nested checkbox controls]8;;
|
|
36
|
+
- ]8;id=md-b07zz4;https://github.com/immense/vue-pom-generator/pull/64#64 — fix: preserve injected expression scope]8;;]8;; (@dkattan)]8;;
|
|
54
37
|
|
|
55
38
|
Testing
|
|
56
39
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
(tests/transform.test.ts)
|
|
62
|
-
- Updated semantic component instance tests to exercise numeric radio values end-to-end, including
|
|
63
|
-
a typecheck consumer file that compiles selectByValue(3)
|
|
64
|
-
(tests/semantic-component-instances.test.ts)
|
|
40
|
+
Added regression tests in tests/transform.test.ts verifying that injected cross-file key expressions
|
|
41
|
+
resolve to $props.subject.id and keyed component-instance markers resolve to
|
|
42
|
+
$setup.getPanelKey($setup.state), with assertions that bare-identifier forms no longer appear in
|
|
43
|
+
compiled output.
|
|
65
44
|
|
package/dist/index.cjs
CHANGED
|
@@ -2766,7 +2766,7 @@ function findTestIdAttribute(element, attributeName) {
|
|
|
2766
2766
|
return staticAttr;
|
|
2767
2767
|
return findDirectiveByName(element, "bind", attributeName) ?? null;
|
|
2768
2768
|
}
|
|
2769
|
-
function upsertAttribute(element, attributeName, value) {
|
|
2769
|
+
function upsertAttribute(element, attributeName, value, context) {
|
|
2770
2770
|
element.props = element.props.filter((prop) => {
|
|
2771
2771
|
if (prop.type === compilerCore.NodeTypes.ATTRIBUTE && prop.name === attributeName) {
|
|
2772
2772
|
return false;
|
|
@@ -2777,6 +2777,7 @@ function upsertAttribute(element, attributeName, value) {
|
|
|
2777
2777
|
return true;
|
|
2778
2778
|
});
|
|
2779
2779
|
if (value.kind === "template") {
|
|
2780
|
+
const expression = compilerCore.createSimpleExpression(`\`${value.template}\``, false, element.loc);
|
|
2780
2781
|
element.props.push({
|
|
2781
2782
|
type: compilerCore.NodeTypes.DIRECTIVE,
|
|
2782
2783
|
name: "bind",
|
|
@@ -2787,7 +2788,10 @@ function upsertAttribute(element, attributeName, value) {
|
|
|
2787
2788
|
constType: 0,
|
|
2788
2789
|
loc: element.loc
|
|
2789
2790
|
},
|
|
2790
|
-
|
|
2791
|
+
// Custom node transforms run after Vue's built-in expression transform.
|
|
2792
|
+
// Process generator-owned bindings explicitly so setup bindings, props,
|
|
2793
|
+
// and v-for/slot locals retain the same runtime scope as authored bindings.
|
|
2794
|
+
exp: context?.prefixIdentifiers ? compilerCore.processExpression(expression, context) : expression,
|
|
2791
2795
|
modifiers: [],
|
|
2792
2796
|
loc: element.loc
|
|
2793
2797
|
});
|
|
@@ -3360,7 +3364,12 @@ Fix: make the element identifiable (e.g. add id/name/inner text or use a more sp
|
|
|
3360
3364
|
}
|
|
3361
3365
|
const normalizedParameters = selectorIsParameterized ? setPomParameter(parameters, selectorParameterName, keyTypeFromValues) : removePomParameter(parameters, selectorParameterName);
|
|
3362
3366
|
if (addHtmlAttribute && !fromExisting) {
|
|
3363
|
-
upsertAttribute(
|
|
3367
|
+
upsertAttribute(
|
|
3368
|
+
args.element,
|
|
3369
|
+
testIdAttribute,
|
|
3370
|
+
runtimeDataTestId,
|
|
3371
|
+
args.preferredRuntimeValue ? args.context : void 0
|
|
3372
|
+
);
|
|
3364
3373
|
}
|
|
3365
3374
|
const childComponentName = args.element.tag;
|
|
3366
3375
|
const dataTestIdEntry = {
|
|
@@ -3398,13 +3407,18 @@ Fix: make the element identifiable (e.g. add id/name/inner text or use a more sp
|
|
|
3398
3407
|
throw new Error(`[vue-pom-generator] runtime.annotator.enabled requires element source locations for ${args.componentName}.`);
|
|
3399
3408
|
}
|
|
3400
3409
|
const metadataAttributePrefix = args.annotatorMetadata.metadataAttributePrefix;
|
|
3401
|
-
upsertAttribute(args.element, args.annotatorMetadata.sourceAttribute, staticAttributeValue(`${filename}:${sourceLocation.line}:${sourceLocation.column}`));
|
|
3402
|
-
upsertAttribute(args.element, `${metadataAttributePrefix}-component`, staticAttributeValue(args.componentName));
|
|
3403
|
-
upsertAttribute(args.element, `${metadataAttributePrefix}-tag`, staticAttributeValue(args.element.tag));
|
|
3404
|
-
upsertAttribute(
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3410
|
+
upsertAttribute(args.element, args.annotatorMetadata.sourceAttribute, staticAttributeValue(`${filename}:${sourceLocation.line}:${sourceLocation.column}`), args.context);
|
|
3411
|
+
upsertAttribute(args.element, `${metadataAttributePrefix}-component`, staticAttributeValue(args.componentName), args.context);
|
|
3412
|
+
upsertAttribute(args.element, `${metadataAttributePrefix}-tag`, staticAttributeValue(args.element.tag), args.context);
|
|
3413
|
+
upsertAttribute(
|
|
3414
|
+
args.element,
|
|
3415
|
+
`${metadataAttributePrefix}-testid`,
|
|
3416
|
+
runtimeDataTestId,
|
|
3417
|
+
args.preferredRuntimeValue ? args.context : void 0
|
|
3418
|
+
);
|
|
3419
|
+
upsertAttribute(args.element, `${metadataAttributePrefix}-action`, staticAttributeValue(buildPomGeneratedActionName(dataTestIdEntry.pom)), args.context);
|
|
3420
|
+
upsertAttribute(args.element, `${metadataAttributePrefix}-property`, staticAttributeValue(buildPomGeneratedPropertyName(dataTestIdEntry.pom)), args.context);
|
|
3421
|
+
upsertAttribute(args.element, `${metadataAttributePrefix}-role`, staticAttributeValue(normalizedRole), args.context);
|
|
3408
3422
|
}
|
|
3409
3423
|
args.dependencies.childrenComponentSet.add(childComponentName);
|
|
3410
3424
|
args.dependencies.usedComponentSet.add(childComponentName);
|
|
@@ -8728,6 +8742,24 @@ function getStaticAttributeContent(element, name) {
|
|
|
8728
8742
|
function getNativeHtmlControlRole(element) {
|
|
8729
8743
|
return getElementControlRole(element);
|
|
8730
8744
|
}
|
|
8745
|
+
function getConventionalOptionIdentityAttribute(element) {
|
|
8746
|
+
const explicitRole = getStaticAttributeContent(element, "role")?.toLowerCase();
|
|
8747
|
+
if (explicitRole === "option") {
|
|
8748
|
+
return "data-value";
|
|
8749
|
+
}
|
|
8750
|
+
if (explicitRole === "radio") {
|
|
8751
|
+
return "value";
|
|
8752
|
+
}
|
|
8753
|
+
const tag = element.tag.toLowerCase();
|
|
8754
|
+
const type = getStaticAttributeContent(element, "type")?.toLowerCase();
|
|
8755
|
+
if ((tag === "input" || tag === "uinput") && type === "radio") {
|
|
8756
|
+
return "value";
|
|
8757
|
+
}
|
|
8758
|
+
return null;
|
|
8759
|
+
}
|
|
8760
|
+
function describeConventionalOption(element) {
|
|
8761
|
+
return getConventionalOptionIdentityAttribute(element) === "value" ? "radio" : `<${element.tag} role="option">`;
|
|
8762
|
+
}
|
|
8731
8763
|
function normalizeControlLabelText(value) {
|
|
8732
8764
|
const normalized = (value ?? "").replace(/\*/g, " ").replace(/\s+/g, " ").trim();
|
|
8733
8765
|
return normalized || null;
|
|
@@ -9282,15 +9314,55 @@ Fix: set \`role\` explicitly in nativeWrappers (e.g. { "${element.tag}": { role:
|
|
|
9282
9314
|
const getBestAvailableKeyInfo = () => {
|
|
9283
9315
|
const parentNode = context.parent && typeof context.parent === "object" ? context.parent : null;
|
|
9284
9316
|
const isDirectVForChild = parentNode?.type === compilerCore.NodeTypes.FOR;
|
|
9285
|
-
const
|
|
9317
|
+
const isInVForScope = isDirectVForChild || context.scopes.vFor > 0;
|
|
9318
|
+
const vForKeyInfo = (isDirectVForChild ? getKeyDirectiveInfo(element) : null) || getContainedInVForDirectiveKeyInfo(context, element, hierarchyMap);
|
|
9319
|
+
const conventionalIdentityAttribute = getConventionalOptionIdentityAttribute(element);
|
|
9320
|
+
const configuredAttrName = optionKeyAttribute[componentName]?.trim();
|
|
9321
|
+
if (configuredAttrName === "key") {
|
|
9322
|
+
if (vForKeyInfo) {
|
|
9323
|
+
return vForKeyInfo;
|
|
9324
|
+
}
|
|
9325
|
+
if (isInVForScope && conventionalIdentityAttribute) {
|
|
9326
|
+
const loc = element.loc.start;
|
|
9327
|
+
throw new Error(
|
|
9328
|
+
`[vue-pom-generator] optionKeyAttribute maps ${componentName} to "key", but repeated ${describeConventionalOption(element)} has no resolvable v-for :key.
|
|
9329
|
+
File: ${context.filename ?? "unknown"}:${loc.line}:${loc.column}
|
|
9330
|
+
|
|
9331
|
+
Fix: bind :key on the repeated option or remove the override to use the conventional :${conventionalIdentityAttribute} identity.`
|
|
9332
|
+
);
|
|
9333
|
+
}
|
|
9334
|
+
}
|
|
9286
9335
|
if (configuredAttrName && configuredAttrName !== "key") {
|
|
9287
9336
|
const bindingKeyInfo = getBindingKeyInfo(element, configuredAttrName);
|
|
9288
9337
|
if (bindingKeyInfo) {
|
|
9289
9338
|
selectorParameterName = configuredAttrName === "value" ? "value" : "key";
|
|
9290
9339
|
return bindingKeyInfo;
|
|
9291
9340
|
}
|
|
9341
|
+
if (isInVForScope && conventionalIdentityAttribute) {
|
|
9342
|
+
const loc = element.loc.start;
|
|
9343
|
+
throw new Error(
|
|
9344
|
+
`[vue-pom-generator] optionKeyAttribute maps ${componentName} to "${configuredAttrName}", but repeated ${describeConventionalOption(element)} does not bind :${configuredAttrName}.
|
|
9345
|
+
File: ${context.filename ?? "unknown"}:${loc.line}:${loc.column}
|
|
9346
|
+
|
|
9347
|
+
Fix: bind :${configuredAttrName} on the option element or remove the override to use the conventional :${conventionalIdentityAttribute} identity.`
|
|
9348
|
+
);
|
|
9349
|
+
}
|
|
9350
|
+
}
|
|
9351
|
+
if (conventionalIdentityAttribute) {
|
|
9352
|
+
const bindingKeyInfo = getBindingKeyInfo(element, conventionalIdentityAttribute);
|
|
9353
|
+
if (bindingKeyInfo) {
|
|
9354
|
+
selectorParameterName = conventionalIdentityAttribute === "value" ? "value" : "key";
|
|
9355
|
+
return bindingKeyInfo;
|
|
9356
|
+
}
|
|
9357
|
+
if (isInVForScope) {
|
|
9358
|
+
const loc = element.loc.start;
|
|
9359
|
+
throw new Error(
|
|
9360
|
+
`[vue-pom-generator] Repeated ${describeConventionalOption(element)} must bind :${conventionalIdentityAttribute} for generated option selection.
|
|
9361
|
+
Component: ${componentName}
|
|
9362
|
+
File: ${context.filename ?? "unknown"}:${loc.line}:${loc.column}`
|
|
9363
|
+
);
|
|
9364
|
+
}
|
|
9292
9365
|
}
|
|
9293
|
-
const vForKeyInfo = (isDirectVForChild ? getKeyDirectiveInfo(element) : null) || getContainedInVForDirectiveKeyInfo(context, element, hierarchyMap);
|
|
9294
9366
|
if (vForKeyInfo) {
|
|
9295
9367
|
return vForKeyInfo;
|
|
9296
9368
|
}
|
|
@@ -9305,7 +9377,10 @@ Fix: set \`role\` explicitly in nativeWrappers (e.g. { "${element.tag}": { role:
|
|
|
9305
9377
|
const propName = crossFileKeyRegistry.get(componentName);
|
|
9306
9378
|
if (propName) {
|
|
9307
9379
|
const fallbackExpr = buildSlotScopeFallbackKeyExpression(propName);
|
|
9308
|
-
|
|
9380
|
+
const runtimeExpression = compilerCore.createSimpleExpression(fallbackExpr, false, element.loc);
|
|
9381
|
+
const selectorExpression = context.prefixIdentifiers ? compilerCore.processExpression(runtimeExpression, context) : runtimeExpression;
|
|
9382
|
+
const selectorSource = getVueExpressionSource(selectorExpression, "compiled", "content");
|
|
9383
|
+
return toResolvedKeyInfo(selectorSource, fallbackExpr);
|
|
9309
9384
|
}
|
|
9310
9385
|
}
|
|
9311
9386
|
return null;
|
|
@@ -9341,7 +9416,7 @@ File: ${context.filename ?? "unknown"}:${loc.line}:${loc.column}`
|
|
|
9341
9416
|
});
|
|
9342
9417
|
const runtimeMarker = componentInstanceKeyInfo ? templateAttributeValue(`${componentName}-${componentInstanceKeyInfo.runtimeFragment}-${instanceName}-component`) : staticAttributeValue(`${componentName}-${instanceName}-component`);
|
|
9343
9418
|
const selector = componentInstanceKeyInfo ? createPomStringPattern(`${componentName}-\${key}-${instanceName}-component`, "parameterized", ["key"]) : createPomStringPattern(`${componentName}-${instanceName}-component`, "static", []);
|
|
9344
|
-
upsertAttribute(element, POM_INSTANCE_ATTRIBUTE, runtimeMarker);
|
|
9419
|
+
upsertAttribute(element, POM_INSTANCE_ATTRIBUTE, runtimeMarker, context);
|
|
9345
9420
|
const slotTemplate = getContainedInSlotTemplateNode(element, hierarchyMap);
|
|
9346
9421
|
const slotName = slotTemplate ? getSlotNameFromTemplate(slotTemplate) : null;
|
|
9347
9422
|
const slotOwner = slotTemplate ? getNearestComponentAncestor(slotTemplate, hierarchyMap, isComponentLikeTag2) : null;
|
|
@@ -9513,7 +9588,7 @@ Existing ${attrLabel}: ${JSON.stringify(existing.value)}
|
|
|
9513
9588
|
Fix: remove the explicit ${attrLabel}, or change existingIdBehavior to "overwrite" or "error".`
|
|
9514
9589
|
);
|
|
9515
9590
|
}
|
|
9516
|
-
upsertAttribute(element, "option-data-testid-prefix", optionDataTestIdPrefixValue);
|
|
9591
|
+
upsertAttribute(element, "option-data-testid-prefix", optionDataTestIdPrefixValue, context);
|
|
9517
9592
|
}
|
|
9518
9593
|
const nativeRole = resolvedNativeWrappers[element.tag]?.role ?? element.tag;
|
|
9519
9594
|
const wrapperHintCandidates = [
|