@immense/vue-pom-generator 1.0.107 → 1.0.109
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 +28 -67
- package/class-generation/index.ts +99 -150
- package/dist/class-generation/index.d.ts +3 -0
- package/dist/class-generation/index.d.ts.map +1 -1
- package/dist/index.cjs +228 -314
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +230 -316
- package/dist/index.mjs.map +1 -1
- package/dist/manifest-generator.d.ts +2 -1
- package/dist/manifest-generator.d.ts.map +1 -1
- package/dist/plugin/generated-outputs.d.ts.map +1 -1
- package/dist/plugin/internal/dev-plugin.d.ts.map +1 -1
- package/dist/plugin/runtime/annotator/client.d.ts +1 -1
- package/dist/plugin/runtime/annotator/client.d.ts.map +1 -1
- package/dist/plugin/runtime/annotator/styles.d.ts +1 -1
- package/dist/plugin/runtime/annotator/styles.d.ts.map +1 -1
- package/dist/tests/annotator-keyboard.test.d.ts +2 -0
- package/dist/tests/annotator-keyboard.test.d.ts.map +1 -0
- package/dist/tests/annotator-preview.test.d.ts +2 -0
- package/dist/tests/annotator-preview.test.d.ts.map +1 -0
- package/dist/tests/incremental-generation.test.d.ts +2 -0
- package/dist/tests/incremental-generation.test.d.ts.map +1 -0
- package/dist/typescript-codegen.d.ts +14 -1
- package/dist/typescript-codegen.d.ts.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/plugin/runtime/annotator/client.ts +23 -137
- package/plugin/runtime/annotator/styles.ts +43 -26
package/RELEASE_NOTES.md
CHANGED
|
@@ -1,86 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
cover #70. Let me review the actual diff to summarize it accurately.
|
|
1
|
+
Git access is blocked, so I'll verify the change content by reading the affected files directly.
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
shipped in v1.0.106), so these notes cover #70 only.
|
|
6
|
-
|
|
7
|
-
v1.0.107
|
|
3
|
+
v1.0.109
|
|
8
4
|
|
|
9
5
|
Highlights
|
|
10
6
|
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
- Source analysis is unified: the SFC parse/compile pipeline is shared between Vite builds and
|
|
20
|
-
one-shot generation, and invalid component sources now fail fast instead of being silently dropped
|
|
21
|
-
from POM output.
|
|
7
|
+
- Annotator keyboard shortcuts removed — all annotator control is now toolbar-driven. The
|
|
8
|
+
capture-phase keydown handler previously swallowed single-letter keys before text surfaces like the
|
|
9
|
+
Monaco terminal editor could handle them.
|
|
10
|
+
- Crosshair cursor while inspecting elements, making selection mode visually obvious.
|
|
11
|
+
- Live annotation count displayed in the annotator toolbar.
|
|
12
|
+
- Readable preview popout — sized wide with a tall monospace textarea so the full feedback text can
|
|
13
|
+
be read in one view.
|
|
14
|
+
- New regression tests lock in the keyboard policy and preview behavior.
|
|
22
15
|
|
|
23
16
|
Changes
|
|
24
17
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
- Add generateVuePoms(options, viteOptions?) and VuePomGenerationViteOptions, exported from the
|
|
28
|
-
main entry point (#70).
|
|
29
|
-
- Runs a generation-only Vite build with no application entry, asset output, public-directory copy,
|
|
30
|
-
or dev server; relative output paths resolve against the provided Vite root.
|
|
31
|
-
- Accepts explicit Vite root, mode, resolve, plugins, and logLevel — the application's vite.config
|
|
32
|
-
is never loaded implicitly; pass only companion plugins needed for generation (e.g., an app-owned
|
|
33
|
-
vue() plugin for vuePluginOwnership: "external").
|
|
34
|
-
- Always scans configured source directories (no timestamp cache); an empty source directory is
|
|
35
|
-
valid and removes its previous outputs, while no existing source directories is an error.
|
|
36
|
-
- Rejects Nuxt projects (use the Nuxt Vite integration), disabled generation, and overlapping
|
|
37
|
-
concurrent calls — router introspection uses process-wide state, so calls must be awaited
|
|
38
|
-
sequentially and fail explicitly otherwise.
|
|
39
|
-
|
|
40
|
-
Generated output ownership and cleanup
|
|
18
|
+
Annotator
|
|
41
19
|
|
|
42
|
-
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
files/directories that are symlinks, including symlinked parents shared with sibling output
|
|
49
|
-
directories.
|
|
50
|
-
- Treat shared .gitattributes files as consumer-owned: update the generator block without claiming
|
|
51
|
-
ownership or pruning the file.
|
|
52
|
-
- Resolve generation.outDir and generation.vueTestUtils.outDir against the project root (VTU out
|
|
53
|
-
dir must still differ from the POM out dir).
|
|
20
|
+
- Removed all window-level keyboard shortcuts (s, p, c, x, ,, Escape); the annotator no longer
|
|
21
|
+
binds any keydown listener at mount and is fully inert to keyboard input.
|
|
22
|
+
- Switched the inspect shield to a crosshair cursor.
|
|
23
|
+
- Added a count badge (N annotation(s)) to the toolbar.
|
|
24
|
+
- Enlarged the preview panel (720–940px wide) with a taller, vertically resizable monospace
|
|
25
|
+
textarea so copied/previewed feedback is readable together.
|
|
54
26
|
|
|
55
|
-
|
|
27
|
+
Tests
|
|
56
28
|
|
|
57
|
-
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
- Skip the "selector-less" and "less-rich snapshot" guards in generation-only mode so one-shot runs
|
|
62
|
-
always emit; record (or clear) element metadata even for template-less components.
|
|
63
|
-
- Deduplicate shared generator state construction and scope the shared-state key to the provided
|
|
64
|
-
project root.
|
|
29
|
+
- Added annotator-keyboard.test.ts: verifies no keydown listeners are bound and every former
|
|
30
|
+
shortcut key is ignored.
|
|
31
|
+
- Added annotator-preview.test.ts: verifies the preview panel opens and contains all seeded
|
|
32
|
+
feedback items.
|
|
65
33
|
|
|
66
|
-
|
|
34
|
+
Chores
|
|
67
35
|
|
|
68
|
-
|
|
69
|
-
silently skipped, and handwritten edits to generator-owned obsolete files block regeneration until
|
|
70
|
-
moved or removed.
|
|
36
|
+
- Added .nodeterm/project.json (local tooling state).
|
|
71
37
|
|
|
72
38
|
Pull Requests Included
|
|
73
39
|
|
|
74
|
-
-
|
|
40
|
+
- #74 fix(annotator): remove keyboard shortcuts; crosshair cursor, count badge, readable preview —
|
|
41
|
+
]8;id=md-co8rmx;https://github.com/immense/vue-pom-generator/pull/74https://github.com/immense/vue-pom-generator/pull/74]8;;]8;; (@dkattan)]8;;
|
|
75
42
|
|
|
76
43
|
Testing
|
|
77
44
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
concurrency guards.
|
|
81
|
-
- New tests/generated-outputs.test.ts (9 cases): manifest pruning, hand-edited obsolete files,
|
|
82
|
-
write-failure behavior, and symlink/malformed-manifest rejection.
|
|
83
|
-
- scripts/packed-smoke-check.mjs now exercises one-shot generation from the packed package in both
|
|
84
|
-
ESM and CJS, and asserts the app build prunes the obsolete split POM. Test suites were not run as
|
|
85
|
-
part of these notes.
|
|
45
|
+
Two new vitest suites cover this change (jsdom): keyboard-inertness of the mounted annotator client
|
|
46
|
+
and preview-panel content/affordances.
|
|
86
47
|
|
|
@@ -34,7 +34,6 @@ import {
|
|
|
34
34
|
import { buildPomLocatorDescription, stripPomActionPrefix } from "../pom-discoverability";
|
|
35
35
|
import { introspectNuxtPages, parseRouterFileFromCwd } from "../router-introspection";
|
|
36
36
|
import {
|
|
37
|
-
addExportAll,
|
|
38
37
|
addNamedImport,
|
|
39
38
|
buildCommentBlock,
|
|
40
39
|
buildFilePrefix,
|
|
@@ -42,17 +41,14 @@ import {
|
|
|
42
41
|
createClassGetter,
|
|
43
42
|
createClassMethod,
|
|
44
43
|
createClassProperty,
|
|
44
|
+
createClassDeclaration,
|
|
45
45
|
renderSourceFile,
|
|
46
|
+
renderStructuredSourceFile,
|
|
46
47
|
StructureKind,
|
|
47
48
|
VariableDeclarationKind,
|
|
48
|
-
type ConstructorDeclarationStructure,
|
|
49
|
-
type GetAccessorDeclarationStructure,
|
|
50
|
-
type MethodDeclarationStructure,
|
|
51
|
-
type OptionalKind,
|
|
52
|
-
type PropertyDeclarationStructure,
|
|
53
49
|
type TypeScriptClassMember,
|
|
54
|
-
type TypeScriptSourceFile,
|
|
55
50
|
type TypeScriptWriter,
|
|
51
|
+
type TypeScriptRenderCache,
|
|
56
52
|
} from "../typescript-codegen";
|
|
57
53
|
import {
|
|
58
54
|
IComponentDependencies,
|
|
@@ -742,6 +738,8 @@ function generateMethodsContentForDependencies(componentName: string, dependenci
|
|
|
742
738
|
}
|
|
743
739
|
|
|
744
740
|
export interface GenerateFilesOptions {
|
|
741
|
+
/** Per-dev-server rendering cache. Omitted for stateless one-shot/build generation. */
|
|
742
|
+
renderCache?: TypeScriptRenderCache;
|
|
745
743
|
/**
|
|
746
744
|
* Output directory for generated files.
|
|
747
745
|
*
|
|
@@ -848,6 +846,7 @@ export interface GenerateFilesOptions {
|
|
|
848
846
|
}
|
|
849
847
|
|
|
850
848
|
interface BaseGenerateContentOptions {
|
|
849
|
+
renderCache?: TypeScriptRenderCache;
|
|
851
850
|
/** Directory the generated .g.ts file will live in (used for relative imports). Defaults to the Vue file's directory. */
|
|
852
851
|
outputDir?: string;
|
|
853
852
|
|
|
@@ -906,6 +905,7 @@ export async function generateFiles(
|
|
|
906
905
|
layoutDirs,
|
|
907
906
|
routeMetaByComponent: routeMetaByComponentOverride,
|
|
908
907
|
elementMetadata = new Map<string, Map<string, ElementMetadata>>(),
|
|
908
|
+
renderCache,
|
|
909
909
|
} = options;
|
|
910
910
|
|
|
911
911
|
const emitLanguages: Array<"ts" | "csharp"> = emitLanguagesOverride?.length
|
|
@@ -933,6 +933,7 @@ export async function generateFiles(
|
|
|
933
933
|
if (emitLanguages.includes("ts")) {
|
|
934
934
|
const files = typescriptOutputStructure === "split"
|
|
935
935
|
? await generateSplitTypeScriptFiles(emittableComponentHierarchyMap, vueFilesPathMap, basePageClassPath, outDir, {
|
|
936
|
+
renderCache,
|
|
936
937
|
customPomAttachments,
|
|
937
938
|
projectRoot,
|
|
938
939
|
customPomDir,
|
|
@@ -944,6 +945,7 @@ export async function generateFiles(
|
|
|
944
945
|
vueRouterFluentChaining,
|
|
945
946
|
})
|
|
946
947
|
: await generateAggregatedFiles(emittableComponentHierarchyMap, vueFilesPathMap, basePageClassPath, outDir, {
|
|
948
|
+
renderCache,
|
|
947
949
|
customPomAttachments,
|
|
948
950
|
projectRoot,
|
|
949
951
|
customPomDir,
|
|
@@ -958,6 +960,7 @@ export async function generateFiles(
|
|
|
958
960
|
generatedFiles.push(...files);
|
|
959
961
|
|
|
960
962
|
const fixtureRegistryFiles = maybeGenerateFixtureRegistry(emittableComponentHierarchyMap, {
|
|
963
|
+
renderCache,
|
|
961
964
|
generateFixtures,
|
|
962
965
|
pomOutDir: outDir,
|
|
963
966
|
projectRoot,
|
|
@@ -981,13 +984,14 @@ export async function generateFiles(
|
|
|
981
984
|
const vueTestUtilsFiles = generateVueTestUtilsFiles(
|
|
982
985
|
emittableComponentHierarchyMap,
|
|
983
986
|
vueTestUtilsOutDir,
|
|
984
|
-
{ testIdAttribute },
|
|
987
|
+
{ testIdAttribute, renderCache },
|
|
985
988
|
);
|
|
986
989
|
generatedFiles.push(...vueTestUtilsFiles);
|
|
987
990
|
}
|
|
988
991
|
|
|
989
992
|
const gitattributesFiles = buildGeneratedGitAttributesFiles(generatedFiles.map(file => file.filePath));
|
|
990
993
|
writeGeneratedOutputs(outDir, generatedFiles, gitattributesFiles, path.resolve(root));
|
|
994
|
+
renderCache?.retain(new Set(generatedFiles.map(file => file.filePath)));
|
|
991
995
|
}
|
|
992
996
|
|
|
993
997
|
const VUE_TEST_UTILS_OMITTED_PARAMETERS = new Set(["annotationText", "timeOut", "timeout", "wait"]);
|
|
@@ -1160,6 +1164,7 @@ function generateVueTestUtilsContent(
|
|
|
1160
1164
|
runtimePath: string,
|
|
1161
1165
|
generatedFilePathByComponent: Map<string, string>,
|
|
1162
1166
|
testIdAttribute: string,
|
|
1167
|
+
renderCache?: TypeScriptRenderCache,
|
|
1163
1168
|
): string {
|
|
1164
1169
|
const prepared = prepareViewObjectModelClass(componentName, dependencies, componentHierarchyMap, {
|
|
1165
1170
|
outputStructure: "split",
|
|
@@ -1188,41 +1193,36 @@ function generateVueTestUtilsContent(
|
|
|
1188
1193
|
...(dependencies.pomExtraMethods ?? []).flatMap(getVueTestUtilsExtraMembers),
|
|
1189
1194
|
];
|
|
1190
1195
|
|
|
1191
|
-
return
|
|
1192
|
-
|
|
1196
|
+
return renderStructuredSourceFile(path.join(outputDir, `${componentName}.vtu.g.ts`), {
|
|
1197
|
+
statements: [{
|
|
1198
|
+
kind: StructureKind.ImportDeclaration,
|
|
1193
1199
|
moduleSpecifier: runtimeImport,
|
|
1194
1200
|
namedImports: ["VueTestUtilsPom"],
|
|
1195
|
-
}
|
|
1196
|
-
|
|
1201
|
+
}, {
|
|
1202
|
+
kind: StructureKind.ImportDeclaration,
|
|
1197
1203
|
moduleSpecifier: runtimeImport,
|
|
1198
1204
|
namedImports: ["VueTestUtilsPomRoot"],
|
|
1199
1205
|
isTypeOnly: true,
|
|
1200
|
-
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
});
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
const declaration = sourceFile.addClass({
|
|
1206
|
+
}, ...componentImports.map(componentImport => ({
|
|
1207
|
+
kind: StructureKind.ImportDeclaration as const,
|
|
1208
|
+
moduleSpecifier: componentImport.moduleSpecifier,
|
|
1209
|
+
namedImports: [componentImport.className],
|
|
1210
|
+
})), createClassDeclaration({
|
|
1209
1211
|
name: prepared.className,
|
|
1210
1212
|
isExported: true,
|
|
1211
1213
|
extends: "VueTestUtilsPom",
|
|
1212
1214
|
docs: [`Vue Test Utils object for ${componentName} (source: ${sourceRel}).`],
|
|
1213
|
-
})
|
|
1214
|
-
for (const member of members) {
|
|
1215
|
-
addClassMember(declaration, member);
|
|
1216
|
-
}
|
|
1215
|
+
}, members)],
|
|
1217
1216
|
}, {
|
|
1218
1217
|
prefixText: buildFilePrefix({ eslintDisableSortImports: true }),
|
|
1218
|
+
cache: renderCache,
|
|
1219
1219
|
});
|
|
1220
1220
|
}
|
|
1221
1221
|
|
|
1222
1222
|
function generateVueTestUtilsFiles(
|
|
1223
1223
|
componentHierarchyMap: Map<string, IComponentDependencies>,
|
|
1224
1224
|
outDir: string,
|
|
1225
|
-
options: { testIdAttribute?: string } = {},
|
|
1225
|
+
options: { testIdAttribute?: string; renderCache?: TypeScriptRenderCache } = {},
|
|
1226
1226
|
): GeneratedFileOutput[] {
|
|
1227
1227
|
const base = ensureDir(outDir);
|
|
1228
1228
|
const testIdAttribute = options.testIdAttribute?.trim() || "data-testid";
|
|
@@ -1244,6 +1244,7 @@ function generateVueTestUtilsFiles(
|
|
|
1244
1244
|
runtimePath,
|
|
1245
1245
|
generatedFilePathByComponent,
|
|
1246
1246
|
testIdAttribute,
|
|
1247
|
+
options.renderCache,
|
|
1247
1248
|
),
|
|
1248
1249
|
};
|
|
1249
1250
|
});
|
|
@@ -1255,12 +1256,13 @@ function generateVueTestUtilsFiles(
|
|
|
1255
1256
|
if (!runtimeFile) {
|
|
1256
1257
|
throw new Error("[vue-pom-generator] Failed to generate the Vue Test Utils runtime.");
|
|
1257
1258
|
}
|
|
1258
|
-
const indexContent =
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
}
|
|
1259
|
+
const indexContent = renderStructuredSourceFile(path.join(base, "index.ts"), {
|
|
1260
|
+
statements: [
|
|
1261
|
+
stripExtension(toPosixRelativePath(base, runtimePath)),
|
|
1262
|
+
...Array.from(generatedFilePathByComponent.values(), filePath => `./${stripExtension(path.basename(filePath))}`),
|
|
1263
|
+
].map(moduleSpecifier => ({ kind: StructureKind.ExportDeclaration, moduleSpecifier })),
|
|
1263
1264
|
}, {
|
|
1265
|
+
cache: options.renderCache,
|
|
1264
1266
|
prefixText: buildFilePrefix({
|
|
1265
1267
|
eslintDisableSortImports: true,
|
|
1266
1268
|
commentLines: [
|
|
@@ -1283,6 +1285,7 @@ async function generateSplitTypeScriptFiles(
|
|
|
1283
1285
|
basePageClassPath: string,
|
|
1284
1286
|
outDir: string,
|
|
1285
1287
|
options: {
|
|
1288
|
+
renderCache?: TypeScriptRenderCache;
|
|
1286
1289
|
customPomAttachments?: GenerateFilesOptions["customPomAttachments"];
|
|
1287
1290
|
projectRoot?: GenerateFilesOptions["projectRoot"];
|
|
1288
1291
|
customPomDir?: GenerateFilesOptions["customPomDir"];
|
|
@@ -1342,6 +1345,7 @@ async function generateSplitTypeScriptFiles(
|
|
|
1342
1345
|
}
|
|
1343
1346
|
|
|
1344
1347
|
const content = generateViewObjectModelContent(name, deps, componentHierarchyMap, vueFilesPathMap, runtimeBasePagePath, {
|
|
1348
|
+
renderCache: options.renderCache,
|
|
1345
1349
|
outputDir: path.dirname(filePath),
|
|
1346
1350
|
outputStructure: "split",
|
|
1347
1351
|
customPomAttachments: options.customPomAttachments ?? [],
|
|
@@ -1373,6 +1377,8 @@ async function generateSplitTypeScriptFiles(
|
|
|
1373
1377
|
const members = composed?.members ?? getDefaultStubMembers();
|
|
1374
1378
|
|
|
1375
1379
|
const content = renderSplitStubPomContent({
|
|
1380
|
+
filePath,
|
|
1381
|
+
renderCache: options.renderCache,
|
|
1376
1382
|
className: targetClassName,
|
|
1377
1383
|
basePageImportSpecifier,
|
|
1378
1384
|
childImports,
|
|
@@ -1384,14 +1390,15 @@ async function generateSplitTypeScriptFiles(
|
|
|
1384
1390
|
|
|
1385
1391
|
const runtimeAssetSpecs = getRuntimeGeneratedAssetSpecs(base, basePageClassPath);
|
|
1386
1392
|
const runtimeFiles = buildRuntimeGeneratedFilesFromSpecs(runtimeAssetSpecs);
|
|
1387
|
-
const indexContent =
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
}
|
|
1393
|
+
const indexContent = renderStructuredSourceFile(path.join(base, "index.ts"), {
|
|
1394
|
+
statements: [
|
|
1395
|
+
...runtimeAssetSpecs.map(spec => stripExtension(toPosixRelativePath(base, spec.outputPath))),
|
|
1396
|
+
...Array.from(generatedTsFilePathByComponent.entries())
|
|
1397
|
+
.sort((a, b) => a[0].localeCompare(b[0]))
|
|
1398
|
+
.map(([, filePath]) => `./${stripExtension(path.basename(filePath))}`),
|
|
1399
|
+
].map(moduleSpecifier => ({ kind: StructureKind.ExportDeclaration, moduleSpecifier })),
|
|
1394
1400
|
}, {
|
|
1401
|
+
cache: options.renderCache,
|
|
1395
1402
|
prefixText: buildFilePrefix({
|
|
1396
1403
|
eslintDisableSortImports: true,
|
|
1397
1404
|
commentLines: [
|
|
@@ -1860,6 +1867,7 @@ function generateAggregatedCSharpFiles(
|
|
|
1860
1867
|
function maybeGenerateFixtureRegistry(
|
|
1861
1868
|
componentHierarchyMap: Map<string, IComponentDependencies>,
|
|
1862
1869
|
options: {
|
|
1870
|
+
renderCache?: TypeScriptRenderCache;
|
|
1863
1871
|
generateFixtures: GenerateFilesOptions["generateFixtures"];
|
|
1864
1872
|
pomOutDir: string;
|
|
1865
1873
|
projectRoot?: string;
|
|
@@ -2219,7 +2227,8 @@ function maybeGenerateFixtureRegistry(
|
|
|
2219
2227
|
const manifestContent = generatePomManifestModule(
|
|
2220
2228
|
componentHierarchyMap,
|
|
2221
2229
|
options.elementMetadata,
|
|
2222
|
-
manifestFileName,
|
|
2230
|
+
path.resolve(fixtureOutDirAbs, manifestFileName),
|
|
2231
|
+
options.renderCache,
|
|
2223
2232
|
);
|
|
2224
2233
|
const [diagnosticsRuntimeFile] = buildRuntimeGeneratedFilesFromSpecs([{
|
|
2225
2234
|
absolutePath: resolvePluginAsset("../class-generation/diagnostics.ts"),
|
|
@@ -2679,45 +2688,33 @@ function generateViewObjectModelContent(
|
|
|
2679
2688
|
generatedImports.sort((a, b) => a.className.localeCompare(b.className));
|
|
2680
2689
|
|
|
2681
2690
|
const prefixText = `${buildFilePrefix({ eslintDisableSortImports: true })}${doc}\n`;
|
|
2682
|
-
return
|
|
2683
|
-
|
|
2691
|
+
return renderStructuredSourceFile(path.join(outputDir, `${componentName}.g.ts`), {
|
|
2692
|
+
statements: [{
|
|
2693
|
+
kind: StructureKind.ImportDeclaration,
|
|
2684
2694
|
moduleSpecifier: "@playwright/test",
|
|
2685
2695
|
isTypeOnly: true,
|
|
2686
2696
|
namedImports: [
|
|
2687
2697
|
{ name: "Locator", alias: "PwLocator" },
|
|
2688
2698
|
{ name: "Page", alias: "PwPage" },
|
|
2689
2699
|
],
|
|
2690
|
-
}
|
|
2691
|
-
|
|
2692
|
-
addNamedImport(sourceFile, {
|
|
2700
|
+
}, {
|
|
2701
|
+
kind: StructureKind.ImportDeclaration,
|
|
2693
2702
|
moduleSpecifier: basePageImportSpecifier,
|
|
2694
2703
|
namedImports: ["BasePage", "Fluent"],
|
|
2695
|
-
}
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
for (const generatedImport of generatedImports) {
|
|
2705
|
-
addNamedImport(sourceFile, {
|
|
2706
|
-
moduleSpecifier: generatedImport.moduleSpecifier,
|
|
2707
|
-
namedImports: [generatedImport.className],
|
|
2708
|
-
});
|
|
2709
|
-
}
|
|
2710
|
-
|
|
2711
|
-
const classDeclaration = sourceFile.addClass({
|
|
2704
|
+
}, ...customImports.map(customImport => ({
|
|
2705
|
+
kind: StructureKind.ImportDeclaration as const,
|
|
2706
|
+
moduleSpecifier: customImport.moduleSpecifier,
|
|
2707
|
+
namedImports: [{ name: customImport.name, alias: customImport.alias }],
|
|
2708
|
+
})), ...generatedImports.map(generatedImport => ({
|
|
2709
|
+
kind: StructureKind.ImportDeclaration as const,
|
|
2710
|
+
moduleSpecifier: generatedImport.moduleSpecifier,
|
|
2711
|
+
namedImports: [generatedImport.className],
|
|
2712
|
+
})), createClassDeclaration({
|
|
2712
2713
|
name: prepared.className,
|
|
2713
2714
|
isExported: true,
|
|
2714
2715
|
extends: "BasePage",
|
|
2715
|
-
})
|
|
2716
|
-
|
|
2717
|
-
for (const member of prepared.members) {
|
|
2718
|
-
addClassMember(classDeclaration, member);
|
|
2719
|
-
}
|
|
2720
|
-
}, { prefixText });
|
|
2716
|
+
}, prepared.members)],
|
|
2717
|
+
}, { prefixText, cache: options.renderCache });
|
|
2721
2718
|
}
|
|
2722
2719
|
|
|
2723
2720
|
function getViewPassthroughMethods(
|
|
@@ -3000,6 +2997,8 @@ function getDefaultStubMembers(): TypeScriptClassMember[] {
|
|
|
3000
2997
|
}
|
|
3001
2998
|
|
|
3002
2999
|
function renderSplitStubPomContent(options: {
|
|
3000
|
+
filePath: string;
|
|
3001
|
+
renderCache?: TypeScriptRenderCache;
|
|
3003
3002
|
className: string;
|
|
3004
3003
|
basePageImportSpecifier: string;
|
|
3005
3004
|
childImports: Array<{ className: string; importPath: string }>;
|
|
@@ -3016,37 +3015,32 @@ function renderSplitStubPomContent(options: {
|
|
|
3016
3015
|
],
|
|
3017
3016
|
});
|
|
3018
3017
|
|
|
3019
|
-
return
|
|
3018
|
+
return renderStructuredSourceFile(options.filePath, {
|
|
3020
3019
|
// Stub ctors take Playwright's full `Page` (aliased `PwPage`), matching non-stub generated
|
|
3021
3020
|
// POMs — stubs are constructed with `new Stub(this.page)` where `this.page` is `Page`.
|
|
3022
|
-
|
|
3021
|
+
statements: [{
|
|
3022
|
+
kind: StructureKind.ImportDeclaration,
|
|
3023
3023
|
moduleSpecifier: "@playwright/test",
|
|
3024
3024
|
isTypeOnly: true,
|
|
3025
3025
|
namedImports: [{ name: "Page", alias: "PwPage" }],
|
|
3026
|
-
}
|
|
3027
|
-
|
|
3026
|
+
}, {
|
|
3027
|
+
kind: StructureKind.ImportDeclaration,
|
|
3028
3028
|
moduleSpecifier: options.basePageImportSpecifier,
|
|
3029
3029
|
namedImports: ["BasePage"],
|
|
3030
|
-
}
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
});
|
|
3036
|
-
}
|
|
3037
|
-
sourceFile.addStatements(buildCommentBlock([
|
|
3038
|
-
"Stub POM generated because it is referenced as a navigation target but",
|
|
3039
|
-
"did not have any generated test ids in this build.",
|
|
3040
|
-
]).trimEnd());
|
|
3041
|
-
const classDeclaration = sourceFile.addClass({
|
|
3030
|
+
}, ...options.childImports.map(childImport => ({
|
|
3031
|
+
kind: StructureKind.ImportDeclaration as const,
|
|
3032
|
+
moduleSpecifier: childImport.importPath,
|
|
3033
|
+
namedImports: [childImport.className],
|
|
3034
|
+
})), createClassDeclaration({
|
|
3042
3035
|
name: options.className,
|
|
3043
3036
|
isExported: true,
|
|
3044
3037
|
extends: "BasePage",
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3038
|
+
leadingTrivia: buildCommentBlock([
|
|
3039
|
+
"Stub POM generated because it is referenced as a navigation target but",
|
|
3040
|
+
"did not have any generated test ids in this build.",
|
|
3041
|
+
]),
|
|
3042
|
+
}, options.members)],
|
|
3043
|
+
}, { prefixText, cache: options.renderCache });
|
|
3050
3044
|
}
|
|
3051
3045
|
|
|
3052
3046
|
function getChildImportSpecifiers(
|
|
@@ -3069,42 +3063,6 @@ function getChildImportSpecifiers(
|
|
|
3069
3063
|
.sort((a, b) => a.className.localeCompare(b.className));
|
|
3070
3064
|
}
|
|
3071
3065
|
|
|
3072
|
-
function isConstructorMember(member: TypeScriptClassMember): member is OptionalKind<ConstructorDeclarationStructure> {
|
|
3073
|
-
return member.kind === StructureKind.Constructor;
|
|
3074
|
-
}
|
|
3075
|
-
|
|
3076
|
-
function isGetterMember(member: TypeScriptClassMember): member is OptionalKind<GetAccessorDeclarationStructure> {
|
|
3077
|
-
return member.kind === StructureKind.GetAccessor;
|
|
3078
|
-
}
|
|
3079
|
-
|
|
3080
|
-
function isMethodMember(member: TypeScriptClassMember): member is OptionalKind<MethodDeclarationStructure> {
|
|
3081
|
-
return member.kind === StructureKind.Method;
|
|
3082
|
-
}
|
|
3083
|
-
|
|
3084
|
-
function isPropertyMember(member: TypeScriptClassMember): member is OptionalKind<PropertyDeclarationStructure> {
|
|
3085
|
-
return member.kind === StructureKind.Property;
|
|
3086
|
-
}
|
|
3087
|
-
|
|
3088
|
-
function addClassMember(classDeclaration: ReturnType<TypeScriptSourceFile["addClass"]>, member: TypeScriptClassMember): void {
|
|
3089
|
-
if (isConstructorMember(member)) {
|
|
3090
|
-
classDeclaration.addConstructor(member);
|
|
3091
|
-
return;
|
|
3092
|
-
}
|
|
3093
|
-
if (isGetterMember(member)) {
|
|
3094
|
-
classDeclaration.addGetAccessor(member);
|
|
3095
|
-
return;
|
|
3096
|
-
}
|
|
3097
|
-
if (isMethodMember(member)) {
|
|
3098
|
-
classDeclaration.addMethod(member);
|
|
3099
|
-
return;
|
|
3100
|
-
}
|
|
3101
|
-
if (isPropertyMember(member)) {
|
|
3102
|
-
classDeclaration.addProperty(member);
|
|
3103
|
-
return;
|
|
3104
|
-
}
|
|
3105
|
-
throw new Error(`Unsupported class member structure: ${String(member)}`);
|
|
3106
|
-
}
|
|
3107
|
-
|
|
3108
3066
|
interface RuntimeGeneratedAssetSpec {
|
|
3109
3067
|
absolutePath: string;
|
|
3110
3068
|
description: string;
|
|
@@ -3360,6 +3318,7 @@ async function generateAggregatedFiles(
|
|
|
3360
3318
|
basePageClassPath: string,
|
|
3361
3319
|
outDir: string,
|
|
3362
3320
|
options: {
|
|
3321
|
+
renderCache?: TypeScriptRenderCache;
|
|
3363
3322
|
customPomAttachments?: GenerateFilesOptions["customPomAttachments"];
|
|
3364
3323
|
projectRoot?: GenerateFilesOptions["projectRoot"];
|
|
3365
3324
|
customPomDir?: GenerateFilesOptions["customPomDir"];
|
|
@@ -3496,33 +3455,22 @@ async function generateAggregatedFiles(
|
|
|
3496
3455
|
],
|
|
3497
3456
|
});
|
|
3498
3457
|
|
|
3499
|
-
return
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
for (const entry of [...classes, ...stubs]) {
|
|
3505
|
-
if (entry.isStub) {
|
|
3506
|
-
sourceFile.addStatements(buildCommentBlock([
|
|
3507
|
-
"Stub POM generated because it is referenced as a navigation target but",
|
|
3508
|
-
"did not have any generated test ids in this build.",
|
|
3509
|
-
]).trimEnd());
|
|
3510
|
-
}
|
|
3511
|
-
else {
|
|
3512
|
-
sourceFile.addStatements(entry.doc);
|
|
3513
|
-
}
|
|
3514
|
-
|
|
3515
|
-
const classDeclaration = sourceFile.addClass({
|
|
3458
|
+
return renderStructuredSourceFile(path.join(outputDir, "page-object-models.g.ts"), {
|
|
3459
|
+
statements: [
|
|
3460
|
+
...imports,
|
|
3461
|
+
...[...classes, ...stubs].map(entry => createClassDeclaration({
|
|
3516
3462
|
name: entry.className,
|
|
3517
3463
|
isExported: true,
|
|
3518
3464
|
extends: "BasePage",
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3465
|
+
leadingTrivia: entry.isStub
|
|
3466
|
+
? buildCommentBlock([
|
|
3467
|
+
"Stub POM generated because it is referenced as a navigation target but",
|
|
3468
|
+
"did not have any generated test ids in this build.",
|
|
3469
|
+
])
|
|
3470
|
+
: `${entry.doc}\n`,
|
|
3471
|
+
}, entry.members)),
|
|
3472
|
+
],
|
|
3473
|
+
}, { prefixText, cache: options.renderCache });
|
|
3526
3474
|
};
|
|
3527
3475
|
|
|
3528
3476
|
const base = ensureDir(outDir);
|
|
@@ -3530,9 +3478,10 @@ async function generateAggregatedFiles(
|
|
|
3530
3478
|
const content = makeAggregatedContent(path.dirname(outputFile), [...views, ...components]);
|
|
3531
3479
|
|
|
3532
3480
|
const indexFile = path.join(base, "index.ts");
|
|
3533
|
-
const indexContent =
|
|
3534
|
-
|
|
3481
|
+
const indexContent = renderStructuredSourceFile(indexFile, {
|
|
3482
|
+
statements: [{ kind: StructureKind.ExportDeclaration, moduleSpecifier: "./page-object-models.g" }],
|
|
3535
3483
|
}, {
|
|
3484
|
+
cache: options.renderCache,
|
|
3536
3485
|
prefixText: buildFilePrefix({
|
|
3537
3486
|
eslintDisableSortImports: true,
|
|
3538
3487
|
commentLines: [
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { generateViewObjectModelMethodContent } from "../method-generation";
|
|
2
2
|
import type { ElementMetadata } from "../metadata-collector";
|
|
3
|
+
import { type TypeScriptRenderCache } from "../typescript-codegen";
|
|
3
4
|
import { IComponentDependencies } from "../utils";
|
|
4
5
|
export { generateViewObjectModelMethodContent };
|
|
5
6
|
interface RouteParamMeta {
|
|
@@ -28,6 +29,8 @@ interface CustomPomAttachment {
|
|
|
28
29
|
}
|
|
29
30
|
export type TypeScriptOutputStructure = "aggregated" | "split";
|
|
30
31
|
export interface GenerateFilesOptions {
|
|
32
|
+
/** Per-dev-server rendering cache. Omitted for stateless one-shot/build generation. */
|
|
33
|
+
renderCache?: TypeScriptRenderCache;
|
|
31
34
|
/**
|
|
32
35
|
* Output directory for generated files.
|
|
33
36
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../class-generation/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAkC,oCAAoC,EAAE,MAAM,sBAAsB,CAAC;AAE5G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../class-generation/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAkC,oCAAoC,EAAE,MAAM,sBAAsB,CAAC;AAE5G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAuB7D,OAAO,EAeL,KAAK,qBAAqB,EAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,sBAAsB,EASvB,MAAM,UAAU,CAAC;AAuBlB,OAAO,EAAE,oCAAoC,EAAE,CAAC;AA2ChD,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,C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