@immense/vue-pom-generator 1.0.100 → 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/RELEASE_NOTES.md CHANGED
@@ -1,68 +1,44 @@
1
- I'll verify the actual commits and PR merge times in this release range before writing the notes.
1
+ I'll verify which PRs actually fall within the release window by querying the GitHub API for merge
2
+ timestamps.
2
3
 
3
- PR #63 merged at 22:00:03Z (before the window start of 22:06:13Z), so it's in the prior release.
4
- Only PR #62 is in range. Let me review the actual diff to write accurate notes.
5
-
6
- Now I have a complete picture. Only PR #62 falls in the release window (PR #63 merged before the
7
- window start). 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.
8
5
 
9
6
  Highlights
10
7
 
11
- - The generator now infers semantic option identities automatically instead of relying solely on
12
- Vue's :key directive.
13
- - Radio inputs derive identity from :value and emit selectByValue(value); elements with
14
- role="option" derive identity from :data-value.
15
- - optionKeyAttribute is repurposed as an explicit override — map to "key" to opt back into Vue's
16
- reconciliation key, or to a custom bound attribute.
17
- - Missing identity bindings on recognized option controls now fail fast with a clear, actionable
18
- error instead of silently falling back.
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.
19
16
 
20
17
  Changes
21
18
 
22
- Semantic option identity inference
23
-
24
- - Added getConventionalOptionIdentityAttribute to detect radio (:value) and ARIA option
25
- (:data-value) controls by role and tag.
26
- - Repeated radios generate selectByValue(value); repeated role="option" elements generate a keyed
27
- option action keyed off :data-value.
28
- - Other repeated controls continue to use Vue's :key identity unchanged.
29
-
30
- optionKeyAttribute override semantics
31
-
32
- - Explicit component configuration wins over semantic inference.
33
- - Mapping a component to "key" selects Vue's reconciliation :key; any other value must match a
34
- bound attribute on the option element.
35
- - A configured or conventional binding that is missing on a repeated option control throws a
36
- descriptive error with file/line context.
37
-
38
- Documentation & types
39
-
40
- - Updated README.md and plugin/types.ts to document the new conventions, override behavior, and
41
- fail-fast guarantee.
42
-
43
- Tests
44
-
45
- - Added fixtures covering missing :value on mousedown handlers, option-change handlers without
46
- :value, and option elements missing :data-value.
47
- - Updated transform.test.ts and semantic-component-instances.test.ts to reflect the new identity
48
- resolution.
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.
49
29
 
50
30
  Breaking Changes
51
31
 
52
- - Repeated radios must bind :value. Repeated elements with role="option" must bind :data-value.
53
- Templates that previously relied on an implicit :key fallback for these controls will now fail
54
- generation with a directed error message.
55
- - Missing optionKeyAttribute overrides no longer silently fall back to :key. A configured binding
56
- is required on recognized option controls; absence is a hard error.
32
+ None.
57
33
 
58
34
  Pull Requests Included
59
35
 
60
- - ]8;id=md-co5m4y;https://github.com/immense/vue-pom-generator/pull/62#62 Infer semantic option identities]8;;]8;; (@dkattan)]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;;
61
37
 
62
38
  Testing
63
39
 
64
- - npm test (42 files, 431 tests), npm run typecheck, npm run lint (0 errors), npm run smoke:pack,
65
- and npm run test:playwright (3 tests) all pass.
66
- - Validated against an ImmyBot generated-POM migration build (643 entries, 1,442 selectors) using a
67
- local packed dependency.
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.
68
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
- exp: compilerCore.createSimpleExpression(`\`${value.template}\``, false, element.loc),
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(args.element, testIdAttribute, dataTestId);
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(args.element, `${metadataAttributePrefix}-testid`, runtimeDataTestId);
3405
- upsertAttribute(args.element, `${metadataAttributePrefix}-action`, staticAttributeValue(buildPomGeneratedActionName(dataTestIdEntry.pom)));
3406
- upsertAttribute(args.element, `${metadataAttributePrefix}-property`, staticAttributeValue(buildPomGeneratedPropertyName(dataTestIdEntry.pom)));
3407
- upsertAttribute(args.element, `${metadataAttributePrefix}-role`, staticAttributeValue(normalizedRole));
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);
@@ -9363,7 +9377,10 @@ File: ${context.filename ?? "unknown"}:${loc.line}:${loc.column}`
9363
9377
  const propName = crossFileKeyRegistry.get(componentName);
9364
9378
  if (propName) {
9365
9379
  const fallbackExpr = buildSlotScopeFallbackKeyExpression(propName);
9366
- return toResolvedKeyInfo(fallbackExpr, fallbackExpr);
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);
9367
9384
  }
9368
9385
  }
9369
9386
  return null;
@@ -9399,7 +9416,7 @@ File: ${context.filename ?? "unknown"}:${loc.line}:${loc.column}`
9399
9416
  });
9400
9417
  const runtimeMarker = componentInstanceKeyInfo ? templateAttributeValue(`${componentName}-${componentInstanceKeyInfo.runtimeFragment}-${instanceName}-component`) : staticAttributeValue(`${componentName}-${instanceName}-component`);
9401
9418
  const selector = componentInstanceKeyInfo ? createPomStringPattern(`${componentName}-\${key}-${instanceName}-component`, "parameterized", ["key"]) : createPomStringPattern(`${componentName}-${instanceName}-component`, "static", []);
9402
- upsertAttribute(element, POM_INSTANCE_ATTRIBUTE, runtimeMarker);
9419
+ upsertAttribute(element, POM_INSTANCE_ATTRIBUTE, runtimeMarker, context);
9403
9420
  const slotTemplate = getContainedInSlotTemplateNode(element, hierarchyMap);
9404
9421
  const slotName = slotTemplate ? getSlotNameFromTemplate(slotTemplate) : null;
9405
9422
  const slotOwner = slotTemplate ? getNearestComponentAncestor(slotTemplate, hierarchyMap, isComponentLikeTag2) : null;
@@ -9571,7 +9588,7 @@ Existing ${attrLabel}: ${JSON.stringify(existing.value)}
9571
9588
  Fix: remove the explicit ${attrLabel}, or change existingIdBehavior to "overwrite" or "error".`
9572
9589
  );
9573
9590
  }
9574
- upsertAttribute(element, "option-data-testid-prefix", optionDataTestIdPrefixValue);
9591
+ upsertAttribute(element, "option-data-testid-prefix", optionDataTestIdPrefixValue, context);
9575
9592
  }
9576
9593
  const nativeRole = resolvedNativeWrappers[element.tag]?.role ?? element.tag;
9577
9594
  const wrapperHintCandidates = [