@immense/vue-pom-generator 1.0.119 → 1.0.121

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 (35) hide show
  1. package/README.md +88 -0
  2. package/RELEASE_NOTES.md +23 -34
  3. package/class-generation/base-page.ts +2 -0
  4. package/class-generation/index.ts +41 -43
  5. package/class-generation/pointer.ts +101 -4
  6. package/dist/class-generation/base-page.d.ts +2 -0
  7. package/dist/class-generation/base-page.d.ts.map +1 -1
  8. package/dist/class-generation/index.d.ts +2 -0
  9. package/dist/class-generation/index.d.ts.map +1 -1
  10. package/dist/class-generation/pointer.d.ts +55 -1
  11. package/dist/class-generation/pointer.d.ts.map +1 -1
  12. package/dist/index.cjs +222 -137
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.mjs +222 -137
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/manifest-generator.d.ts +18 -0
  19. package/dist/manifest-generator.d.ts.map +1 -1
  20. package/dist/playwright/runtime.cjs +20 -4
  21. package/dist/playwright/runtime.cjs.map +1 -1
  22. package/dist/playwright/runtime.mjs +20 -4
  23. package/dist/playwright/runtime.mjs.map +1 -1
  24. package/dist/plugin/create-vue-pom-generator-plugins.d.ts.map +1 -1
  25. package/dist/plugin/internal/build-plugin.d.ts.map +1 -1
  26. package/dist/plugin/internal/dev-plugin.d.ts.map +1 -1
  27. package/dist/plugin/path-utils.d.ts +1 -0
  28. package/dist/plugin/path-utils.d.ts.map +1 -1
  29. package/dist/plugin/resolved-generation-options.d.ts +1 -0
  30. package/dist/plugin/resolved-generation-options.d.ts.map +1 -1
  31. package/dist/plugin/types.d.ts +6 -0
  32. package/dist/plugin/types.d.ts.map +1 -1
  33. package/dist/router-introspection.d.ts +10 -1
  34. package/dist/router-introspection.d.ts.map +1 -1
  35. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ import type { NuxtPomGeneratorPluginOptions, VuePomGeneratorPluginOptions } from
5
5
  export { createVuePomGeneratorPlugins };
6
6
  export { createVuePomGeneratorPlugins as vuePomGenerator };
7
7
  export default createVuePomGeneratorPlugins;
8
+ export type { ComponentGraph } from "./manifest-generator";
8
9
  export { generateVuePoms, type VuePomGenerationViteOptions } from "./plugin/generate-vue-poms";
9
10
  export { mountAnnotatorClient };
10
11
  export type { AnnotatorClientOptions, AnnotatorSubmitHandler };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,MAAM,2CAA2C,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAExG,OAAO,KAAK,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAIlG,OAAO,EAAE,4BAA4B,EAAE,CAAC;AACxC,OAAO,EAAE,4BAA4B,IAAI,eAAe,EAAE,CAAC;AAC3D,eAAe,4BAA4B,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,KAAK,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAE/F,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAChC,YAAY,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,CAAC;AAC/D,YAAY,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAE7E,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,4BAA4B,GAAG,4BAA4B,CAE/G;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,6BAA6B,GAAG,6BAA6B,CAOlH;AAED,YAAY,EACV,kBAAkB,EAClB,6BAA6B,EAC7B,wBAAwB,EACxB,2BAA2B,EAC3B,6BAA6B,EAC7B,yBAAyB,EACzB,wBAAwB,EACxB,4BAA4B,EAC5B,6BAA6B,EAC7B,sCAAsC,EACtC,wCAAwC,GACzC,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,MAAM,2CAA2C,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAExG,OAAO,KAAK,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAIlG,OAAO,EAAE,4BAA4B,EAAE,CAAC;AACxC,OAAO,EAAE,4BAA4B,IAAI,eAAe,EAAE,CAAC;AAC3D,eAAe,4BAA4B,CAAC;AAE5C,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,KAAK,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAE/F,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAChC,YAAY,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,CAAC;AAC/D,YAAY,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAE7E,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,4BAA4B,GAAG,4BAA4B,CAE/G;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,6BAA6B,GAAG,6BAA6B,CAOlH;AAED,YAAY,EACV,kBAAkB,EAClB,6BAA6B,EAC7B,wBAAwB,EACxB,2BAA2B,EAC3B,6BAA6B,EAC7B,yBAAyB,EACzB,wBAAwB,EACxB,4BAA4B,EAC5B,6BAA6B,EAC7B,sCAAsC,EACtC,wCAAwC,GACzC,MAAM,gBAAgB,CAAC"}
package/dist/index.mjs CHANGED
@@ -222,6 +222,7 @@ function resolveGenerationSupportOptions(options) {
222
222
  customPomImportAliases: options.customPomImportAliases,
223
223
  customPomImportNameCollisionBehavior: options.customPomImportNameCollisionBehavior ?? "error",
224
224
  customPomFixtures: options.customPomFixtures ?? [],
225
+ componentGraph: options.componentGraph ?? false,
225
226
  nameCollisionBehavior: options.nameCollisionBehavior ?? "error",
226
227
  missingSemanticNameBehavior: options.missingSemanticNameBehavior ?? "error",
227
228
  existingIdBehavior: options.existingIdBehavior ?? "error",
@@ -3877,6 +3878,103 @@ function buildPomGeneratedPropertyName(pom) {
3877
3878
  function buildPomGeneratedActionName(pom) {
3878
3879
  return requireStructuredPomName(pom.generatedActionName, "generatedActionName", pom);
3879
3880
  }
3881
+ function toPosixSlashes(value) {
3882
+ let out = "";
3883
+ for (let i = 0; i < value.length; i++) {
3884
+ const ch = value[i];
3885
+ out += ch === "\\" ? "/" : ch;
3886
+ }
3887
+ return out;
3888
+ }
3889
+ function safeRealpath(value) {
3890
+ try {
3891
+ if (fs.existsSync(value)) {
3892
+ return fs.realpathSync(value);
3893
+ }
3894
+ } catch {
3895
+ return value;
3896
+ }
3897
+ const parent = path.dirname(value);
3898
+ if (!parent || parent === value) {
3899
+ return value;
3900
+ }
3901
+ const resolvedParent = safeRealpath(parent);
3902
+ return resolvedParent === parent ? value : path.join(resolvedParent, path.basename(value));
3903
+ }
3904
+ function normalizeScopePath(value, pathImpl = path) {
3905
+ return pathImpl.normalize(value);
3906
+ }
3907
+ function isNormalizedPathWithinDir(filePathAbs, dirPathAbs, pathImpl = path) {
3908
+ const normalizedFileAbs = normalizeScopePath(filePathAbs, pathImpl);
3909
+ const normalizedDirAbs = normalizeScopePath(dirPathAbs, pathImpl);
3910
+ return normalizedFileAbs === normalizedDirAbs || normalizedFileAbs.startsWith(`${normalizedDirAbs}${pathImpl.sep}`);
3911
+ }
3912
+ function isPathWithinDir(filePathAbs, dirPathAbs) {
3913
+ const fileAbs = path.resolve(filePathAbs);
3914
+ const dirAbs = path.resolve(dirPathAbs);
3915
+ const rel = path.relative(dirAbs, fileAbs);
3916
+ if (!rel)
3917
+ return true;
3918
+ return !rel.startsWith("..") && !path.isAbsolute(rel);
3919
+ }
3920
+ function resolveComponentNameFromPath(options) {
3921
+ const { projectRoot, viewsDirAbs, sourceDirs, extraRoots = [] } = options;
3922
+ const cleanFilename = options.filename.includes("?") ? options.filename.substring(0, options.filename.indexOf("?")) : options.filename;
3923
+ const absFilename = path.isAbsolute(cleanFilename) ? cleanFilename : path.resolve(projectRoot, cleanFilename);
3924
+ const normalizedAbsFilename = toPosixSlashes(path.normalize(safeRealpath(absFilename)));
3925
+ const rootBases = [projectRoot, ...extraRoots.filter((r) => r !== projectRoot)];
3926
+ const roots = [
3927
+ viewsDirAbs,
3928
+ ...sourceDirs.flatMap((dir) => path.isAbsolute(dir) ? [dir] : rootBases.map((base) => path.resolve(base, dir)))
3929
+ ];
3930
+ const potentialRoots = Array.from(new Set(roots.map((r) => toPosixSlashes(path.normalize(safeRealpath(r)))))).sort((a, b) => b.length - a.length);
3931
+ for (const root of potentialRoots) {
3932
+ if (normalizedAbsFilename.startsWith(`${root}/`) || normalizedAbsFilename === root) {
3933
+ const rel = path.posix.relative(root, normalizedAbsFilename);
3934
+ const parsed = path.posix.parse(rel);
3935
+ const segments = path.posix.join(parsed.dir, parsed.name);
3936
+ return toPascalCase(segments);
3937
+ }
3938
+ }
3939
+ return toPascalCase(path.parse(normalizedAbsFilename).name);
3940
+ }
3941
+ function isFileInConfiguredSourceScope(options) {
3942
+ const { filename, projectRoot, viewsDirAbs, sourceDirs, extraRoots = [], pathImpl = path } = options;
3943
+ if (!filename) {
3944
+ return false;
3945
+ }
3946
+ const cleanFilename = filename.includes("?") ? filename.substring(0, filename.indexOf("?")) : filename;
3947
+ const normalizedProjectRoot = normalizeScopePath(projectRoot, pathImpl);
3948
+ const normalizedAbsFilename = normalizeScopePath(
3949
+ pathImpl.isAbsolute(cleanFilename) ? cleanFilename : pathImpl.resolve(normalizedProjectRoot, cleanFilename),
3950
+ pathImpl
3951
+ );
3952
+ if (normalizedAbsFilename.includes(`${pathImpl.sep}node_modules${pathImpl.sep}`) || normalizedAbsFilename.includes("/node_modules/")) {
3953
+ return false;
3954
+ }
3955
+ const normalizedViewsDirAbs = normalizeScopePath(viewsDirAbs, pathImpl);
3956
+ if (isNormalizedPathWithinDir(normalizedAbsFilename, normalizedViewsDirAbs, pathImpl)) {
3957
+ return true;
3958
+ }
3959
+ const rootsToTry = Array.from(/* @__PURE__ */ new Set([
3960
+ normalizedProjectRoot,
3961
+ ...extraRoots.map((root) => normalizeScopePath(root, pathImpl))
3962
+ ]));
3963
+ return sourceDirs.some((dir) => {
3964
+ return rootsToTry.some((root) => {
3965
+ const normalizedAbsDir = normalizeScopePath(pathImpl.resolve(root, dir), pathImpl);
3966
+ if (isNormalizedPathWithinDir(normalizedAbsFilename, normalizedAbsDir, pathImpl)) {
3967
+ return true;
3968
+ }
3969
+ if (dir.startsWith("app/") && pathImpl.basename(root) === "app") {
3970
+ const relativeDir = dir.substring(4);
3971
+ const normalizedAbsDirAlt = normalizeScopePath(pathImpl.resolve(root, relativeDir), pathImpl);
3972
+ return isNormalizedPathWithinDir(normalizedAbsFilename, normalizedAbsDirAlt, pathImpl);
3973
+ }
3974
+ return false;
3975
+ });
3976
+ });
3977
+ }
3880
3978
  function matchesPrimarySelector(extraMethod, pom) {
3881
3979
  if (extraMethod.selector.kind !== "testId") {
3882
3980
  return false;
@@ -3945,6 +4043,56 @@ function buildPomManifest(componentHierarchyMap, elementMetadata) {
3945
4043
  }).filter((entry) => entry !== null);
3946
4044
  return Object.fromEntries(manifestEntries);
3947
4045
  }
4046
+ function normalizeTrackedComponentRef(value) {
4047
+ return value.endsWith(".vue") ? value.slice(0, -4) : value;
4048
+ }
4049
+ function resolveTrackedComponentRef(value, componentHierarchyMap) {
4050
+ const normalizedValue = normalizeTrackedComponentRef(value);
4051
+ if (componentHierarchyMap.has(value)) {
4052
+ return value;
4053
+ }
4054
+ if (componentHierarchyMap.has(normalizedValue)) {
4055
+ return normalizedValue;
4056
+ }
4057
+ let match = null;
4058
+ for (const [candidateName, candidateDeps] of componentHierarchyMap.entries()) {
4059
+ const normalizedCandidate = normalizeTrackedComponentRef(candidateName);
4060
+ const candidateBaseName = path.parse(candidateDeps.filePath).name;
4061
+ if (normalizedCandidate !== normalizedValue && candidateBaseName !== normalizedValue) {
4062
+ continue;
4063
+ }
4064
+ if (match && match !== candidateName) {
4065
+ return null;
4066
+ }
4067
+ match = candidateName;
4068
+ }
4069
+ return match;
4070
+ }
4071
+ function buildComponentGraph(componentHierarchyMap, routeMetaEntries, projectRoot) {
4072
+ const rootAbs = safeRealpath(path.resolve(projectRoot));
4073
+ const toProjectPath = (filePath) => toPosixSlashes(path.relative(rootAbs, safeRealpath(path.resolve(rootAbs, filePath))));
4074
+ const sortedUnique = (values) => Array.from(new Set(values)).sort((a, b) => a.localeCompare(b));
4075
+ const components = Array.from(componentHierarchyMap.entries(), ([name, dependencies]) => [toProjectPath(dependencies.filePath), {
4076
+ name,
4077
+ // Templates may use kebab-case tags; tags that are not project components (built-ins, libraries) drop out.
4078
+ uses: sortedUnique(Array.from(dependencies.usedComponentSet).flatMap((tag) => {
4079
+ const ref = resolveTrackedComponentRef(toPascalCase(tag), componentHierarchyMap);
4080
+ const used = ref ? componentHierarchyMap.get(ref) : void 0;
4081
+ return used ? [toProjectPath(used.filePath)] : [];
4082
+ }))
4083
+ }]).sort(([a], [b]) => a.localeCompare(b));
4084
+ const routes = routeMetaEntries.map((route) => {
4085
+ if (!route.componentFiles) {
4086
+ throw new Error(`[vue-pom-generator] Route "${route.path}" was introspected without its component files.`);
4087
+ }
4088
+ return { path: route.path, name: route.name, components: Array.from(new Set(route.componentFiles.map(toProjectPath))) };
4089
+ }).sort((a, b) => a.path.localeCompare(b.path) || (a.name ?? "").localeCompare(b.name ?? ""));
4090
+ return { version: 1, components: Object.fromEntries(components), routes };
4091
+ }
4092
+ function generateComponentGraphJson(componentHierarchyMap, routeMetaEntries, projectRoot) {
4093
+ return `${JSON.stringify(buildComponentGraph(componentHierarchyMap, routeMetaEntries, projectRoot), null, 2)}
4094
+ `;
4095
+ }
3948
4096
  function buildTestIdManifest(componentHierarchyMap) {
3949
4097
  return Object.fromEntries(
3950
4098
  Array.from(componentHierarchyMap.entries()).sort((a, b) => a[0].localeCompare(b[0])).map(([componentName, dependencies]) => {
@@ -4128,103 +4276,6 @@ function writeGeneratedOutputs(outDir, files, sharedFiles, projectRoot = path.di
4128
4276
  writeFile(manifestPath, `${JSON.stringify(next, null, 2)}
4129
4277
  `);
4130
4278
  }
4131
- function toPosixSlashes(value) {
4132
- let out = "";
4133
- for (let i = 0; i < value.length; i++) {
4134
- const ch = value[i];
4135
- out += ch === "\\" ? "/" : ch;
4136
- }
4137
- return out;
4138
- }
4139
- function safeRealpath(value) {
4140
- try {
4141
- if (fs.existsSync(value)) {
4142
- return fs.realpathSync(value);
4143
- }
4144
- } catch {
4145
- return value;
4146
- }
4147
- const parent = path.dirname(value);
4148
- if (!parent || parent === value) {
4149
- return value;
4150
- }
4151
- const resolvedParent = safeRealpath(parent);
4152
- return resolvedParent === parent ? value : path.join(resolvedParent, path.basename(value));
4153
- }
4154
- function normalizeScopePath(value, pathImpl = path) {
4155
- return pathImpl.normalize(value);
4156
- }
4157
- function isNormalizedPathWithinDir(filePathAbs, dirPathAbs, pathImpl = path) {
4158
- const normalizedFileAbs = normalizeScopePath(filePathAbs, pathImpl);
4159
- const normalizedDirAbs = normalizeScopePath(dirPathAbs, pathImpl);
4160
- return normalizedFileAbs === normalizedDirAbs || normalizedFileAbs.startsWith(`${normalizedDirAbs}${pathImpl.sep}`);
4161
- }
4162
- function isPathWithinDir(filePathAbs, dirPathAbs) {
4163
- const fileAbs = path.resolve(filePathAbs);
4164
- const dirAbs = path.resolve(dirPathAbs);
4165
- const rel = path.relative(dirAbs, fileAbs);
4166
- if (!rel)
4167
- return true;
4168
- return !rel.startsWith("..") && !path.isAbsolute(rel);
4169
- }
4170
- function resolveComponentNameFromPath(options) {
4171
- const { projectRoot, viewsDirAbs, sourceDirs, extraRoots = [] } = options;
4172
- const cleanFilename = options.filename.includes("?") ? options.filename.substring(0, options.filename.indexOf("?")) : options.filename;
4173
- const absFilename = path.isAbsolute(cleanFilename) ? cleanFilename : path.resolve(projectRoot, cleanFilename);
4174
- const normalizedAbsFilename = toPosixSlashes(path.normalize(safeRealpath(absFilename)));
4175
- const rootBases = [projectRoot, ...extraRoots.filter((r) => r !== projectRoot)];
4176
- const roots = [
4177
- viewsDirAbs,
4178
- ...sourceDirs.flatMap((dir) => path.isAbsolute(dir) ? [dir] : rootBases.map((base) => path.resolve(base, dir)))
4179
- ];
4180
- const potentialRoots = Array.from(new Set(roots.map((r) => toPosixSlashes(path.normalize(safeRealpath(r)))))).sort((a, b) => b.length - a.length);
4181
- for (const root of potentialRoots) {
4182
- if (normalizedAbsFilename.startsWith(`${root}/`) || normalizedAbsFilename === root) {
4183
- const rel = path.posix.relative(root, normalizedAbsFilename);
4184
- const parsed = path.posix.parse(rel);
4185
- const segments = path.posix.join(parsed.dir, parsed.name);
4186
- return toPascalCase(segments);
4187
- }
4188
- }
4189
- return toPascalCase(path.parse(normalizedAbsFilename).name);
4190
- }
4191
- function isFileInConfiguredSourceScope(options) {
4192
- const { filename, projectRoot, viewsDirAbs, sourceDirs, extraRoots = [], pathImpl = path } = options;
4193
- if (!filename) {
4194
- return false;
4195
- }
4196
- const cleanFilename = filename.includes("?") ? filename.substring(0, filename.indexOf("?")) : filename;
4197
- const normalizedProjectRoot = normalizeScopePath(projectRoot, pathImpl);
4198
- const normalizedAbsFilename = normalizeScopePath(
4199
- pathImpl.isAbsolute(cleanFilename) ? cleanFilename : pathImpl.resolve(normalizedProjectRoot, cleanFilename),
4200
- pathImpl
4201
- );
4202
- if (normalizedAbsFilename.includes(`${pathImpl.sep}node_modules${pathImpl.sep}`) || normalizedAbsFilename.includes("/node_modules/")) {
4203
- return false;
4204
- }
4205
- const normalizedViewsDirAbs = normalizeScopePath(viewsDirAbs, pathImpl);
4206
- if (isNormalizedPathWithinDir(normalizedAbsFilename, normalizedViewsDirAbs, pathImpl)) {
4207
- return true;
4208
- }
4209
- const rootsToTry = Array.from(/* @__PURE__ */ new Set([
4210
- normalizedProjectRoot,
4211
- ...extraRoots.map((root) => normalizeScopePath(root, pathImpl))
4212
- ]));
4213
- return sourceDirs.some((dir) => {
4214
- return rootsToTry.some((root) => {
4215
- const normalizedAbsDir = normalizeScopePath(pathImpl.resolve(root, dir), pathImpl);
4216
- if (isNormalizedPathWithinDir(normalizedAbsFilename, normalizedAbsDir, pathImpl)) {
4217
- return true;
4218
- }
4219
- if (dir.startsWith("app/") && pathImpl.basename(root) === "app") {
4220
- const relativeDir = dir.substring(4);
4221
- const normalizedAbsDirAlt = normalizeScopePath(pathImpl.resolve(root, relativeDir), pathImpl);
4222
- return isNormalizedPathWithinDir(normalizedAbsFilename, normalizedAbsDirAlt, pathImpl);
4223
- }
4224
- return false;
4225
- });
4226
- });
4227
- }
4228
4279
  let routerIntrospectionQueue = Promise.resolve();
4229
4280
  async function runRouterIntrospectionExclusive(fn) {
4230
4281
  const prev = routerIntrospectionQueue.catch(() => void 0);
@@ -4594,8 +4645,8 @@ function getComponentInfoFromVueComponent(comp, options = {}) {
4594
4645
  filePath
4595
4646
  };
4596
4647
  }
4597
- async function getComponentInfoFromRouteRecord(record, options = {}) {
4598
- const comp = record.components?.default;
4648
+ async function getComponentInfoFromRouteComponent(routeComponent, options = {}) {
4649
+ const comp = routeComponent;
4599
4650
  if (!comp) {
4600
4651
  return {
4601
4652
  componentName: null,
@@ -4621,6 +4672,39 @@ async function getComponentInfoFromRouteRecord(record, options = {}) {
4621
4672
  }
4622
4673
  return getComponentInfoFromVueComponent(comp, options);
4623
4674
  }
4675
+ function isRouteParamNameCode(code) {
4676
+ return code === 95 || isAsciiLetterCode$1(code) || isAsciiDigitCode$1(code);
4677
+ }
4678
+ function getPathParamNames(routePath) {
4679
+ const names = [];
4680
+ for (let start = routePath.indexOf(":"); start !== -1; start = routePath.indexOf(":", start + 1)) {
4681
+ let end = start + 1;
4682
+ while (end < routePath.length && isRouteParamNameCode(routePath.charCodeAt(end)))
4683
+ end++;
4684
+ if (end > start + 1)
4685
+ names.push(routePath.slice(start + 1, end));
4686
+ }
4687
+ return names;
4688
+ }
4689
+ function getRenderedRouteRecords(router, record) {
4690
+ const matched = record.name === void 0 ? router.resolve(record.path).matched : router.resolve({ name: record.name, params: Object.fromEntries(getPathParamNames(record.path).map((name) => [name, name])) }).matched;
4691
+ const index = matched.findIndex((candidate) => candidate === record || candidate === record.aliasOf);
4692
+ if (index === -1) {
4693
+ throw new Error(`[vue-pom-generator] Cannot resolve the parent routes of unnamed route "${record.path}". Give it a name so the components it renders can be listed.`);
4694
+ }
4695
+ return matched.slice(0, index + 1);
4696
+ }
4697
+ async function getRenderedComponentFiles(router, record, rootDir) {
4698
+ const files = [];
4699
+ for (const rendered of getRenderedRouteRecords(router, record)) {
4700
+ for (const routeComponent of Object.values(rendered.components ?? {})) {
4701
+ const { filePath } = await getComponentInfoFromRouteComponent(routeComponent, { rootDir });
4702
+ if (filePath && !files.includes(filePath))
4703
+ files.push(filePath);
4704
+ }
4705
+ }
4706
+ return files;
4707
+ }
4624
4708
  function resolveIntrospectedComponentName(componentInfo, componentNaming) {
4625
4709
  if (componentInfo.filePath && componentNaming) {
4626
4710
  return resolveComponentNameFromPath({
@@ -5051,9 +5135,11 @@ async function introspectNuxtPages(projectRoot, options = {}) {
5051
5135
  // Nuxt file-based routes are named by convention, but the static walk does not
5052
5136
  // recover those names — leave null so callers fall back to path-template navigation.
5053
5137
  name: null,
5138
+ path: pathTemplate,
5054
5139
  pathTemplate,
5055
5140
  params,
5056
- query: []
5141
+ query: [],
5142
+ ...options.collectComponentFiles ? { componentFiles: [fullPath] } : {}
5057
5143
  });
5058
5144
  }
5059
5145
  };
@@ -5127,7 +5213,7 @@ async function parseRouterFileFromCwd(routerEntryPath, options = {}) {
5127
5213
  const routePathMap = /* @__PURE__ */ new Map();
5128
5214
  const routeMetaEntries = [];
5129
5215
  for (const r of router.getRoutes()) {
5130
- const componentInfo = await getComponentInfoFromRouteRecord(r, { rootDir: cwd });
5216
+ const componentInfo = await getComponentInfoFromRouteComponent(r.components?.default, { rootDir: cwd });
5131
5217
  const componentName = resolveIntrospectedComponentName(componentInfo, options.componentNaming);
5132
5218
  if (!componentName)
5133
5219
  continue;
@@ -5145,9 +5231,11 @@ async function parseRouterFileFromCwd(routerEntryPath, options = {}) {
5145
5231
  routeMetaEntries.push({
5146
5232
  componentName,
5147
5233
  name: typeof r.name === "string" && r.name.length ? r.name : null,
5234
+ path: r.path,
5148
5235
  pathTemplate,
5149
5236
  params: paramsMeta,
5150
- query: queryKeys
5237
+ query: queryKeys,
5238
+ ...options.collectComponentFiles ? { componentFiles: await getRenderedComponentFiles(router, r, cwd) } : {}
5151
5239
  });
5152
5240
  }
5153
5241
  }
@@ -5545,7 +5633,7 @@ function resolveVueSourcePath(targetClassName, vueFilesPathMap, projectRoot) {
5545
5633
  ].filter((candidate) => typeof candidate === "string" && candidate.length > 0);
5546
5634
  return candidates.find((candidate) => fs.existsSync(candidate));
5547
5635
  }
5548
- async function getRouteMetaByComponent(projectRoot, routerEntry, routerType, options = {}) {
5636
+ async function introspectRouteMetaEntries(projectRoot, routerEntry, routerType, options = {}) {
5549
5637
  const root = projectRoot ?? process.cwd();
5550
5638
  const pageDirs = options.pageDirs?.length ? options.pageDirs : ["src/views"];
5551
5639
  const pageDirsAbs = pageDirs.map((dir) => path.isAbsolute(dir) ? dir : path.resolve(root, dir));
@@ -5556,14 +5644,18 @@ async function getRouteMetaByComponent(projectRoot, routerEntry, routerType, opt
5556
5644
  ...options.layoutDirs?.length ? options.layoutDirs : ["src/layouts"]
5557
5645
  ];
5558
5646
  const extraRoots = process.cwd() !== root ? [process.cwd()] : [];
5559
- const { routeMetaEntries } = routerType === "nuxt" ? await introspectNuxtPages(root, { pageDirs: pageDirsAbs }) : await parseRouterFileFromCwd(resolveRouterEntry(root, routerEntry), {
5647
+ const { routeMetaEntries } = routerType === "nuxt" ? await introspectNuxtPages(root, { pageDirs: pageDirsAbs, collectComponentFiles: options.collectComponentFiles }) : await parseRouterFileFromCwd(resolveRouterEntry(root, routerEntry), {
5560
5648
  componentNaming: {
5561
5649
  projectRoot: root,
5562
5650
  viewsDirAbs: primaryPageDirAbs,
5563
5651
  sourceDirs,
5564
5652
  extraRoots
5565
- }
5653
+ },
5654
+ collectComponentFiles: options.collectComponentFiles
5566
5655
  });
5656
+ return routeMetaEntries;
5657
+ }
5658
+ function buildRouteMetaByComponent(routeMetaEntries) {
5567
5659
  const map = /* @__PURE__ */ new Map();
5568
5660
  for (const entry of routeMetaEntries) {
5569
5661
  const list = map.get(entry.componentName) ?? [];
@@ -5905,6 +5997,7 @@ async function generateFiles(componentHierarchyMap, vueFilesPathMap, basePageCla
5905
5997
  customPomImportAliases,
5906
5998
  customPomImportNameCollisionBehavior = "error",
5907
5999
  customPomFixtures = [],
6000
+ componentGraph = false,
5908
6001
  testIdAttribute,
5909
6002
  emitLanguages: emitLanguagesOverride,
5910
6003
  typescriptOutputStructure = "aggregated",
@@ -5926,11 +6019,13 @@ async function generateFiles(componentHierarchyMap, vueFilesPathMap, basePageCla
5926
6019
  if (vueTestUtilsOutDir && path.resolve(vueTestUtilsOutDir) === path.resolve(outDir)) {
5927
6020
  throw new Error("[vue-pom-generator] generation.vueTestUtils.outDir must differ from generation.outDir.");
5928
6021
  }
5929
- const routeMetaByComponent = routeMetaByComponentOverride ?? (vueRouterFluentChaining ? await getRouteMetaByComponent(projectRoot, routerEntry, routerType, {
6022
+ const routeMetaEntries = vueRouterFluentChaining && (!routeMetaByComponentOverride || componentGraph) ? await introspectRouteMetaEntries(projectRoot, routerEntry, routerType, {
5930
6023
  pageDirs,
5931
6024
  componentDirs,
5932
- layoutDirs
5933
- }) : void 0);
6025
+ layoutDirs,
6026
+ collectComponentFiles: componentGraph
6027
+ }) : [];
6028
+ const routeMetaByComponent = routeMetaByComponentOverride ?? (vueRouterFluentChaining ? buildRouteMetaByComponent(routeMetaEntries) : void 0);
5934
6029
  const emittableComponentHierarchyMap = componentHierarchyMap;
5935
6030
  const generatedFiles = [];
5936
6031
  if (emitLanguages.includes("ts")) {
@@ -5965,6 +6060,7 @@ async function generateFiles(componentHierarchyMap, vueFilesPathMap, basePageCla
5965
6060
  projectRoot,
5966
6061
  customPomDir,
5967
6062
  customPomFixtures,
6063
+ componentGraphRoutes: componentGraph ? routeMetaEntries : void 0,
5968
6064
  elementMetadata,
5969
6065
  testIdAttribute
5970
6066
  });
@@ -6677,13 +6773,18 @@ function generateAggregatedCSharpFiles(componentHierarchyMap, outDir, options =
6677
6773
  return [{ filePath: outputFile, content: chunks.join("\n") }];
6678
6774
  }
6679
6775
  function maybeGenerateFixtureRegistry(componentHierarchyMap, options) {
6680
- const { generateFixtures, pomOutDir, customPomFixtures } = options;
6776
+ const { generateFixtures, pomOutDir, customPomFixtures, componentGraphRoutes } = options;
6681
6777
  if (!generateFixtures) {
6682
6778
  if (customPomFixtures.length > 0) {
6683
6779
  throw new VuePomGeneratorError(
6684
6780
  "generation.playwright.customPoms.fixtures requires generation.playwright.fixtures to be enabled."
6685
6781
  );
6686
6782
  }
6783
+ if (componentGraphRoutes) {
6784
+ throw new VuePomGeneratorError(
6785
+ "generation.playwright.componentGraph requires generation.playwright.fixtures to be enabled."
6786
+ );
6787
+ }
6687
6788
  return [];
6688
6789
  }
6689
6790
  const defaultFixtureOutDirRel = pomOutDir;
@@ -7041,6 +7142,10 @@ Rename the class or remove it from generation.playwright.customPoms.fixtures.`
7041
7142
  filePath: path.resolve(fixtureOutDirAbs, manifestFileName),
7042
7143
  content: manifestContent
7043
7144
  },
7145
+ ...componentGraphRoutes ? [{
7146
+ filePath: path.resolve(fixtureOutDirAbs, "component-graph.json"),
7147
+ content: generateComponentGraphJson(componentHierarchyMap, componentGraphRoutes, root)
7148
+ }] : [],
7044
7149
  diagnosticsRuntimeFile
7045
7150
  ];
7046
7151
  }
@@ -7050,33 +7155,8 @@ function prepareViewObjectModelClass(componentName, dependencies, componentHiera
7050
7155
  customPomAttachments = [],
7051
7156
  testIdAttribute
7052
7157
  } = options;
7053
- const normalizeTrackedComponentRef = (value) => {
7054
- return value.endsWith(".vue") ? value.slice(0, -4) : value;
7055
- };
7056
- const resolveTrackedComponentRef = (value) => {
7057
- const normalizedValue = normalizeTrackedComponentRef(value);
7058
- if (componentHierarchyMap.has(value)) {
7059
- return value;
7060
- }
7061
- if (componentHierarchyMap.has(normalizedValue)) {
7062
- return normalizedValue;
7063
- }
7064
- let match = null;
7065
- for (const [candidateName, candidateDeps] of componentHierarchyMap.entries()) {
7066
- const normalizedCandidate = normalizeTrackedComponentRef(candidateName);
7067
- const candidateBaseName = path.parse(candidateDeps.filePath).name;
7068
- if (normalizedCandidate !== normalizedValue && candidateBaseName !== normalizedValue) {
7069
- continue;
7070
- }
7071
- if (match && match !== candidateName) {
7072
- return null;
7073
- }
7074
- match = candidateName;
7075
- }
7076
- return match;
7077
- };
7078
7158
  const hasGeneratedPomSurface = (value, seen = /* @__PURE__ */ new Set()) => {
7079
- const resolvedRef = resolveTrackedComponentRef(value);
7159
+ const resolvedRef = resolveTrackedComponentRef(value, componentHierarchyMap);
7080
7160
  if (!resolvedRef || seen.has(resolvedRef)) {
7081
7161
  return false;
7082
7162
  }
@@ -7097,7 +7177,7 @@ function prepareViewObjectModelClass(componentName, dependencies, componentHiera
7097
7177
  return toPascalCaseLocal(normalizeTrackedComponentRef(ref)) === ownClassName && ownClassName.length > 0;
7098
7178
  };
7099
7179
  const resolveComponentInstance = (spec) => {
7100
- const componentRef = resolveTrackedComponentRef(spec.componentName);
7180
+ const componentRef = resolveTrackedComponentRef(spec.componentName, componentHierarchyMap);
7101
7181
  if (!componentRef || isSelfReference(componentRef) || !hasGeneratedPomSurface(componentRef, /* @__PURE__ */ new Set([componentName]))) {
7102
7182
  return null;
7103
7183
  }
@@ -7206,7 +7286,7 @@ Move the repetition to the receiving component boundary so the generator can exp
7206
7286
  const hasChildComponent = (needle) => {
7207
7287
  const normalizedNeedle = normalizeTrackedComponentRef(needle);
7208
7288
  for (const child of rawComponentRefsForInstances) {
7209
- const resolvedChild = resolveTrackedComponentRef(child);
7289
+ const resolvedChild = resolveTrackedComponentRef(child, componentHierarchyMap);
7210
7290
  if (normalizeTrackedComponentRef(child) === normalizedNeedle)
7211
7291
  return true;
7212
7292
  if (resolvedChild && normalizeTrackedComponentRef(resolvedChild) === normalizedNeedle)
@@ -8195,6 +8275,7 @@ function createBuildProcessorPlugin(options) {
8195
8275
  customPomImportAliases,
8196
8276
  customPomImportNameCollisionBehavior,
8197
8277
  customPomFixtures,
8278
+ componentGraph,
8198
8279
  testIdAttribute,
8199
8280
  routerAwarePoms,
8200
8281
  routerType,
@@ -8346,6 +8427,7 @@ function createBuildProcessorPlugin(options) {
8346
8427
  customPomImportAliases,
8347
8428
  customPomImportNameCollisionBehavior,
8348
8429
  customPomFixtures,
8430
+ componentGraph,
8349
8431
  testIdAttribute,
8350
8432
  vueRouterFluentChaining: routerAwarePoms,
8351
8433
  routerEntry: getResolvedRouterEntry(),
@@ -10727,6 +10809,7 @@ function createDevProcessorPlugin(options) {
10727
10809
  customPomImportAliases,
10728
10810
  customPomImportNameCollisionBehavior,
10729
10811
  customPomFixtures,
10812
+ componentGraph,
10730
10813
  nameCollisionBehavior,
10731
10814
  missingSemanticNameBehavior,
10732
10815
  existingIdBehavior,
@@ -10990,6 +11073,7 @@ function createDevProcessorPlugin(options) {
10990
11073
  customPomImportAliases,
10991
11074
  customPomImportNameCollisionBehavior,
10992
11075
  customPomFixtures,
11076
+ componentGraph,
10993
11077
  pageDirs: getPageDirs(),
10994
11078
  componentDirs: getComponentDirs(),
10995
11079
  layoutDirs: getLayoutDirs(),
@@ -11640,6 +11724,7 @@ function createGeneratorPlugins(options, generationOnly, projectRoot = process.c
11640
11724
  customPomImportAliases: resolvedCustomPomImportAliases,
11641
11725
  customPomImportNameCollisionBehavior: customPoms?.importNameCollisionBehavior,
11642
11726
  customPomFixtures: resolvedCustomPomFixtures,
11727
+ componentGraph: generationOptions?.playwright?.componentGraph,
11643
11728
  nameCollisionBehavior: generationOptions?.nameCollisionBehavior,
11644
11729
  missingSemanticNameBehavior: generationOptions?.missingSemanticNameBehavior,
11645
11730
  existingIdBehavior: resolvedInjectionOptions.existingIdBehavior,