@immense/vue-pom-generator 1.0.120 → 1.0.122
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 +20 -0
- package/RELEASE_NOTES.md +27 -28
- package/class-generation/base-page.ts +2 -0
- package/class-generation/pointer.ts +101 -4
- package/dist/class-generation/base-page.d.ts +2 -0
- package/dist/class-generation/base-page.d.ts.map +1 -1
- package/dist/class-generation/pointer.d.ts +55 -1
- package/dist/class-generation/pointer.d.ts.map +1 -1
- package/dist/index.cjs +71 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +71 -23
- package/dist/index.mjs.map +1 -1
- package/dist/playwright/runtime.cjs +20 -4
- package/dist/playwright/runtime.cjs.map +1 -1
- package/dist/playwright/runtime.mjs +20 -4
- package/dist/playwright/runtime.mjs.map +1 -1
- package/dist/plugin/internal-plugins.d.ts.map +1 -1
- package/dist/plugin/runtime/annotator/plugin.d.ts +15 -0
- package/dist/plugin/runtime/annotator/plugin.d.ts.map +1 -1
- package/dist/tests/annotator-sources.test.d.ts +2 -0
- package/dist/tests/annotator-sources.test.d.ts.map +1 -0
- package/package.json +1 -1
- package/plugin/runtime/annotator/plugin.ts +69 -1
package/dist/index.cjs
CHANGED
|
@@ -24,7 +24,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
25
25
|
const fs = require("node:fs");
|
|
26
26
|
const path = require("node:path");
|
|
27
|
-
const process = require("node:process");
|
|
27
|
+
const process$1 = require("node:process");
|
|
28
28
|
const node_module = require("node:module");
|
|
29
29
|
const node_url = require("node:url");
|
|
30
30
|
const parser = require("@babel/parser");
|
|
@@ -181,7 +181,7 @@ function normalizeNuxtComponentDirs(value, baseDir, context) {
|
|
|
181
181
|
}
|
|
182
182
|
return normalizeNuxtComponentDirs(value.dirs, baseDir, context);
|
|
183
183
|
}
|
|
184
|
-
function resolveNuxtProjectDiscovery(nuxtOptions, getLayerDirectories, cwd = process.cwd()) {
|
|
184
|
+
function resolveNuxtProjectDiscovery(nuxtOptions, getLayerDirectories, cwd = process$1.cwd()) {
|
|
185
185
|
const rootDir = path.resolve(nuxtOptions.rootDir ?? cwd);
|
|
186
186
|
const srcDir = path.resolve(nuxtOptions.srcDir ?? rootDir);
|
|
187
187
|
const fallbackLayer = {
|
|
@@ -229,7 +229,7 @@ function resolveNuxtProjectDiscovery(nuxtOptions, getLayerDirectories, cwd = pro
|
|
|
229
229
|
wrapperSearchRoots: []
|
|
230
230
|
};
|
|
231
231
|
}
|
|
232
|
-
async function loadNuxtProjectDiscovery(cwd = process.cwd()) {
|
|
232
|
+
async function loadNuxtProjectDiscovery(cwd = process$1.cwd()) {
|
|
233
233
|
let loadNuxtConfig;
|
|
234
234
|
let getLayerDirectories;
|
|
235
235
|
try {
|
|
@@ -4333,7 +4333,7 @@ async function runRouterIntrospectionExclusive(fn) {
|
|
|
4333
4333
|
}
|
|
4334
4334
|
}
|
|
4335
4335
|
function debugLog(message) {
|
|
4336
|
-
if (process.env.VUE_TESTID_DEBUG === "1") {
|
|
4336
|
+
if (process$1.env.VUE_TESTID_DEBUG === "1") {
|
|
4337
4337
|
console.log(`[vue-pom-generator][router-introspection] ${message}`);
|
|
4338
4338
|
}
|
|
4339
4339
|
}
|
|
@@ -5158,7 +5158,7 @@ async function introspectNuxtPages(projectRoot, options = {}) {
|
|
|
5158
5158
|
projectRoot,
|
|
5159
5159
|
viewsDirAbs: pagesDir,
|
|
5160
5160
|
sourceDirs: [pagesDir],
|
|
5161
|
-
extraRoots: [process.cwd()]
|
|
5161
|
+
extraRoots: [process$1.cwd()]
|
|
5162
5162
|
});
|
|
5163
5163
|
const relativePath = path.relative(pagesDir, fullPath);
|
|
5164
5164
|
const parsed = path.parse(relativePath);
|
|
@@ -5592,7 +5592,7 @@ function resolveRouterEntry(projectRoot, routerEntry) {
|
|
|
5592
5592
|
if (!routerEntry) {
|
|
5593
5593
|
throw new Error("[vue-pom-generator] Router entry path is required when routerAwarePoms is enabled.");
|
|
5594
5594
|
}
|
|
5595
|
-
const root = projectRoot ?? process.cwd();
|
|
5595
|
+
const root = projectRoot ?? process$1.cwd();
|
|
5596
5596
|
return path.isAbsolute(routerEntry) ? routerEntry : path.resolve(root, routerEntry);
|
|
5597
5597
|
}
|
|
5598
5598
|
function createMissingCustomPomDirectoryError(configuredDir, resolvedDir) {
|
|
@@ -5675,7 +5675,7 @@ function resolveVueSourcePath(targetClassName, vueFilesPathMap, projectRoot) {
|
|
|
5675
5675
|
return candidates.find((candidate) => fs.existsSync(candidate));
|
|
5676
5676
|
}
|
|
5677
5677
|
async function introspectRouteMetaEntries(projectRoot, routerEntry, routerType, options = {}) {
|
|
5678
|
-
const root = projectRoot ?? process.cwd();
|
|
5678
|
+
const root = projectRoot ?? process$1.cwd();
|
|
5679
5679
|
const pageDirs = options.pageDirs?.length ? options.pageDirs : ["src/views"];
|
|
5680
5680
|
const pageDirsAbs = pageDirs.map((dir) => path.isAbsolute(dir) ? dir : path.resolve(root, dir));
|
|
5681
5681
|
const primaryPageDirAbs = pageDirsAbs[0] ?? path.resolve(root, "src/views");
|
|
@@ -5684,7 +5684,7 @@ async function introspectRouteMetaEntries(projectRoot, routerEntry, routerType,
|
|
|
5684
5684
|
...options.componentDirs?.length ? options.componentDirs : ["src/components"],
|
|
5685
5685
|
...options.layoutDirs?.length ? options.layoutDirs : ["src/layouts"]
|
|
5686
5686
|
];
|
|
5687
|
-
const extraRoots = process.cwd() !== root ? [process.cwd()] : [];
|
|
5687
|
+
const extraRoots = process$1.cwd() !== root ? [process$1.cwd()] : [];
|
|
5688
5688
|
const { routeMetaEntries } = routerType === "nuxt" ? await introspectNuxtPages(root, { pageDirs: pageDirsAbs, collectComponentFiles: options.collectComponentFiles }) : await parseRouterFileFromCwd(resolveRouterEntry(root, routerEntry), {
|
|
5689
5689
|
componentNaming: {
|
|
5690
5690
|
projectRoot: root,
|
|
@@ -6054,7 +6054,7 @@ async function generateFiles(componentHierarchyMap, vueFilesPathMap, basePageCla
|
|
|
6054
6054
|
renderCache
|
|
6055
6055
|
} = options;
|
|
6056
6056
|
const emitLanguages = emitLanguagesOverride?.length ? emitLanguagesOverride : ["ts"];
|
|
6057
|
-
const root = projectRoot ?? process.cwd();
|
|
6057
|
+
const root = projectRoot ?? process$1.cwd();
|
|
6058
6058
|
const outDir = path.resolve(root, outDirOverride ?? "./pom");
|
|
6059
6059
|
const vueTestUtilsOutDir = vueTestUtilsOutDirOverride ? path.resolve(root, vueTestUtilsOutDirOverride) : void 0;
|
|
6060
6060
|
if (vueTestUtilsOutDir && path.resolve(vueTestUtilsOutDir) === path.resolve(outDir)) {
|
|
@@ -6351,7 +6351,7 @@ function generateVueTestUtilsFiles(componentHierarchyMap, outDir, options = {})
|
|
|
6351
6351
|
];
|
|
6352
6352
|
}
|
|
6353
6353
|
async function generateSplitTypeScriptFiles(componentHierarchyMap, vueFilesPathMap, basePageClassPath, outDir, options = {}) {
|
|
6354
|
-
const projectRoot = options.projectRoot ?? process.cwd();
|
|
6354
|
+
const projectRoot = options.projectRoot ?? process$1.cwd();
|
|
6355
6355
|
const entries = Array.from(componentHierarchyMap.entries()).sort((a, b) => a[0].localeCompare(b[0]));
|
|
6356
6356
|
const base = ensureDir(outDir);
|
|
6357
6357
|
const generatedClassNames = new Set(entries.map(([name]) => name));
|
|
@@ -6833,7 +6833,7 @@ function maybeGenerateFixtureRegistry(componentHierarchyMap, options) {
|
|
|
6833
6833
|
const looksLikeFilePath = fixtureOutRel.endsWith(".ts") || fixtureOutRel.endsWith(".tsx") || fixtureOutRel.endsWith(".mts") || fixtureOutRel.endsWith(".cts");
|
|
6834
6834
|
const fixtureOutDirRel = looksLikeFilePath ? path.dirname(fixtureOutRel) : fixtureOutRel;
|
|
6835
6835
|
const fixtureFileName = looksLikeFilePath ? path.basename(fixtureOutRel) : "fixtures.g.ts";
|
|
6836
|
-
const root = options.projectRoot ?? process.cwd();
|
|
6836
|
+
const root = options.projectRoot ?? process$1.cwd();
|
|
6837
6837
|
const fixtureOutDirAbs = path.isAbsolute(fixtureOutDirRel) ? fixtureOutDirRel : path.resolve(root, fixtureOutDirRel);
|
|
6838
6838
|
const customPomDirRel = options.customPomDir ?? "tests/playwright/pom/custom";
|
|
6839
6839
|
const customPomDirAbs = path.isAbsolute(customPomDirRel) ? customPomDirRel : path.resolve(root, customPomDirRel);
|
|
@@ -7435,7 +7435,7 @@ function generateViewObjectModelContent(componentName, dependencies, componentHi
|
|
|
7435
7435
|
const sourceRel = toPosixRelativePath(outputDir, filePath);
|
|
7436
7436
|
const kind = prepared.isView ? "Page" : "Component";
|
|
7437
7437
|
const doc = `/** ${kind} POM: ${componentName} (source: ${sourceRel}) */`;
|
|
7438
|
-
const projectRoot = options.projectRoot ?? process.cwd();
|
|
7438
|
+
const projectRoot = options.projectRoot ?? process$1.cwd();
|
|
7439
7439
|
const fromAbs = path.isAbsolute(outputDir) ? outputDir : path.resolve(projectRoot, outputDir);
|
|
7440
7440
|
const toAbs = basePageClassPath ? path.isAbsolute(basePageClassPath) ? basePageClassPath : path.resolve(projectRoot, basePageClassPath) : "";
|
|
7441
7441
|
const basePageImport = path.relative(fromAbs, toAbs).replace(/\\/g, "/");
|
|
@@ -7961,7 +7961,7 @@ function getComposedStubBody(targetClassName, availableClassNames, depsByClassNa
|
|
|
7961
7961
|
};
|
|
7962
7962
|
}
|
|
7963
7963
|
async function generateAggregatedFiles(componentHierarchyMap, vueFilesPathMap, basePageClassPath, outDir, options = {}) {
|
|
7964
|
-
const projectRoot = options.projectRoot ?? process.cwd();
|
|
7964
|
+
const projectRoot = options.projectRoot ?? process$1.cwd();
|
|
7965
7965
|
const entries = Array.from(componentHierarchyMap.entries()).sort((a, b) => a[0].localeCompare(b[0]));
|
|
7966
7966
|
const views = entries.filter(([, d]) => d.isView);
|
|
7967
7967
|
const components = entries.filter(([, d]) => !d.isView);
|
|
@@ -8365,7 +8365,7 @@ function createBuildProcessorPlugin(options) {
|
|
|
8365
8365
|
projectRoot: projectRootRef.current,
|
|
8366
8366
|
viewsDirAbs: getViewsDirAbs(),
|
|
8367
8367
|
sourceDirs: getSourceDirs(),
|
|
8368
|
-
extraRoots: [process.cwd()]
|
|
8368
|
+
extraRoots: [process$1.cwd()]
|
|
8369
8369
|
});
|
|
8370
8370
|
if (componentHierarchyMap.has(componentName))
|
|
8371
8371
|
continue;
|
|
@@ -8608,7 +8608,7 @@ ${buildSearchRootsKey(normalizedSearchRoots)}`;
|
|
|
8608
8608
|
}
|
|
8609
8609
|
const candidateNames = [`${tag}.vue`, `${toKebabCaseTag(tag)}.vue`];
|
|
8610
8610
|
const directCandidates = [
|
|
8611
|
-
registeredPath ? path.resolve(process.cwd(), registeredPath) : null,
|
|
8611
|
+
registeredPath ? path.resolve(process$1.cwd(), registeredPath) : null,
|
|
8612
8612
|
...normalizedSearchRoots.flatMap((root) => candidateNames.map((fileName) => path.join(root, fileName)))
|
|
8613
8613
|
].filter((value) => !!value);
|
|
8614
8614
|
const directMatch = directCandidates.find((candidatePath) => fs.existsSync(candidatePath));
|
|
@@ -10577,7 +10577,7 @@ function createVuePluginWithTestIds(options) {
|
|
|
10577
10577
|
projectRoot: getProjectRoot(),
|
|
10578
10578
|
viewsDirAbs: getViewsDirAbs(),
|
|
10579
10579
|
sourceDirs: getSourceDirs(),
|
|
10580
|
-
extraRoots: [process.cwd()]
|
|
10580
|
+
extraRoots: [process$1.cwd()]
|
|
10581
10581
|
});
|
|
10582
10582
|
};
|
|
10583
10583
|
const isFileInScope = (filename) => {
|
|
@@ -10590,7 +10590,7 @@ function createVuePluginWithTestIds(options) {
|
|
|
10590
10590
|
projectRoot,
|
|
10591
10591
|
viewsDirAbs: getViewsDirAbs(),
|
|
10592
10592
|
sourceDirs: getSourceDirs(),
|
|
10593
|
-
extraRoots: [process.cwd()]
|
|
10593
|
+
extraRoots: [process$1.cwd()]
|
|
10594
10594
|
});
|
|
10595
10595
|
if (cleanPath.endsWith(".vue") && !matched) {
|
|
10596
10596
|
const absFilename = path.normalize(path.isAbsolute(cleanPath) ? cleanPath : path.resolve(projectRoot, cleanPath));
|
|
@@ -10862,7 +10862,7 @@ function createDevProcessorPlugin(options) {
|
|
|
10862
10862
|
let scheduleVueFileRegen = null;
|
|
10863
10863
|
const getProjectRootCandidates = () => Array.from(/* @__PURE__ */ new Set([
|
|
10864
10864
|
path.resolve(projectRootRef.current),
|
|
10865
|
-
path.resolve(process.cwd())
|
|
10865
|
+
path.resolve(process$1.cwd())
|
|
10866
10866
|
]));
|
|
10867
10867
|
const resolveProjectPath = (maybePath) => {
|
|
10868
10868
|
if (path.isAbsolute(maybePath))
|
|
@@ -10914,7 +10914,7 @@ function createDevProcessorPlugin(options) {
|
|
|
10914
10914
|
projectRoot: projectRootRef.current,
|
|
10915
10915
|
viewsDirAbs: getViewsDirAbs(),
|
|
10916
10916
|
sourceDirs: getSourceDirs(),
|
|
10917
|
-
extraRoots: [process.cwd()]
|
|
10917
|
+
extraRoots: [process$1.cwd()]
|
|
10918
10918
|
}
|
|
10919
10919
|
});
|
|
10920
10920
|
}
|
|
@@ -11008,7 +11008,7 @@ function createDevProcessorPlugin(options) {
|
|
|
11008
11008
|
projectRoot: projectRootRef.current,
|
|
11009
11009
|
viewsDirAbs: getViewsDirAbs(),
|
|
11010
11010
|
sourceDirs: getSourceDirs(),
|
|
11011
|
-
extraRoots: [process.cwd()]
|
|
11011
|
+
extraRoots: [process$1.cwd()]
|
|
11012
11012
|
});
|
|
11013
11013
|
filePathToComponentName.set(normalized, name);
|
|
11014
11014
|
return name;
|
|
@@ -11397,6 +11397,51 @@ ${code}`,
|
|
|
11397
11397
|
}
|
|
11398
11398
|
};
|
|
11399
11399
|
}
|
|
11400
|
+
function findExportedComponent(code) {
|
|
11401
|
+
const program = parser.parse(code, { sourceType: "module", plugins: ["typescript", "jsx"] }).program;
|
|
11402
|
+
const exported = program.body.find((node) => node.type === "ExportDefaultDeclaration");
|
|
11403
|
+
if (!exported) {
|
|
11404
|
+
return void 0;
|
|
11405
|
+
}
|
|
11406
|
+
const declaration = exported.declaration;
|
|
11407
|
+
if (declaration.type === "Identifier") {
|
|
11408
|
+
return declaration.name;
|
|
11409
|
+
}
|
|
11410
|
+
if (declaration.type === "CallExpression" && declaration.arguments[0]?.type === "Identifier") {
|
|
11411
|
+
return declaration.arguments[0].name;
|
|
11412
|
+
}
|
|
11413
|
+
return void 0;
|
|
11414
|
+
}
|
|
11415
|
+
function addComponentSourcePath(code, file) {
|
|
11416
|
+
const component = findExportedComponent(code);
|
|
11417
|
+
return component ? `${code}
|
|
11418
|
+
${component}.__file = ${JSON.stringify(file)};
|
|
11419
|
+
` : void 0;
|
|
11420
|
+
}
|
|
11421
|
+
function createAnnotatorSourcePlugin(options) {
|
|
11422
|
+
let root = process.cwd();
|
|
11423
|
+
return {
|
|
11424
|
+
name: "vue-pom-generator:annotator-sources",
|
|
11425
|
+
enforce: "post",
|
|
11426
|
+
// Client builds only: a server render has no annotator to read the links or paths.
|
|
11427
|
+
apply(config, { command }) {
|
|
11428
|
+
return command === "build" && !config.build?.ssr;
|
|
11429
|
+
},
|
|
11430
|
+
config() {
|
|
11431
|
+
return options.enabled ? { define: { __VUE_PROD_DEVTOOLS__: true } } : void 0;
|
|
11432
|
+
},
|
|
11433
|
+
configResolved(config) {
|
|
11434
|
+
root = config.root;
|
|
11435
|
+
},
|
|
11436
|
+
transform(code, id, transformOptions) {
|
|
11437
|
+
if (!options.enabled || transformOptions?.ssr || !id.endsWith(".vue")) {
|
|
11438
|
+
return null;
|
|
11439
|
+
}
|
|
11440
|
+
const updated = addComponentSourcePath(code, normalizePathSeparators(path.relative(root, id)));
|
|
11441
|
+
return updated === void 0 ? null : { code: updated, map: null };
|
|
11442
|
+
}
|
|
11443
|
+
};
|
|
11444
|
+
}
|
|
11400
11445
|
function createInternalPlugins(options) {
|
|
11401
11446
|
const {
|
|
11402
11447
|
componentHierarchyMap,
|
|
@@ -11485,7 +11530,10 @@ function createInternalPlugins(options) {
|
|
|
11485
11530
|
sourceAttribute: annotatorRuntime.sourceAttribute,
|
|
11486
11531
|
metadataAttributePrefix: annotatorRuntime.metadataAttributePrefix
|
|
11487
11532
|
});
|
|
11488
|
-
|
|
11533
|
+
const annotatorSourcePlugin = createAnnotatorSourcePlugin({
|
|
11534
|
+
enabled: annotatorRuntime.enabled && annotatorRuntime.ui.enabled
|
|
11535
|
+
});
|
|
11536
|
+
return [tsProcessor, devProcessor, virtualModules, annotatorUiPlugin, annotatorSourcePlugin];
|
|
11489
11537
|
}
|
|
11490
11538
|
const nuxtConfigMarker$1 = /* @__PURE__ */ Symbol.for("@immense/vue-pom-generator.nuxt");
|
|
11491
11539
|
const nuxtConfigFileNames = [
|
|
@@ -11693,7 +11741,7 @@ function assertNotVitePluginInstance(options) {
|
|
|
11693
11741
|
function createVuePomGeneratorPlugins(options = {}) {
|
|
11694
11742
|
return createGeneratorPlugins(options, false);
|
|
11695
11743
|
}
|
|
11696
|
-
function createGeneratorPlugins(options, generationOnly, projectRoot = process.cwd()) {
|
|
11744
|
+
function createGeneratorPlugins(options, generationOnly, projectRoot = process$1.cwd()) {
|
|
11697
11745
|
assertNotVitePluginInstance(options);
|
|
11698
11746
|
const injection = options.injection ?? {};
|
|
11699
11747
|
const isNuxt = detectNuxtProject(options, projectRoot);
|
|
@@ -11816,7 +11864,7 @@ function createGeneratorPlugins(options, generationOnly, projectRoot = process.c
|
|
|
11816
11864
|
throw new Error('[vue-pom-generator] Remove generation.router.type="nuxt". Nuxt projects are auto-detected.');
|
|
11817
11865
|
}
|
|
11818
11866
|
if (isNuxt) {
|
|
11819
|
-
const nuxtDiscovery = await loadNuxtProjectDiscovery(process.cwd());
|
|
11867
|
+
const nuxtDiscovery = await loadNuxtProjectDiscovery(process$1.cwd());
|
|
11820
11868
|
projectRootRef.current = nuxtDiscovery.rootDir;
|
|
11821
11869
|
resolvedInjectionOptionsRef.current = applyNuxtDiscoveryToInjectionOptions(
|
|
11822
11870
|
resolvedInjectionOptionsRef.current,
|