@immense/vue-pom-generator 1.0.114 → 1.0.116

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,47 +1,34 @@
1
- I'll verify the actual contents of the compare range and the PR's changes before writing the notes.
2
-
3
- The range contains exactly one commit (#79). Let me review its diff to describe the feature
4
- accurately.
1
+ v1.0.116
5
2
 
6
3
  Highlights
7
4
 
8
- - Generated POMs now expose BasePage.screenshot() as a first-class proof-capture seam — no more
9
- reaching for the raw Page escape hatch to save evidence screenshots.
10
- - Options mirror Playwright's own page.screenshot (path, fullPage, timeout) and pass through
11
- verbatim; the method resolves to the image buffer and writes the file when path is set.
12
- - screenshot is recognized as a value-returning method in the fluent chain, so awaited destination
13
- POMs (e.g. after goTo...()) can capture screenshots directly.
5
+ - Wrapper targeting fixed: a component's own fallthrough target is now matched by element, not by
6
+ offset in the wrapper contract (#83) — wrappers no longer bind to the wrong node when sibling
7
+ structure shifts.
8
+ - Corrected the corresponding logic in transform.ts so generated wrappers stay consistent with the
9
+ new element-based matching.
10
+ - Added regression coverage in tests/transform.test.ts and trimmed the offset-based assumptions in
11
+ tests/wrapper-contract.test.ts.
14
12
 
15
13
  Changes
16
14
 
17
- POM class generation
15
+ Fixed
18
16
 
19
- - Added BasePage.screenshot(options?) as a thin delegate to Playwright's page.screenshot — no
20
- animation, callout, or annotation side effects (]8;id=md-78o31g;https://github.com/immense/vue-pom-generator/blob/main/class-generation/base-page.tsbase-page.ts]8;;]8;;).]8;;
21
- - Added BasePageScreenshotOptions (path, fullPage, timeout) and wired screenshot into the narrowed
22
- BasePagePage interface (]8;id=md-14v2psc;https://github.com/immense/vue-pom-generator/blob/main/class-generation/playwright-types.tsplaywright-types.ts]8;;]8;;).]8;;
23
- - Extended fluent-chain handling so screenshot joins getObjectId/getObjectIdAsInt as a
24
- value-returning method, returning the awaited image buffer.
17
+ - wrapper-contract: match a component's own fallthrough target by element rather than by positional
18
+ offset (#83).
19
+ - transform: updated transform behavior to align with element-based fallthrough matching.
25
20
 
26
21
  Tests
27
22
 
28
- - New Playwright spec tests/playwright/pom-screenshot.spec.ts covering: writing a real PNG file
29
- (path) and verifying the resolved buffer matches it, capturing without options, and the consumer
30
- pattern of screenshotting an awaited fluent destination POM.
31
- - Extended broad unit coverage for base-page.ts and updated the fake-runtime test helper to support
32
- the new seam.
33
-
34
- Breaking Changes
35
-
36
- None.
23
+ - tests/transform.test.ts: new cases covering element-based fallthrough target matching.
24
+ - tests/wrapper-contract.test.ts: updated expectations for the corrected matching behavior.
37
25
 
38
26
  Pull Requests Included
39
27
 
40
- - ]8;id=md-fq4e9m;https://github.com/immense/vue-pom-generator/pull/79#79 — feat(pom): BasePage.screenshot proof-capture seam]8;;]8;; (@dkattan)]8;;
28
+ - #83 — fix(wrappers): match a component's own fallthrough target by element, not offset —
29
+ ]8;id=md-1cfqef3;https://github.com/immense/vue-pom-generator/pull/83@darrenator[bot]]8;;
41
30
 
42
31
  Testing
43
32
 
44
- - Unit tests for base-page generation extended in
45
- tests/broad/class-generation-base-page-ts.test.ts.
46
- - New Playwright end-to-end spec validates buffer content, PNG magic bytes, and file-write parity.
33
+ - Unit tests added/updated for transform and wrapper-contract matching behavior.
47
34
 
package/dist/index.cjs CHANGED
@@ -4168,6 +4168,14 @@ function writeGeneratedOutputs(outDir, files, sharedFiles, projectRoot = path.di
4168
4168
  writeFile(manifestPath, `${JSON.stringify(next, null, 2)}
4169
4169
  `);
4170
4170
  }
4171
+ function toPosixSlashes(value) {
4172
+ let out = "";
4173
+ for (let i = 0; i < value.length; i++) {
4174
+ const ch = value[i];
4175
+ out += ch === "\\" ? "/" : ch;
4176
+ }
4177
+ return out;
4178
+ }
4171
4179
  function safeRealpath(value) {
4172
4180
  try {
4173
4181
  if (fs.existsSync(value)) {
@@ -4203,18 +4211,18 @@ function resolveComponentNameFromPath(options) {
4203
4211
  const { projectRoot, viewsDirAbs, sourceDirs, extraRoots = [] } = options;
4204
4212
  const cleanFilename = options.filename.includes("?") ? options.filename.substring(0, options.filename.indexOf("?")) : options.filename;
4205
4213
  const absFilename = path.isAbsolute(cleanFilename) ? cleanFilename : path.resolve(projectRoot, cleanFilename);
4206
- const normalizedAbsFilename = path.normalize(safeRealpath(absFilename));
4214
+ const normalizedAbsFilename = toPosixSlashes(path.normalize(safeRealpath(absFilename)));
4207
4215
  const rootBases = [projectRoot, ...extraRoots.filter((r) => r !== projectRoot)];
4208
4216
  const roots = [
4209
4217
  viewsDirAbs,
4210
4218
  ...sourceDirs.flatMap((dir) => path.isAbsolute(dir) ? [dir] : rootBases.map((base) => path.resolve(base, dir)))
4211
4219
  ];
4212
- const potentialRoots = Array.from(new Set(roots.map((r) => path.normalize(safeRealpath(r))))).sort((a, b) => b.length - a.length);
4220
+ const potentialRoots = Array.from(new Set(roots.map((r) => toPosixSlashes(path.normalize(safeRealpath(r)))))).sort((a, b) => b.length - a.length);
4213
4221
  for (const root of potentialRoots) {
4214
- if (normalizedAbsFilename.startsWith(root + path.sep) || normalizedAbsFilename === root) {
4215
- const rel = path.relative(root, normalizedAbsFilename);
4216
- const parsed = path.parse(rel);
4217
- const segments = path.join(parsed.dir, parsed.name);
4222
+ if (normalizedAbsFilename.startsWith(`${root}/`) || normalizedAbsFilename === root) {
4223
+ const rel = path.posix.relative(root, normalizedAbsFilename);
4224
+ const parsed = path.posix.parse(rel);
4225
+ const segments = path.posix.join(parsed.dir, parsed.name);
4218
4226
  return toPascalCase(segments);
4219
4227
  }
4220
4228
  }
@@ -9029,9 +9037,8 @@ function analyzeWrapperContractFromSfc(options) {
9029
9037
  role: null,
9030
9038
  targetRoles: [],
9031
9039
  forwardedTestIdTargetOffsets: /* @__PURE__ */ new Set(),
9032
- forwardedTestIdTargetSfcOffsets: /* @__PURE__ */ new Set(),
9033
- explicitlyForwardedTestIdTargetOffsets: /* @__PURE__ */ new Set(),
9034
- explicitlyForwardedTestIdTargetSfcOffsets: /* @__PURE__ */ new Set()
9040
+ attrsObjectNames: /* @__PURE__ */ new Set(),
9041
+ attrsFunctionNames: /* @__PURE__ */ new Set()
9035
9042
  };
9036
9043
  }
9037
9044
  const scriptMetadata = analyzeScriptForwardingMetadata(
@@ -9040,7 +9047,6 @@ function analyzeWrapperContractFromSfc(options) {
9040
9047
  );
9041
9048
  const ast = compilerDom.parse(template, { comments: false });
9042
9049
  const targets = /* @__PURE__ */ new Map();
9043
- const explicitTargetOffsets = /* @__PURE__ */ new Set();
9044
9050
  if (scriptMetadata.inheritAttrs) {
9045
9051
  for (const element of getRenderedRootElements(ast)) {
9046
9052
  targets.set(element.loc.start.offset, element);
@@ -9049,7 +9055,6 @@ function analyzeWrapperContractFromSfc(options) {
9049
9055
  walkTemplate(ast, (element) => {
9050
9056
  if (elementExplicitlyForwardsTestId(element, options.testIdAttribute, scriptMetadata)) {
9051
9057
  targets.set(element.loc.start.offset, element);
9052
- explicitTargetOffsets.add(element.loc.start.offset);
9053
9058
  }
9054
9059
  });
9055
9060
  const targetRoles = [...targets.values()].map((element) => {
@@ -9064,17 +9069,12 @@ function analyzeWrapperContractFromSfc(options) {
9064
9069
  });
9065
9070
  const uniqueRoles = new Set(targetRoles);
9066
9071
  const role = uniqueRoles.size === 1 && !uniqueRoles.has(null) ? targetRoles[0] ?? null : null;
9067
- const templateContentStartOffset = descriptor.template?.loc.start.offset ?? 0;
9068
- const toSfcOffsets = (offsets) => new Set(
9069
- [...offsets].map((offset) => offset + templateContentStartOffset)
9070
- );
9071
9072
  return {
9072
9073
  role,
9073
9074
  targetRoles,
9074
9075
  forwardedTestIdTargetOffsets: new Set(targets.keys()),
9075
- forwardedTestIdTargetSfcOffsets: toSfcOffsets(targets.keys()),
9076
- explicitlyForwardedTestIdTargetOffsets: explicitTargetOffsets,
9077
- explicitlyForwardedTestIdTargetSfcOffsets: toSfcOffsets(explicitTargetOffsets)
9076
+ attrsObjectNames: scriptMetadata.attrsObjectNames,
9077
+ attrsFunctionNames: scriptMetadata.attrsFunctionNames
9078
9078
  };
9079
9079
  }
9080
9080
  function resolveWrapperContractForTag(options) {
@@ -9743,8 +9743,7 @@ function createTestIdTransform(componentName, componentHierarchyMap, nativeWrapp
9743
9743
  }
9744
9744
  }
9745
9745
  const ownWrapperContract = getWrapperContract(componentName);
9746
- const elementStartOffset = element.loc.start.offset;
9747
- const isExplicitFallthroughTarget = ownWrapperContract?.explicitlyForwardedTestIdTargetOffsets.has(elementStartOffset) || ownWrapperContract?.explicitlyForwardedTestIdTargetSfcOffsets.has(elementStartOffset);
9746
+ const isExplicitFallthroughTarget = !!ownWrapperContract && elementExplicitlyForwardsTestId(element, testIdAttribute, ownWrapperContract);
9748
9747
  if (!dependencies.isView && isExplicitFallthroughTarget) {
9749
9748
  return;
9750
9749
  }
@@ -10580,7 +10579,8 @@ function createVuePluginWithTestIds(options) {
10580
10579
  runtimeNodeTransform
10581
10580
  ]
10582
10581
  };
10583
- const collectSource = async (code, cleanPath) => {
10582
+ const collectSource = async (code, rawPath) => {
10583
+ const cleanPath = toPosixSlashes(rawPath);
10584
10584
  const componentName = getComponentNameFromPath(cleanPath);
10585
10585
  loggerRef.current.debug(`Collecting metadata for ${cleanPath} (component: ${componentName})`);
10586
10586
  const compilerSfc2 = await import("@vue/compiler-sfc");
@@ -10813,7 +10813,7 @@ function createDevProcessorPlugin(options) {
10813
10813
  const { descriptor } = compilerSfc.parse(source, { filename });
10814
10814
  if (!descriptor.script && !descriptor.scriptSetup)
10815
10815
  return { bindings: void 0, isScriptSetup: false };
10816
- const scriptBlock = compilerSfc.compileScript(descriptor, { id: filename });
10816
+ const scriptBlock = compilerSfc.compileScript(descriptor, { id: toPosixSlashes(filename) });
10817
10817
  return { bindings: scriptBlock.bindings, isScriptSetup: !!descriptor.scriptSetup };
10818
10818
  } catch {
10819
10819
  return { bindings: void 0, isScriptSetup: false };