@immense/vue-pom-generator 1.0.90 → 1.0.92

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 (62) hide show
  1. package/README.md +88 -10
  2. package/RELEASE_NOTES.md +95 -62
  3. package/class-generation/base-page.ts +141 -59
  4. package/class-generation/diagnostics.ts +559 -0
  5. package/class-generation/index.ts +247 -128
  6. package/class-generation/playwright-types.ts +7 -11
  7. package/class-generation/pointer.ts +65 -18
  8. package/dist/class-generation/base-page.d.ts +19 -4
  9. package/dist/class-generation/base-page.d.ts.map +1 -1
  10. package/dist/class-generation/diagnostics.d.ts +110 -0
  11. package/dist/class-generation/diagnostics.d.ts.map +1 -0
  12. package/dist/class-generation/index.d.ts +4 -0
  13. package/dist/class-generation/index.d.ts.map +1 -1
  14. package/dist/class-generation/playwright-types.d.ts +3 -39
  15. package/dist/class-generation/playwright-types.d.ts.map +1 -1
  16. package/dist/class-generation/pointer.d.ts +10 -1
  17. package/dist/class-generation/pointer.d.ts.map +1 -1
  18. package/dist/eslint/index.cjs +52 -9
  19. package/dist/eslint/index.cjs.map +1 -1
  20. package/dist/eslint/index.d.ts +16 -7
  21. package/dist/eslint/index.d.ts.map +1 -1
  22. package/dist/eslint/index.mjs +52 -9
  23. package/dist/eslint/index.mjs.map +1 -1
  24. package/dist/index.cjs +728 -324
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.mjs +728 -324
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/manifest-generator.d.ts +10 -5
  29. package/dist/manifest-generator.d.ts.map +1 -1
  30. package/dist/method-generation.d.ts.map +1 -1
  31. package/dist/playwright/reporter.cjs +174 -0
  32. package/dist/playwright/reporter.cjs.map +1 -0
  33. package/dist/playwright/reporter.d.ts +13 -0
  34. package/dist/playwright/reporter.d.ts.map +1 -0
  35. package/dist/playwright/reporter.mjs +174 -0
  36. package/dist/playwright/reporter.mjs.map +1 -0
  37. package/dist/plugin/internal/build-plugin.d.ts +2 -0
  38. package/dist/plugin/internal/build-plugin.d.ts.map +1 -1
  39. package/dist/plugin/internal/dev-plugin.d.ts +2 -0
  40. package/dist/plugin/internal/dev-plugin.d.ts.map +1 -1
  41. package/dist/plugin/internal-plugins.d.ts.map +1 -1
  42. package/dist/route-navigation-codegen.d.ts +40 -0
  43. package/dist/route-navigation-codegen.d.ts.map +1 -0
  44. package/dist/router-bridge.d.ts +15 -0
  45. package/dist/router-bridge.d.ts.map +1 -1
  46. package/dist/router.cjs +41 -1
  47. package/dist/router.cjs.map +1 -1
  48. package/dist/router.mjs +41 -1
  49. package/dist/router.mjs.map +1 -1
  50. package/dist/tests/broad/helpers/fake-runtime.d.ts +27 -3
  51. package/dist/tests/broad/helpers/fake-runtime.d.ts.map +1 -1
  52. package/dist/tests/fixtures/generated-tsc/base-page.full.d.ts +16 -3
  53. package/dist/tests/fixtures/generated-tsc/base-page.full.d.ts.map +1 -1
  54. package/dist/tests/method-generation.test.d.ts +2 -0
  55. package/dist/tests/method-generation.test.d.ts.map +1 -0
  56. package/dist/tests/playwright-diagnostics.test.d.ts +2 -0
  57. package/dist/tests/playwright-diagnostics.test.d.ts.map +1 -0
  58. package/dist/tests/playwright-reporter.test.d.ts +2 -0
  59. package/dist/tests/playwright-reporter.test.d.ts.map +1 -0
  60. package/dist/transform.d.ts.map +1 -1
  61. package/dist/vite.config.d.ts.map +1 -1
  62. package/package.json +8 -1
@@ -4,8 +4,9 @@
4
4
  */
5
5
  import type { AccessibilityAuditResult } from "./accessibility-audit";
6
6
  import type { ElementMetadata } from "./metadata-collector";
7
+ import type { PomParameterSpec } from "./pom-params";
7
8
  import type { IComponentDependencies } from "./utils";
8
- type PomManifestEntry = {
9
+ export type PomManifestEntry = {
9
10
  testId: string;
10
11
  selectorPatternKind: "static" | "parameterized";
11
12
  semanticName: string;
@@ -15,6 +16,11 @@ type PomManifestEntry = {
15
16
  generatedPropertyName: string | null;
16
17
  generatedActionName: string | null;
17
18
  generatedActionNames: string[];
19
+ generatedMethods: Array<{
20
+ name: string;
21
+ kind: "action" | "locator";
22
+ parameters: PomParameterSpec[];
23
+ }>;
18
24
  emitPrimary: boolean;
19
25
  targetPageObjectModelClass?: string;
20
26
  sourceTag?: string;
@@ -28,7 +34,7 @@ type PomManifestEntry = {
28
34
  hasDynamicStyle?: boolean;
29
35
  hasDynamicText?: boolean;
30
36
  };
31
- type PomManifestComponent = {
37
+ export type PomManifestComponent = {
32
38
  componentName: string;
33
39
  className: string;
34
40
  sourceFile: string;
@@ -36,12 +42,11 @@ type PomManifestComponent = {
36
42
  testIds: string[];
37
43
  entries: PomManifestEntry[];
38
44
  };
39
- type PomManifest = Record<string, PomManifestComponent>;
45
+ export type PomManifest = Record<string, PomManifestComponent>;
40
46
  export declare function buildPomManifest(componentHierarchyMap: Map<string, IComponentDependencies>, elementMetadata: Map<string, Map<string, ElementMetadata>>): PomManifest;
41
47
  /**
42
48
  * Generates the complete virtual:testids module content
43
49
  */
44
50
  export declare function generateTestIdsModule(componentHierarchyMap: Map<string, IComponentDependencies>, elementMetadata: Map<string, Map<string, ElementMetadata>>): string;
45
- export declare function generatePomManifestModule(componentHierarchyMap: Map<string, IComponentDependencies>, elementMetadata: Map<string, Map<string, ElementMetadata>>): string;
46
- export {};
51
+ export declare function generatePomManifestModule(componentHierarchyMap: Map<string, IComponentDependencies>, elementMetadata: Map<string, Map<string, ElementMetadata>>, fileName?: string): string;
47
52
  //# sourceMappingURL=manifest-generator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"manifest-generator.d.ts","sourceRoot":"","sources":["../manifest-generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,KAAK,EAAE,sBAAsB,EAAwD,MAAM,SAAS,CAAC;AAI5G,KAAK,gBAAgB,GAAG;IACtB,MAAM,E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AC,GACzD,MAAM,CA2CR;AAED,wBAAgB,yBAAyB,CACvC,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC,EAC1D,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,EAC1D,QAAQ,GAAE,MAAkC,GAC3C,MAAM,CAwBR"}
@@ -1 +1 @@
1
- {"version":3,"file":"method-generation.d.ts","sourceRoot":"","sources":["../method-generation.ts"],"names":[],"mappings":"AAMA,OAAO,EAML,KAAK,qBAAqB,EAE3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAML,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAoZxB,wBAAgB,8BAA8B,CAC5C,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,0BAA0B,EAAE,MAAM,GAAG,SAAS,EAC9C,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,gBAAgB,EAC1B,kBAAkB,EAAE,gBAAgB,EAAE,GAAG,SAAS,EAClD,kBAAkB,EAAE,MAAM,GAAG,SAAS,EACtC,UAAU,EAAE,gBAAgB,EAAE,GAC7B,qBAAqB,EAAE,CA2CzB;AAED,wBAAgB,oCAAoC,CAClD,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,0BAA0B,EAAE,MAAM,GAAG,SAAS,EAC9C,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,gBAAgB,EAC1B,kBAAkB,EAAE,gBAAgB,EAAE,GAAG,SAAS,EAClD,kBAAkB,EAAE,MAAM,GAAG,SAAS,EACtC,UAAU,EAAE,gBAAgB,EAAE,UAc/B"}
1
+ {"version":3,"file":"method-generation.d.ts","sourceRoot":"","sources":["../method-generation.ts"],"names":[],"mappings":"AAMA,OAAO,EAML,KAAK,qBAAqB,EAE3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAML,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AA6YxB,wBAAgB,8BAA8B,CAC5C,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,0BAA0B,EAAE,MAAM,GAAG,SAAS,EAC9C,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,gBAAgB,EAC1B,kBAAkB,EAAE,gBAAgB,EAAE,GAAG,SAAS,EAClD,kBAAkB,EAAE,MAAM,GAAG,SAAS,EACtC,UAAU,EAAE,gBAAgB,EAAE,GAC7B,qBAAqB,EAAE,CA2CzB;AAED,wBAAgB,oCAAoC,CAClD,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,0BAA0B,EAAE,MAAM,GAAG,SAAS,EAC9C,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,gBAAgB,EAC1B,kBAAkB,EAAE,gBAAgB,EAAE,GAAG,SAAS,EAClD,kBAAkB,EAAE,MAAM,GAAG,SAAS,EACtC,UAAU,EAAE,gBAAgB,EAAE,UAc/B"}
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const fs = require("node:fs");
4
+ const path = require("node:path");
5
+ require("node:fs/promises");
6
+ const POM_FAILURE_ATTACHMENT_NAME = "vue-pom-generator.failure";
7
+ const DEFAULT_MAX_OUTPUT_CHARACTERS = 32e3;
8
+ const DEFAULT_MAX_METHODS = 80;
9
+ const DEFAULT_MAX_ELEMENTS = 80;
10
+ const DEFAULT_MAX_EVENTS = 30;
11
+ const DEFAULT_MAX_ARIA_CHARACTERS = 8e3;
12
+ function shellQuote(value) {
13
+ let quoted = "'";
14
+ for (const character of value) {
15
+ quoted += character === "'" ? `'"'"'` : character;
16
+ }
17
+ return `${quoted}'`;
18
+ }
19
+ function readDiagnostics(result) {
20
+ const attachment = result.attachments.find((candidate) => candidate.name === POM_FAILURE_ATTACHMENT_NAME);
21
+ if (!attachment) return null;
22
+ try {
23
+ if (attachment.body) return JSON.parse(attachment.body.toString("utf8"));
24
+ if (attachment.path) return JSON.parse(fs.readFileSync(attachment.path, "utf8"));
25
+ } catch {
26
+ return null;
27
+ }
28
+ return null;
29
+ }
30
+ function appendLimited(lines, heading, values, limit) {
31
+ if (!values.length) return;
32
+ lines.push(heading);
33
+ for (const value of values.slice(-limit)) lines.push(` ${value}`);
34
+ const omitted = Math.max(0, values.length - limit);
35
+ if (omitted) lines.push(` … ${omitted} earlier entries omitted`);
36
+ }
37
+ function formatPage(lines, page, index) {
38
+ lines.push(`Page ${index + 1}: ${page.url || "<no URL>"}`);
39
+ if (page.title) lines.push(`Title: ${page.title}`);
40
+ if (page.closed) lines.push("State: page was already closed");
41
+ if (page.routerNavigation) {
42
+ lines.push(
43
+ `Generated router navigation: ${page.routerNavigation.status} at ${page.routerNavigation.stage} -> ${page.routerNavigation.targetName}`
44
+ );
45
+ if (page.routerNavigation.error) lines.push(`Router error: ${page.routerNavigation.error}`);
46
+ }
47
+ if (page.component) {
48
+ const available = page.component.methods.filter((method) => method.state === "present").length;
49
+ lines.push(
50
+ `Generated POM match: ${page.component.className} (${page.component.matchedTestIds} rendered test ids; ${available}/${page.component.methods.length} methods currently present)`
51
+ );
52
+ lines.push(`Vue source: ${page.component.sourceFile}`);
53
+ for (const method of page.component.methods.slice(0, DEFAULT_MAX_METHODS)) {
54
+ lines.push(` [${method.state}] ${method.signature} <- ${method.expectedTestIds.join(" | ")}`);
55
+ }
56
+ const omittedMethods = Math.max(0, page.component.methods.length - DEFAULT_MAX_METHODS);
57
+ if (omittedMethods) lines.push(` … ${omittedMethods} generated methods omitted; see JSON`);
58
+ lines.push(" Availability describes the current page state; an unavailable method is not inherently an error.");
59
+ } else {
60
+ lines.push("Generated POM match: no active page POM identified from rendered test ids");
61
+ }
62
+ if (page.renderedElements.length) {
63
+ lines.push("Rendered generated elements:");
64
+ for (const element of page.renderedElements.slice(0, DEFAULT_MAX_ELEMENTS)) {
65
+ const state = `${element.visible ? "visible" : "hidden"}/${element.enabled ? "enabled" : "disabled"}`;
66
+ const semantics = [element.role ? `role=${element.role}` : null, element.name ? `name=${JSON.stringify(element.name)}` : null].filter(Boolean).join(" ");
67
+ lines.push(` ${element.testId} <${element.tag}> ${state}${semantics ? ` ${semantics}` : ""}`);
68
+ }
69
+ const omittedElements = Math.max(0, page.renderedElements.length - DEFAULT_MAX_ELEMENTS);
70
+ if (omittedElements) lines.push(` … ${omittedElements} rendered elements omitted; see JSON`);
71
+ }
72
+ if (page.ariaSnapshot) {
73
+ const aria = page.ariaSnapshot.slice(0, DEFAULT_MAX_ARIA_CHARACTERS);
74
+ lines.push("Accessibility snapshot:", aria);
75
+ if (aria.length < page.ariaSnapshot.length) {
76
+ lines.push(` … ${page.ariaSnapshot.length - aria.length} accessibility-snapshot characters omitted; see JSON`);
77
+ }
78
+ } else if (page.ariaSnapshotError) {
79
+ lines.push(`Accessibility snapshot unavailable: ${page.ariaSnapshotError}`);
80
+ }
81
+ appendLimited(lines, "Capture warnings:", page.captureErrors, DEFAULT_MAX_EVENTS);
82
+ }
83
+ function formatErrors(result) {
84
+ if (!result.errors.length) return ["Playwright error: failure did not include an Error object"];
85
+ return result.errors.map((error, index) => {
86
+ const value = error.stack ?? error.message ?? error.value ?? "Unknown error";
87
+ return `Error ${index + 1}:
88
+ ${String(value).slice(0, 6e3)}`;
89
+ });
90
+ }
91
+ function isolatedCommand(test) {
92
+ const location = `${path.relative(process.cwd(), test.location.file)}:${test.location.line}`;
93
+ return `npx playwright test ${shellQuote(location)} --project=${shellQuote(test.parent.project()?.name ?? "chromium")} --max-failures=1`;
94
+ }
95
+ function boundOutput(lines, footer, maximum) {
96
+ const full = [...lines, ...footer].join("\n");
97
+ if (full.length <= maximum) return full;
98
+ const footerText = footer.join("\n");
99
+ const marker = `
100
+ … report truncated by ${full.length - maximum} characters; use the JSON artifact for complete structured diagnostics …
101
+ `;
102
+ const available = Math.max(0, maximum - footerText.length - marker.length - 1);
103
+ return `${lines.join("\n").slice(0, available)}${marker}${footerText}`;
104
+ }
105
+ function formatPomFailureReport(test, result, diagnostics, options = {}) {
106
+ const title = test.titlePath().join(" › ");
107
+ const lines = [
108
+ "================ VUE POM FAILURE DIAGNOSTICS ================",
109
+ `Test: ${title}`,
110
+ `Location: ${test.location.file}:${test.location.line}:${test.location.column}`,
111
+ `Attempt: ${result.retry + 1}`,
112
+ `Status: ${result.status} (expected ${test.expectedStatus})`,
113
+ ...formatErrors(result)
114
+ ];
115
+ if (diagnostics) {
116
+ if (diagnostics.activeAction) {
117
+ lines.push(
118
+ `Active generated action: ${diagnostics.activeAction.componentName ? `${diagnostics.activeAction.componentName}.` : ""}${diagnostics.activeAction.methodName}`
119
+ );
120
+ if (diagnostics.activeAction.expectedTestIds.length) {
121
+ lines.push(`Expected generated test ids: ${diagnostics.activeAction.expectedTestIds.join(" | ")}`);
122
+ }
123
+ } else {
124
+ lines.push("Active generated action: none recorded");
125
+ }
126
+ diagnostics.pages.forEach((page, index) => formatPage(lines, page, index));
127
+ appendLimited(lines, "Browser console:", diagnostics.console, DEFAULT_MAX_EVENTS);
128
+ appendLimited(lines, "Page errors:", diagnostics.pageErrors, DEFAULT_MAX_EVENTS);
129
+ appendLimited(lines, "Network failures:", diagnostics.networkFailures, DEFAULT_MAX_EVENTS);
130
+ appendLimited(
131
+ lines,
132
+ "HTTP error responses:",
133
+ (diagnostics.httpFailures ?? []).map((failure) => {
134
+ const heading = `${failure.status} ${failure.method} ${failure.url}${failure.contentType ? ` (${failure.contentType})` : ""}`;
135
+ if (failure.body) return `${heading}
136
+ Response body:
137
+ ${failure.body}`;
138
+ if (failure.bodyCaptureError) return `${heading}
139
+ Response body unavailable: ${failure.bodyCaptureError}`;
140
+ return heading;
141
+ }),
142
+ DEFAULT_MAX_EVENTS
143
+ );
144
+ appendLimited(lines, "Requests still pending at failure:", diagnostics.pendingRequests ?? [], DEFAULT_MAX_EVENTS);
145
+ } else {
146
+ lines.push(
147
+ "Browser diagnostics: unavailable. The test did not initialize generated POM fixtures, the page closed before capture, or capture itself failed."
148
+ );
149
+ }
150
+ const footer = [
151
+ diagnostics ? `Structured diagnostics: ${diagnostics.jsonPath}` : "Structured diagnostics: unavailable",
152
+ `Isolated rerun: ${isolatedCommand(test)}`,
153
+ "============================================================="
154
+ ];
155
+ return boundOutput(lines, footer, options.maxOutputCharacters ?? DEFAULT_MAX_OUTPUT_CHARACTERS);
156
+ }
157
+ class PomFailureReporter {
158
+ options;
159
+ constructor(options = {}) {
160
+ this.options = options;
161
+ }
162
+ onTestEnd(test, result) {
163
+ if (result.status === test.expectedStatus || result.status === "skipped") return;
164
+ const diagnostics = readDiagnostics(result);
165
+ process.stdout.write(`${formatPomFailureReport(test, result, diagnostics, this.options)}
166
+ `);
167
+ }
168
+ printsToStdio() {
169
+ return true;
170
+ }
171
+ }
172
+ exports.default = PomFailureReporter;
173
+ exports.formatPomFailureReport = formatPomFailureReport;
174
+ //# sourceMappingURL=reporter.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reporter.cjs","sources":["../../class-generation/diagnostics.ts","../../playwright/reporter.ts"],"sourcesContent":["import { writeFile } from \"node:fs/promises\";\nimport type { TestInfo } from \"@playwright/test\";\nimport type { BrowserContext, Page } from \"playwright\";\n\nexport const POM_FAILURE_ATTACHMENT_NAME = \"vue-pom-generator.failure\";\nexport const POM_FAILURE_SCREENSHOT_ATTACHMENT_NAME = \"vue-pom-generator.screenshot\";\n\nconst DEFAULT_CAPTURE_BUDGET_MS = 5_000;\nconst MAX_BUFFERED_EVENTS = 100;\nconst MAX_TEXT_LENGTH = 2_000;\nconst MAX_HTTP_FAILURES = 20;\nconst MAX_HTTP_FAILURE_BODY_LENGTH = 8_000;\nconst HTTP_FAILURE_BODY_SETTLE_BUDGET_MS = 500;\nconst POM_ACTIVE_ACTION_REGISTRY = Symbol.for(\"@immense/vue-pom-generator.active-action-registry\");\n\nexport interface PomManifestParameter {\n name: string;\n typeExpression?: string;\n type?: string;\n initializer?: string;\n hasQuestionToken?: boolean;\n isRestParameter?: boolean;\n}\n\nexport interface PomManifestMethod {\n name: string;\n kind: \"action\" | \"locator\";\n parameters: readonly PomManifestParameter[];\n}\n\nexport interface PomManifestEntry {\n testId: string;\n selectorPatternKind: \"static\" | \"parameterized\";\n generatedMethods: readonly PomManifestMethod[];\n targetPageObjectModelClass?: string;\n}\n\nexport interface PomManifestComponent {\n componentName: string;\n className: string;\n sourceFile: string;\n kind: \"component\" | \"view\";\n entries: readonly PomManifestEntry[];\n}\n\nexport type PomManifest = Readonly<Record<string, PomManifestComponent>>;\n\nexport interface PomActiveAction {\n componentName?: string;\n methodName: string;\n expectedTestIds: readonly string[];\n}\n\nexport interface PomRenderedElement {\n testId: string;\n tag: string;\n role: string | null;\n name: string | null;\n visible: boolean;\n enabled: boolean;\n}\n\nexport interface PomMethodAvailability {\n methodName: string;\n kind: \"action\" | \"locator\";\n signature: string;\n expectedTestIds: string[];\n state: \"present\" | \"hidden\" | \"disabled\" | \"absent\";\n}\n\nexport interface PomComponentAvailability {\n componentName: string;\n className: string;\n sourceFile: string;\n matchedTestIds: number;\n methods: PomMethodAvailability[];\n}\n\nexport interface PomPageFailureSnapshot {\n url: string;\n title: string | null;\n closed: boolean;\n ariaSnapshot: string | null;\n ariaSnapshotError?: string;\n renderedElements: PomRenderedElement[];\n component: PomComponentAvailability | null;\n routerNavigation?: PomRouterNavigationSnapshot | null;\n screenshotPath?: string;\n captureErrors: string[];\n}\n\nexport interface PomRouterNavigationSnapshot {\n id: number;\n status: \"pending\" | \"succeeded\" | \"failed\";\n stage: \"waiting-for-router-ready\" | \"pushing-route\" | \"complete\";\n targetName: string;\n error?: string;\n}\n\nexport interface PomFailureDiagnostics {\n schemaVersion: 1;\n capturedAt: string;\n captureBudgetMs: number;\n activeAction: PomActiveAction | null;\n pages: PomPageFailureSnapshot[];\n console: string[];\n pageErrors: string[];\n networkFailures: string[];\n httpFailures?: PomHttpFailure[];\n pendingRequests?: string[];\n jsonPath: string;\n}\n\nexport interface PomHttpFailure {\n status: number;\n method: string;\n url: string;\n contentType: string | null;\n body?: string;\n bodyCaptureError?: string;\n}\n\nexport type PomDiagnosticsTestInfo = Pick<TestInfo, \"attach\" | \"outputPath\">;\n\nexport interface PomFailureDiagnosticsOptions {\n captureBudgetMs?: number;\n testIdAttribute?: string;\n}\n\nexport interface PomFailureDiagnosticsCapture {\n capture: () => Promise<PomFailureDiagnostics>;\n}\n\ninterface EventBuffers {\n console: string[];\n pageErrors: string[];\n networkFailures: string[];\n httpFailures: PomHttpFailure[];\n httpFailureBodyCaptures: Set<Promise<void>>;\n pendingRequests: Map<object, { method: string; resourceType: string; startedAt: number; url: string }>;\n}\n\nfunction pushBounded(buffer: string[], value: string): void {\n buffer.push(value.slice(0, MAX_TEXT_LENGTH));\n if (buffer.length > MAX_BUFFERED_EVENTS) {\n buffer.splice(0, buffer.length - MAX_BUFFERED_EVENTS);\n }\n}\n\nfunction pushHttpFailureBounded(buffer: PomHttpFailure[], value: PomHttpFailure): void {\n buffer.push(value);\n if (buffer.length > MAX_HTTP_FAILURES) {\n buffer.splice(0, buffer.length - MAX_HTTP_FAILURES);\n }\n}\n\nfunction truncateText(value: string, maximum: number): string {\n if (value.length <= maximum) return value;\n return `${value.slice(0, maximum)}\\n… truncated ${value.length - maximum} characters …`;\n}\n\nfunction formatNetworkUrl(value: string): string {\n if (value.length <= 500) return value;\n\n try {\n const parsed = new URL(value);\n return `${parsed.origin}${parsed.pathname}${parsed.search ? \"?…\" : \"\"}`;\n }\n catch {\n return `${value.slice(0, 497)}…`;\n }\n}\n\nfunction errorMessage<T>(error: T): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction patternToRegExp(pattern: string): RegExp {\n const escaped = pattern.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n return new RegExp(`^${escaped.replace(/\\\\\\$\\\\\\{[^}]+\\\\\\}/g, \".+\")}$`);\n}\n\nfunction matchesTestId(pattern: string, actual: string): boolean {\n return pattern.includes(\"${\") ? patternToRegExp(pattern).test(actual) : pattern === actual;\n}\n\nfunction formatMethodSignature(method: PomManifestMethod): string {\n const parameters = method.parameters.map((parameter) => {\n const rest = parameter.isRestParameter ? \"...\" : \"\";\n const optional = parameter.hasQuestionToken ? \"?\" : \"\";\n // Normalized manifest parameters retain the original typeExpression for\n // provenance, but it may also contain the initializer (for example\n // `string = \"\"`). Prefer the split type to avoid printing it twice.\n const type = parameter.type ?? parameter.typeExpression ?? \"unknown\";\n const initializer = parameter.initializer === undefined ? \"\" : ` = ${parameter.initializer}`;\n return `${rest}${parameter.name}${optional}: ${type}${initializer}`;\n });\n return `${method.name}(${parameters.join(\", \")})`;\n}\n\nfunction availabilityState(elements: readonly PomRenderedElement[]): PomMethodAvailability[\"state\"] {\n if (!elements.length) return \"absent\";\n if (!elements.some(element => element.visible)) return \"hidden\";\n if (!elements.some(element => element.visible && element.enabled)) return \"disabled\";\n return \"present\";\n}\n\nfunction buildComponentAvailability(\n manifest: PomManifest,\n renderedElements: readonly PomRenderedElement[],\n activeComponentName?: string,\n): PomComponentAvailability | null {\n const renderedTestIds = Array.from(new Set(renderedElements.map(element => element.testId)));\n const candidates = Object.values(manifest).map((component) => ({\n component,\n matchedTestIds: renderedTestIds.filter(actual => component.entries.some(entry => matchesTestId(entry.testId, actual))).length,\n }));\n candidates.sort((a, b) => b.matchedTestIds - a.matchedTestIds\n || Number(b.component.kind === \"view\") - Number(a.component.kind === \"view\")\n || a.component.componentName.localeCompare(b.component.componentName));\n\n const activeCandidate = candidates.find(candidate => candidate.component.componentName === activeComponentName);\n const selected = activeCandidate ?? candidates[0];\n if (!selected || (selected.matchedTestIds === 0 && !activeCandidate)) return null;\n\n const methods = new Map<string, { method: PomManifestMethod; testIds: Set<string> }>();\n for (const entry of selected.component.entries) {\n for (const method of entry.generatedMethods) {\n const key = `${method.kind}:${method.name}`;\n const current = methods.get(key) ?? { method, testIds: new Set<string>() };\n current.testIds.add(entry.testId);\n methods.set(key, current);\n }\n }\n\n return {\n componentName: selected.component.componentName,\n className: selected.component.className,\n sourceFile: selected.component.sourceFile,\n matchedTestIds: selected.matchedTestIds,\n methods: Array.from(methods.values())\n .map(({ method, testIds }) => {\n const expectedTestIds = Array.from(testIds).sort((a, b) => a.localeCompare(b));\n const matchingElements = renderedElements.filter(element => expectedTestIds.some(pattern => matchesTestId(pattern, element.testId)));\n return {\n methodName: method.name,\n kind: method.kind,\n signature: formatMethodSignature(method),\n expectedTestIds,\n state: availabilityState(matchingElements),\n } satisfies PomMethodAvailability;\n })\n .sort((a, b) => a.methodName.localeCompare(b.methodName)),\n };\n}\n\nfunction remainingMilliseconds(deadline: number): number {\n return Math.max(0, deadline - Date.now());\n}\n\nasync function withinBudget<T>(deadline: number, operation: () => Promise<T>): Promise<T> {\n const remaining = remainingMilliseconds(deadline);\n if (remaining <= 0) throw new Error(\"diagnostic capture budget exhausted\");\n\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n return await Promise.race([\n operation(),\n new Promise<T>((_resolve, reject) => {\n timer = setTimeout(() => reject(new Error(\"diagnostic capture budget exhausted\")), remaining);\n }),\n ]);\n }\n finally {\n if (timer) clearTimeout(timer);\n }\n}\n\nfunction installPageListeners(page: Page, buffers: EventBuffers): void {\n page.on(\"console\", message => pushBounded(buffers.console, `[${message.type()}] ${message.text()}`));\n page.on(\"pageerror\", error => pushBounded(buffers.pageErrors, errorMessage(error)));\n page.on(\"request\", (request) => {\n buffers.pendingRequests.set(request, {\n method: request.method(),\n resourceType: request.resourceType(),\n startedAt: Date.now(),\n url: request.url(),\n });\n });\n page.on(\"requestfinished\", request => buffers.pendingRequests.delete(request));\n page.on(\"requestfailed\", (request) => {\n buffers.pendingRequests.delete(request);\n const failure = request.failure()?.errorText ?? \"request failed\";\n pushBounded(buffers.networkFailures, `${request.method()} ${formatNetworkUrl(request.url())} — ${failure}`);\n });\n page.on(\"response\", (response) => {\n if (response.status() >= 400) {\n pushBounded(buffers.networkFailures, `${response.status()} ${response.request().method()} ${formatNetworkUrl(response.url())}`);\n const failure: PomHttpFailure = {\n status: response.status(),\n method: response.request().method(),\n url: formatNetworkUrl(response.url()),\n contentType: response.headers()[\"content-type\"] ?? null,\n };\n pushHttpFailureBounded(buffers.httpFailures, failure);\n\n const capture: Promise<void> = response.text()\n .then((body) => {\n if (body) failure.body = truncateText(body, MAX_HTTP_FAILURE_BODY_LENGTH);\n })\n .catch((error) => {\n failure.bodyCaptureError = errorMessage(error);\n })\n .finally(() => buffers.httpFailureBodyCaptures.delete(capture));\n buffers.httpFailureBodyCaptures.add(capture);\n }\n });\n}\n\nasync function settleHttpFailureBodies(buffers: EventBuffers, deadline: number): Promise<void> {\n const captures = Array.from(buffers.httpFailureBodyCaptures);\n if (!captures.length) return;\n\n const waitMs = Math.min(HTTP_FAILURE_BODY_SETTLE_BUDGET_MS, remainingMilliseconds(deadline));\n if (waitMs <= 0) return;\n\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n await Promise.race([\n Promise.allSettled(captures),\n new Promise<void>((resolve) => {\n timer = setTimeout(resolve, waitMs);\n }),\n ]);\n }\n finally {\n if (timer) clearTimeout(timer);\n }\n}\n\nasync function captureRenderedElements(\n page: Page,\n testIdAttribute: string,\n): Promise<{ title: string; elements: PomRenderedElement[]; routerNavigation: PomRouterNavigationSnapshot | null }> {\n return page.evaluate(({ attribute, routerGlobalName }) => {\n const elements = Array.from(document.querySelectorAll(`[${CSS.escape(attribute)}]`));\n const isVisibleElement = (candidate: HTMLElement) => {\n const style = getComputedStyle(candidate);\n const rect = candidate.getBoundingClientRect();\n return style.display !== \"none\"\n && style.visibility !== \"hidden\"\n && Number.parseFloat(style.opacity || \"1\") > 0\n && rect.width > 0\n && rect.height > 0;\n };\n const rendered = elements.map((element) => {\n const htmlElement = element as HTMLElement;\n const disabled = (\"disabled\" in htmlElement && Boolean((htmlElement as HTMLButtonElement).disabled))\n || htmlElement.getAttribute(\"aria-disabled\") === \"true\";\n const text = htmlElement.textContent?.replace(/\\s+/g, \" \").trim();\n const inputType = htmlElement instanceof HTMLInputElement ? htmlElement.type.toLowerCase() : \"\";\n const labels = htmlElement instanceof HTMLInputElement ? Array.from(htmlElement.labels ?? []) : [];\n const labelText = labels.length\n ? labels\n .map(label => label.textContent?.replace(/\\s+/g, \" \").trim())\n .filter((value): value is string => Boolean(value))\n .join(\" \")\n : \"\";\n const visible = isVisibleElement(htmlElement)\n || ((inputType === \"checkbox\" || inputType === \"radio\") && labels.some(label => isVisibleElement(label)));\n const role = htmlElement.getAttribute(\"role\")\n ?? (htmlElement.tagName === \"BUTTON\" ? \"button\" : null)\n ?? (htmlElement.tagName === \"A\" && htmlElement.hasAttribute(\"href\") ? \"link\" : null)\n ?? (inputType === \"checkbox\" || inputType === \"radio\" ? inputType : null)\n ?? (htmlElement.tagName === \"TEXTAREA\" || (htmlElement.tagName === \"INPUT\" && inputType !== \"hidden\") ? \"textbox\" : null)\n ?? (htmlElement.tagName === \"SELECT\" ? \"combobox\" : null);\n const name = htmlElement.getAttribute(\"aria-label\")\n ?? htmlElement.getAttribute(\"title\")\n ?? (labelText || null)\n ?? (text ? text.slice(0, 160) : null);\n return {\n testId: htmlElement.getAttribute(attribute) ?? \"\",\n tag: htmlElement.tagName.toLowerCase(),\n role,\n name,\n visible,\n enabled: !disabled,\n };\n }).filter(element => element.testId.length > 0);\n\n const routerBridge = Reflect.get(globalThis, routerGlobalName) as\n | { navigation?: PomRouterNavigationSnapshot }\n | undefined;\n const rawNavigation = routerBridge?.navigation;\n const routerNavigation = rawNavigation\n ? {\n id: rawNavigation.id,\n status: rawNavigation.status,\n stage: rawNavigation.stage,\n targetName: rawNavigation.targetName,\n ...(rawNavigation.error ? { error: rawNavigation.error } : {}),\n }\n : null;\n\n return { title: document.title, elements: rendered, routerNavigation };\n }, { attribute: testIdAttribute, routerGlobalName: \"__vuePomGeneratorRouter\" });\n}\n\nasync function capturePage(\n page: Page,\n pageIndex: number,\n manifest: PomManifest,\n testInfo: PomDiagnosticsTestInfo,\n testIdAttribute: string,\n deadline: number,\n activeAction: PomActiveAction | null,\n): Promise<PomPageFailureSnapshot> {\n const captureErrors: string[] = [];\n const snapshot: PomPageFailureSnapshot = {\n url: page.url(),\n title: null,\n closed: page.isClosed(),\n ariaSnapshot: null,\n renderedElements: [],\n component: null,\n routerNavigation: null,\n captureErrors,\n };\n if (snapshot.closed) return snapshot;\n\n try {\n const rendered = await withinBudget(deadline, () => captureRenderedElements(page, testIdAttribute));\n snapshot.title = rendered.title;\n snapshot.renderedElements = rendered.elements;\n snapshot.component = buildComponentAvailability(manifest, rendered.elements, activeAction?.componentName);\n snapshot.routerNavigation = rendered.routerNavigation;\n }\n catch (error) {\n captureErrors.push(`DOM inventory: ${errorMessage(error)}`);\n }\n\n try {\n snapshot.ariaSnapshot = await withinBudget(deadline, () => page.locator(\"body\").ariaSnapshot({\n timeout: remainingMilliseconds(deadline),\n }));\n }\n catch (error) {\n snapshot.ariaSnapshotError = errorMessage(error);\n }\n\n if (pageIndex === 0 && remainingMilliseconds(deadline) > 0) {\n const screenshotPath = testInfo.outputPath(\"vue-pom-generator-failure.png\");\n try {\n await withinBudget(deadline, () => page.screenshot({\n path: screenshotPath,\n fullPage: true,\n timeout: remainingMilliseconds(deadline),\n }));\n await testInfo.attach(POM_FAILURE_SCREENSHOT_ATTACHMENT_NAME, { path: screenshotPath, contentType: \"image/png\" });\n snapshot.screenshotPath = screenshotPath;\n }\n catch (error) {\n captureErrors.push(`Screenshot: ${errorMessage(error)}`);\n }\n }\n\n return snapshot;\n}\n\nexport function recordPomAction(page: object, action: PomActiveAction): void {\n const globalRecord = globalThis as typeof globalThis & {\n [POM_ACTIVE_ACTION_REGISTRY]?: WeakMap<object, PomActiveAction>;\n };\n const registry = globalRecord[POM_ACTIVE_ACTION_REGISTRY] ?? new WeakMap<object, PomActiveAction>();\n globalRecord[POM_ACTIVE_ACTION_REGISTRY] = registry;\n registry.set(page, {\n ...action,\n expectedTestIds: [...action.expectedTestIds],\n });\n}\n\nexport function getActivePomAction(page: object): PomActiveAction | null {\n const globalRecord = globalThis as typeof globalThis & {\n [POM_ACTIVE_ACTION_REGISTRY]?: WeakMap<object, PomActiveAction>;\n };\n return globalRecord[POM_ACTIVE_ACTION_REGISTRY]?.get(page) ?? null;\n}\n\nexport function installPomFailureDiagnostics(\n page: Page,\n manifest: PomManifest,\n testInfo: PomDiagnosticsTestInfo,\n options: PomFailureDiagnosticsOptions = {},\n): PomFailureDiagnosticsCapture {\n const context: BrowserContext = page.context();\n const pages = new Set<Page>();\n const buffers: EventBuffers = {\n console: [],\n pageErrors: [],\n networkFailures: [],\n httpFailures: [],\n httpFailureBodyCaptures: new Set(),\n pendingRequests: new Map(),\n };\n let captured: Promise<PomFailureDiagnostics> | null = null;\n\n const registerPage = (candidate: Page) => {\n if (pages.has(candidate)) return;\n pages.add(candidate);\n installPageListeners(candidate, buffers);\n };\n for (const existingPage of context.pages()) registerPage(existingPage);\n context.on(\"page\", registerPage);\n\n return {\n capture() {\n if (captured) return captured;\n captured = (async () => {\n const captureBudgetMs = options.captureBudgetMs ?? DEFAULT_CAPTURE_BUDGET_MS;\n const deadline = Date.now() + captureBudgetMs;\n await settleHttpFailureBodies(buffers, deadline);\n const activeAction = getActivePomAction(page);\n const pageSnapshots: PomPageFailureSnapshot[] = [];\n for (const [index, candidate] of Array.from(pages).entries()) {\n pageSnapshots.push(await capturePage(\n candidate,\n index,\n manifest,\n testInfo,\n options.testIdAttribute ?? \"data-testid\",\n deadline,\n activeAction,\n ));\n }\n\n const jsonPath = testInfo.outputPath(\"vue-pom-generator-failure.json\");\n const diagnostics: PomFailureDiagnostics = {\n schemaVersion: 1,\n capturedAt: new Date().toISOString(),\n captureBudgetMs,\n activeAction,\n pages: pageSnapshots,\n console: [...buffers.console],\n pageErrors: [...buffers.pageErrors],\n networkFailures: [...buffers.networkFailures],\n httpFailures: buffers.httpFailures.map(failure => ({ ...failure })),\n pendingRequests: Array.from(buffers.pendingRequests.values())\n .map(request => `${request.method} ${request.resourceType} ${formatNetworkUrl(request.url)} — pending ${Date.now() - request.startedAt}ms`)\n .slice(-MAX_BUFFERED_EVENTS),\n jsonPath,\n };\n await writeFile(jsonPath, `${JSON.stringify(diagnostics, null, 2)}\\n`, \"utf8\");\n await testInfo.attach(POM_FAILURE_ATTACHMENT_NAME, { path: jsonPath, contentType: \"application/json\" });\n return diagnostics;\n })();\n return captured;\n },\n };\n}\n","import { readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type {\n Reporter,\n TestCase,\n TestResult,\n} from \"@playwright/test/reporter\";\n\nimport {\n POM_FAILURE_ATTACHMENT_NAME,\n type PomFailureDiagnostics,\n type PomPageFailureSnapshot,\n} from \"../class-generation/diagnostics\";\n\nconst DEFAULT_MAX_OUTPUT_CHARACTERS = 32_000;\nconst DEFAULT_MAX_METHODS = 80;\nconst DEFAULT_MAX_ELEMENTS = 80;\nconst DEFAULT_MAX_EVENTS = 30;\nconst DEFAULT_MAX_ARIA_CHARACTERS = 8_000;\n\nexport interface PomFailureReporterOptions {\n maxOutputCharacters?: number;\n}\n\nfunction shellQuote(value: string): string {\n let quoted = \"'\";\n for (const character of value) {\n quoted += character === \"'\" ? `'\"'\"'` : character;\n }\n return `${quoted}'`;\n}\n\nfunction readDiagnostics(result: TestResult): PomFailureDiagnostics | null {\n const attachment = result.attachments.find(candidate => candidate.name === POM_FAILURE_ATTACHMENT_NAME);\n if (!attachment) return null;\n\n try {\n if (attachment.body) return JSON.parse(attachment.body.toString(\"utf8\")) as PomFailureDiagnostics;\n if (attachment.path) return JSON.parse(readFileSync(attachment.path, \"utf8\")) as PomFailureDiagnostics;\n }\n catch {\n return null;\n }\n return null;\n}\n\nfunction appendLimited(lines: string[], heading: string, values: readonly string[], limit: number): void {\n if (!values.length) return;\n lines.push(heading);\n for (const value of values.slice(-limit)) lines.push(` ${value}`);\n const omitted = Math.max(0, values.length - limit);\n if (omitted) lines.push(` … ${omitted} earlier entries omitted`);\n}\n\nfunction formatPage(lines: string[], page: PomPageFailureSnapshot, index: number): void {\n lines.push(`Page ${index + 1}: ${page.url || \"<no URL>\"}`);\n if (page.title) lines.push(`Title: ${page.title}`);\n if (page.closed) lines.push(\"State: page was already closed\");\n if (page.routerNavigation) {\n lines.push(\n `Generated router navigation: ${page.routerNavigation.status} at ${page.routerNavigation.stage} -> ${page.routerNavigation.targetName}`,\n );\n if (page.routerNavigation.error) lines.push(`Router error: ${page.routerNavigation.error}`);\n }\n\n if (page.component) {\n const available = page.component.methods.filter(method => method.state === \"present\").length;\n lines.push(\n `Generated POM match: ${page.component.className} (${page.component.matchedTestIds} rendered test ids; ${available}/${page.component.methods.length} methods currently present)`,\n );\n lines.push(`Vue source: ${page.component.sourceFile}`);\n for (const method of page.component.methods.slice(0, DEFAULT_MAX_METHODS)) {\n lines.push(` [${method.state}] ${method.signature} <- ${method.expectedTestIds.join(\" | \")}`);\n }\n const omittedMethods = Math.max(0, page.component.methods.length - DEFAULT_MAX_METHODS);\n if (omittedMethods) lines.push(` … ${omittedMethods} generated methods omitted; see JSON`);\n lines.push(\" Availability describes the current page state; an unavailable method is not inherently an error.\");\n }\n else {\n lines.push(\"Generated POM match: no active page POM identified from rendered test ids\");\n }\n\n if (page.renderedElements.length) {\n lines.push(\"Rendered generated elements:\");\n for (const element of page.renderedElements.slice(0, DEFAULT_MAX_ELEMENTS)) {\n const state = `${element.visible ? \"visible\" : \"hidden\"}/${element.enabled ? \"enabled\" : \"disabled\"}`;\n const semantics = [element.role ? `role=${element.role}` : null, element.name ? `name=${JSON.stringify(element.name)}` : null]\n .filter(Boolean)\n .join(\" \");\n lines.push(` ${element.testId} <${element.tag}> ${state}${semantics ? ` ${semantics}` : \"\"}`);\n }\n const omittedElements = Math.max(0, page.renderedElements.length - DEFAULT_MAX_ELEMENTS);\n if (omittedElements) lines.push(` … ${omittedElements} rendered elements omitted; see JSON`);\n }\n\n if (page.ariaSnapshot) {\n const aria = page.ariaSnapshot.slice(0, DEFAULT_MAX_ARIA_CHARACTERS);\n lines.push(\"Accessibility snapshot:\", aria);\n if (aria.length < page.ariaSnapshot.length) {\n lines.push(` … ${page.ariaSnapshot.length - aria.length} accessibility-snapshot characters omitted; see JSON`);\n }\n }\n else if (page.ariaSnapshotError) {\n lines.push(`Accessibility snapshot unavailable: ${page.ariaSnapshotError}`);\n }\n\n appendLimited(lines, \"Capture warnings:\", page.captureErrors, DEFAULT_MAX_EVENTS);\n}\n\nfunction formatErrors(result: TestResult): string[] {\n if (!result.errors.length) return [\"Playwright error: failure did not include an Error object\"];\n return result.errors.map((error, index) => {\n const value = error.stack ?? error.message ?? error.value ?? \"Unknown error\";\n return `Error ${index + 1}:\\n${String(value).slice(0, 6_000)}`;\n });\n}\n\nfunction isolatedCommand(test: TestCase): string {\n const location = `${path.relative(process.cwd(), test.location.file)}:${test.location.line}`;\n return `npx playwright test ${shellQuote(location)} --project=${shellQuote(test.parent.project()?.name ?? \"chromium\")} --max-failures=1`;\n}\n\nfunction boundOutput(lines: string[], footer: string[], maximum: number): string {\n const full = [...lines, ...footer].join(\"\\n\");\n if (full.length <= maximum) return full;\n\n const footerText = footer.join(\"\\n\");\n const marker = `\\n… report truncated by ${full.length - maximum} characters; use the JSON artifact for complete structured diagnostics …\\n`;\n const available = Math.max(0, maximum - footerText.length - marker.length - 1);\n return `${lines.join(\"\\n\").slice(0, available)}${marker}${footerText}`;\n}\n\nexport function formatPomFailureReport(\n test: TestCase,\n result: TestResult,\n diagnostics: PomFailureDiagnostics | null,\n options: PomFailureReporterOptions = {},\n): string {\n const title = test.titlePath().join(\" › \");\n const lines = [\n \"================ VUE POM FAILURE DIAGNOSTICS ================\",\n `Test: ${title}`,\n `Location: ${test.location.file}:${test.location.line}:${test.location.column}`,\n `Attempt: ${result.retry + 1}`,\n `Status: ${result.status} (expected ${test.expectedStatus})`,\n ...formatErrors(result),\n ];\n\n if (diagnostics) {\n if (diagnostics.activeAction) {\n lines.push(\n `Active generated action: ${diagnostics.activeAction.componentName ? `${diagnostics.activeAction.componentName}.` : \"\"}${diagnostics.activeAction.methodName}`,\n );\n if (diagnostics.activeAction.expectedTestIds.length) {\n lines.push(`Expected generated test ids: ${diagnostics.activeAction.expectedTestIds.join(\" | \")}`);\n }\n }\n else {\n lines.push(\"Active generated action: none recorded\");\n }\n diagnostics.pages.forEach((page, index) => formatPage(lines, page, index));\n appendLimited(lines, \"Browser console:\", diagnostics.console, DEFAULT_MAX_EVENTS);\n appendLimited(lines, \"Page errors:\", diagnostics.pageErrors, DEFAULT_MAX_EVENTS);\n appendLimited(lines, \"Network failures:\", diagnostics.networkFailures, DEFAULT_MAX_EVENTS);\n appendLimited(\n lines,\n \"HTTP error responses:\",\n (diagnostics.httpFailures ?? []).map((failure) => {\n const heading = `${failure.status} ${failure.method} ${failure.url}${failure.contentType ? ` (${failure.contentType})` : \"\"}`;\n if (failure.body) return `${heading}\\nResponse body:\\n${failure.body}`;\n if (failure.bodyCaptureError) return `${heading}\\nResponse body unavailable: ${failure.bodyCaptureError}`;\n return heading;\n }),\n DEFAULT_MAX_EVENTS,\n );\n appendLimited(lines, \"Requests still pending at failure:\", diagnostics.pendingRequests ?? [], DEFAULT_MAX_EVENTS);\n }\n else {\n lines.push(\n \"Browser diagnostics: unavailable. The test did not initialize generated POM fixtures, the page closed before capture, or capture itself failed.\",\n );\n }\n\n const footer = [\n diagnostics ? `Structured diagnostics: ${diagnostics.jsonPath}` : \"Structured diagnostics: unavailable\",\n `Isolated rerun: ${isolatedCommand(test)}`,\n \"=============================================================\",\n ];\n return boundOutput(lines, footer, options.maxOutputCharacters ?? DEFAULT_MAX_OUTPUT_CHARACTERS);\n}\n\nexport default class PomFailureReporter implements Reporter {\n private readonly options: PomFailureReporterOptions;\n\n public constructor(options: PomFailureReporterOptions = {}) {\n this.options = options;\n }\n\n public onTestEnd(test: TestCase, result: TestResult): void {\n if (result.status === test.expectedStatus || result.status === \"skipped\") return;\n const diagnostics = readDiagnostics(result);\n process.stdout.write(`${formatPomFailureReport(test, result, diagnostics, this.options)}\\n`);\n }\n\n public printsToStdio(): boolean {\n return true;\n }\n}\n"],"names":["readFileSync"],"mappings":";;;;;AAIO,MAAM,8BAA8B;ACU3C,MAAM,gCAAgC;AACtC,MAAM,sBAAsB;AAC5B,MAAM,uBAAuB;AAC7B,MAAM,qBAAqB;AAC3B,MAAM,8BAA8B;AAMpC,SAAS,WAAW,OAAuB;AACzC,MAAI,SAAS;AACb,aAAW,aAAa,OAAO;AAC7B,cAAU,cAAc,MAAM,UAAU;AAAA,EAC1C;AACA,SAAO,GAAG,MAAM;AAClB;AAEA,SAAS,gBAAgB,QAAkD;AACzE,QAAM,aAAa,OAAO,YAAY,KAAK,CAAA,cAAa,UAAU,SAAS,2BAA2B;AACtG,MAAI,CAAC,WAAY,QAAO;AAExB,MAAI;AACF,QAAI,WAAW,KAAM,QAAO,KAAK,MAAM,WAAW,KAAK,SAAS,MAAM,CAAC;AACvE,QAAI,WAAW,KAAM,QAAO,KAAK,MAAMA,GAAAA,aAAa,WAAW,MAAM,MAAM,CAAC;AAAA,EAC9E,QACM;AACJ,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,SAAS,cAAc,OAAiB,SAAiB,QAA2B,OAAqB;AACvG,MAAI,CAAC,OAAO,OAAQ;AACpB,QAAM,KAAK,OAAO;AAClB,aAAW,SAAS,OAAO,MAAM,CAAC,KAAK,EAAG,OAAM,KAAK,KAAK,KAAK,EAAE;AACjE,QAAM,UAAU,KAAK,IAAI,GAAG,OAAO,SAAS,KAAK;AACjD,MAAI,QAAS,OAAM,KAAK,OAAO,OAAO,0BAA0B;AAClE;AAEA,SAAS,WAAW,OAAiB,MAA8B,OAAqB;AACtF,QAAM,KAAK,QAAQ,QAAQ,CAAC,KAAK,KAAK,OAAO,UAAU,EAAE;AACzD,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EAC7F;AAAA,EAEO,gBAAyB;AAC9B,WAAO;AAAA,EACT;AACF;;;"}
@@ -0,0 +1,13 @@
1
+ import type { Reporter, TestCase, TestResult } from "@playwright/test/reporter";
2
+ import { type PomFailureDiagnostics } from "../class-generation/diagnostics";
3
+ export interface PomFailureReporterOptions {
4
+ maxOutputCharacters?: number;
5
+ }
6
+ export declare function formatPomFailureReport(test: TestCase, result: TestResult, diagnostics: PomFailureDiagnostics | null, options?: PomFailureReporterOptions): string;
7
+ export default class PomFailureReporter implements Reporter {
8
+ private readonly options;
9
+ constructor(options?: PomFailureReporterOptions);
10
+ onTestEnd(test: TestCase, result: TestResult): void;
11
+ printsToStdio(): boolean;
12
+ }
13
+ //# sourceMappingURL=reporter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../../playwright/reporter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACX,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAEL,KAAK,qBAAqB,EAE3B,MAAM,iCAAiC,CAAC;AAQzC,MAAM,WAAW,yBAAyB;IACxC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AA8GD,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,UAAU,EAClB,WAAW,EAAE,qBAAqB,GAAG,IAAI,EACzC,OAAO,GAAE,yBAA8B,GACtC,MAAM,CAoDR;AAED,MAAM,CAAC,OAAO,OAAO,kBAAmB,YAAW,QAAQ;IACzD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4B;gBAEjC,OAAO,GAAE,yBAA8B;IAInD,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI;IAMnD,aAAa,IAAI,OAAO;CAGhC"}
@@ -0,0 +1,174 @@
1
+ import { readFileSync } from "node:fs";
2
+ import path from "node:path";
3
+ import "node:fs/promises";
4
+ const POM_FAILURE_ATTACHMENT_NAME = "vue-pom-generator.failure";
5
+ const DEFAULT_MAX_OUTPUT_CHARACTERS = 32e3;
6
+ const DEFAULT_MAX_METHODS = 80;
7
+ const DEFAULT_MAX_ELEMENTS = 80;
8
+ const DEFAULT_MAX_EVENTS = 30;
9
+ const DEFAULT_MAX_ARIA_CHARACTERS = 8e3;
10
+ function shellQuote(value) {
11
+ let quoted = "'";
12
+ for (const character of value) {
13
+ quoted += character === "'" ? `'"'"'` : character;
14
+ }
15
+ return `${quoted}'`;
16
+ }
17
+ function readDiagnostics(result) {
18
+ const attachment = result.attachments.find((candidate) => candidate.name === POM_FAILURE_ATTACHMENT_NAME);
19
+ if (!attachment) return null;
20
+ try {
21
+ if (attachment.body) return JSON.parse(attachment.body.toString("utf8"));
22
+ if (attachment.path) return JSON.parse(readFileSync(attachment.path, "utf8"));
23
+ } catch {
24
+ return null;
25
+ }
26
+ return null;
27
+ }
28
+ function appendLimited(lines, heading, values, limit) {
29
+ if (!values.length) return;
30
+ lines.push(heading);
31
+ for (const value of values.slice(-limit)) lines.push(` ${value}`);
32
+ const omitted = Math.max(0, values.length - limit);
33
+ if (omitted) lines.push(` … ${omitted} earlier entries omitted`);
34
+ }
35
+ function formatPage(lines, page, index) {
36
+ lines.push(`Page ${index + 1}: ${page.url || "<no URL>"}`);
37
+ if (page.title) lines.push(`Title: ${page.title}`);
38
+ if (page.closed) lines.push("State: page was already closed");
39
+ if (page.routerNavigation) {
40
+ lines.push(
41
+ `Generated router navigation: ${page.routerNavigation.status} at ${page.routerNavigation.stage} -> ${page.routerNavigation.targetName}`
42
+ );
43
+ if (page.routerNavigation.error) lines.push(`Router error: ${page.routerNavigation.error}`);
44
+ }
45
+ if (page.component) {
46
+ const available = page.component.methods.filter((method) => method.state === "present").length;
47
+ lines.push(
48
+ `Generated POM match: ${page.component.className} (${page.component.matchedTestIds} rendered test ids; ${available}/${page.component.methods.length} methods currently present)`
49
+ );
50
+ lines.push(`Vue source: ${page.component.sourceFile}`);
51
+ for (const method of page.component.methods.slice(0, DEFAULT_MAX_METHODS)) {
52
+ lines.push(` [${method.state}] ${method.signature} <- ${method.expectedTestIds.join(" | ")}`);
53
+ }
54
+ const omittedMethods = Math.max(0, page.component.methods.length - DEFAULT_MAX_METHODS);
55
+ if (omittedMethods) lines.push(` … ${omittedMethods} generated methods omitted; see JSON`);
56
+ lines.push(" Availability describes the current page state; an unavailable method is not inherently an error.");
57
+ } else {
58
+ lines.push("Generated POM match: no active page POM identified from rendered test ids");
59
+ }
60
+ if (page.renderedElements.length) {
61
+ lines.push("Rendered generated elements:");
62
+ for (const element of page.renderedElements.slice(0, DEFAULT_MAX_ELEMENTS)) {
63
+ const state = `${element.visible ? "visible" : "hidden"}/${element.enabled ? "enabled" : "disabled"}`;
64
+ const semantics = [element.role ? `role=${element.role}` : null, element.name ? `name=${JSON.stringify(element.name)}` : null].filter(Boolean).join(" ");
65
+ lines.push(` ${element.testId} <${element.tag}> ${state}${semantics ? ` ${semantics}` : ""}`);
66
+ }
67
+ const omittedElements = Math.max(0, page.renderedElements.length - DEFAULT_MAX_ELEMENTS);
68
+ if (omittedElements) lines.push(` … ${omittedElements} rendered elements omitted; see JSON`);
69
+ }
70
+ if (page.ariaSnapshot) {
71
+ const aria = page.ariaSnapshot.slice(0, DEFAULT_MAX_ARIA_CHARACTERS);
72
+ lines.push("Accessibility snapshot:", aria);
73
+ if (aria.length < page.ariaSnapshot.length) {
74
+ lines.push(` … ${page.ariaSnapshot.length - aria.length} accessibility-snapshot characters omitted; see JSON`);
75
+ }
76
+ } else if (page.ariaSnapshotError) {
77
+ lines.push(`Accessibility snapshot unavailable: ${page.ariaSnapshotError}`);
78
+ }
79
+ appendLimited(lines, "Capture warnings:", page.captureErrors, DEFAULT_MAX_EVENTS);
80
+ }
81
+ function formatErrors(result) {
82
+ if (!result.errors.length) return ["Playwright error: failure did not include an Error object"];
83
+ return result.errors.map((error, index) => {
84
+ const value = error.stack ?? error.message ?? error.value ?? "Unknown error";
85
+ return `Error ${index + 1}:
86
+ ${String(value).slice(0, 6e3)}`;
87
+ });
88
+ }
89
+ function isolatedCommand(test) {
90
+ const location = `${path.relative(process.cwd(), test.location.file)}:${test.location.line}`;
91
+ return `npx playwright test ${shellQuote(location)} --project=${shellQuote(test.parent.project()?.name ?? "chromium")} --max-failures=1`;
92
+ }
93
+ function boundOutput(lines, footer, maximum) {
94
+ const full = [...lines, ...footer].join("\n");
95
+ if (full.length <= maximum) return full;
96
+ const footerText = footer.join("\n");
97
+ const marker = `
98
+ … report truncated by ${full.length - maximum} characters; use the JSON artifact for complete structured diagnostics …
99
+ `;
100
+ const available = Math.max(0, maximum - footerText.length - marker.length - 1);
101
+ return `${lines.join("\n").slice(0, available)}${marker}${footerText}`;
102
+ }
103
+ function formatPomFailureReport(test, result, diagnostics, options = {}) {
104
+ const title = test.titlePath().join(" › ");
105
+ const lines = [
106
+ "================ VUE POM FAILURE DIAGNOSTICS ================",
107
+ `Test: ${title}`,
108
+ `Location: ${test.location.file}:${test.location.line}:${test.location.column}`,
109
+ `Attempt: ${result.retry + 1}`,
110
+ `Status: ${result.status} (expected ${test.expectedStatus})`,
111
+ ...formatErrors(result)
112
+ ];
113
+ if (diagnostics) {
114
+ if (diagnostics.activeAction) {
115
+ lines.push(
116
+ `Active generated action: ${diagnostics.activeAction.componentName ? `${diagnostics.activeAction.componentName}.` : ""}${diagnostics.activeAction.methodName}`
117
+ );
118
+ if (diagnostics.activeAction.expectedTestIds.length) {
119
+ lines.push(`Expected generated test ids: ${diagnostics.activeAction.expectedTestIds.join(" | ")}`);
120
+ }
121
+ } else {
122
+ lines.push("Active generated action: none recorded");
123
+ }
124
+ diagnostics.pages.forEach((page, index) => formatPage(lines, page, index));
125
+ appendLimited(lines, "Browser console:", diagnostics.console, DEFAULT_MAX_EVENTS);
126
+ appendLimited(lines, "Page errors:", diagnostics.pageErrors, DEFAULT_MAX_EVENTS);
127
+ appendLimited(lines, "Network failures:", diagnostics.networkFailures, DEFAULT_MAX_EVENTS);
128
+ appendLimited(
129
+ lines,
130
+ "HTTP error responses:",
131
+ (diagnostics.httpFailures ?? []).map((failure) => {
132
+ const heading = `${failure.status} ${failure.method} ${failure.url}${failure.contentType ? ` (${failure.contentType})` : ""}`;
133
+ if (failure.body) return `${heading}
134
+ Response body:
135
+ ${failure.body}`;
136
+ if (failure.bodyCaptureError) return `${heading}
137
+ Response body unavailable: ${failure.bodyCaptureError}`;
138
+ return heading;
139
+ }),
140
+ DEFAULT_MAX_EVENTS
141
+ );
142
+ appendLimited(lines, "Requests still pending at failure:", diagnostics.pendingRequests ?? [], DEFAULT_MAX_EVENTS);
143
+ } else {
144
+ lines.push(
145
+ "Browser diagnostics: unavailable. The test did not initialize generated POM fixtures, the page closed before capture, or capture itself failed."
146
+ );
147
+ }
148
+ const footer = [
149
+ diagnostics ? `Structured diagnostics: ${diagnostics.jsonPath}` : "Structured diagnostics: unavailable",
150
+ `Isolated rerun: ${isolatedCommand(test)}`,
151
+ "============================================================="
152
+ ];
153
+ return boundOutput(lines, footer, options.maxOutputCharacters ?? DEFAULT_MAX_OUTPUT_CHARACTERS);
154
+ }
155
+ class PomFailureReporter {
156
+ options;
157
+ constructor(options = {}) {
158
+ this.options = options;
159
+ }
160
+ onTestEnd(test, result) {
161
+ if (result.status === test.expectedStatus || result.status === "skipped") return;
162
+ const diagnostics = readDiagnostics(result);
163
+ process.stdout.write(`${formatPomFailureReport(test, result, diagnostics, this.options)}
164
+ `);
165
+ }
166
+ printsToStdio() {
167
+ return true;
168
+ }
169
+ }
170
+ export {
171
+ PomFailureReporter as default,
172
+ formatPomFailureReport
173
+ };
174
+ //# sourceMappingURL=reporter.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reporter.mjs","sources":["../../class-generation/diagnostics.ts","../../playwright/reporter.ts"],"sourcesContent":["import { writeFile } from \"node:fs/promises\";\nimport type { TestInfo } from \"@playwright/test\";\nimport type { BrowserContext, Page } from \"playwright\";\n\nexport const POM_FAILURE_ATTACHMENT_NAME = \"vue-pom-generator.failure\";\nexport const POM_FAILURE_SCREENSHOT_ATTACHMENT_NAME = \"vue-pom-generator.screenshot\";\n\nconst DEFAULT_CAPTURE_BUDGET_MS = 5_000;\nconst MAX_BUFFERED_EVENTS = 100;\nconst MAX_TEXT_LENGTH = 2_000;\nconst MAX_HTTP_FAILURES = 20;\nconst MAX_HTTP_FAILURE_BODY_LENGTH = 8_000;\nconst HTTP_FAILURE_BODY_SETTLE_BUDGET_MS = 500;\nconst POM_ACTIVE_ACTION_REGISTRY = Symbol.for(\"@immense/vue-pom-generator.active-action-registry\");\n\nexport interface PomManifestParameter {\n name: string;\n typeExpression?: string;\n type?: string;\n initializer?: string;\n hasQuestionToken?: boolean;\n isRestParameter?: boolean;\n}\n\nexport interface PomManifestMethod {\n name: string;\n kind: \"action\" | \"locator\";\n parameters: readonly PomManifestParameter[];\n}\n\nexport interface PomManifestEntry {\n testId: string;\n selectorPatternKind: \"static\" | \"parameterized\";\n generatedMethods: readonly PomManifestMethod[];\n targetPageObjectModelClass?: string;\n}\n\nexport interface PomManifestComponent {\n componentName: string;\n className: string;\n sourceFile: string;\n kind: \"component\" | \"view\";\n entries: readonly PomManifestEntry[];\n}\n\nexport type PomManifest = Readonly<Record<string, PomManifestComponent>>;\n\nexport interface PomActiveAction {\n componentName?: string;\n methodName: string;\n expectedTestIds: readonly string[];\n}\n\nexport interface PomRenderedElement {\n testId: string;\n tag: string;\n role: string | null;\n name: string | null;\n visible: boolean;\n enabled: boolean;\n}\n\nexport interface PomMethodAvailability {\n methodName: string;\n kind: \"action\" | \"locator\";\n signature: string;\n expectedTestIds: string[];\n state: \"present\" | \"hidden\" | \"disabled\" | \"absent\";\n}\n\nexport interface PomComponentAvailability {\n componentName: string;\n className: string;\n sourceFile: string;\n matchedTestIds: number;\n methods: PomMethodAvailability[];\n}\n\nexport interface PomPageFailureSnapshot {\n url: string;\n title: string | null;\n closed: boolean;\n ariaSnapshot: string | null;\n ariaSnapshotError?: string;\n renderedElements: PomRenderedElement[];\n component: PomComponentAvailability | null;\n routerNavigation?: PomRouterNavigationSnapshot | null;\n screenshotPath?: string;\n captureErrors: string[];\n}\n\nexport interface PomRouterNavigationSnapshot {\n id: number;\n status: \"pending\" | \"succeeded\" | \"failed\";\n stage: \"waiting-for-router-ready\" | \"pushing-route\" | \"complete\";\n targetName: string;\n error?: string;\n}\n\nexport interface PomFailureDiagnostics {\n schemaVersion: 1;\n capturedAt: string;\n captureBudgetMs: number;\n activeAction: PomActiveAction | null;\n pages: PomPageFailureSnapshot[];\n console: string[];\n pageErrors: string[];\n networkFailures: string[];\n httpFailures?: PomHttpFailure[];\n pendingRequests?: string[];\n jsonPath: string;\n}\n\nexport interface PomHttpFailure {\n status: number;\n method: string;\n url: string;\n contentType: string | null;\n body?: string;\n bodyCaptureError?: string;\n}\n\nexport type PomDiagnosticsTestInfo = Pick<TestInfo, \"attach\" | \"outputPath\">;\n\nexport interface PomFailureDiagnosticsOptions {\n captureBudgetMs?: number;\n testIdAttribute?: string;\n}\n\nexport interface PomFailureDiagnosticsCapture {\n capture: () => Promise<PomFailureDiagnostics>;\n}\n\ninterface EventBuffers {\n console: string[];\n pageErrors: string[];\n networkFailures: string[];\n httpFailures: PomHttpFailure[];\n httpFailureBodyCaptures: Set<Promise<void>>;\n pendingRequests: Map<object, { method: string; resourceType: string; startedAt: number; url: string }>;\n}\n\nfunction pushBounded(buffer: string[], value: string): void {\n buffer.push(value.slice(0, MAX_TEXT_LENGTH));\n if (buffer.length > MAX_BUFFERED_EVENTS) {\n buffer.splice(0, buffer.length - MAX_BUFFERED_EVENTS);\n }\n}\n\nfunction pushHttpFailureBounded(buffer: PomHttpFailure[], value: PomHttpFailure): void {\n buffer.push(value);\n if (buffer.length > MAX_HTTP_FAILURES) {\n buffer.splice(0, buffer.length - MAX_HTTP_FAILURES);\n }\n}\n\nfunction truncateText(value: string, maximum: number): string {\n if (value.length <= maximum) return value;\n return `${value.slice(0, maximum)}\\n… truncated ${value.length - maximum} characters …`;\n}\n\nfunction formatNetworkUrl(value: string): string {\n if (value.length <= 500) return value;\n\n try {\n const parsed = new URL(value);\n return `${parsed.origin}${parsed.pathname}${parsed.search ? \"?…\" : \"\"}`;\n }\n catch {\n return `${value.slice(0, 497)}…`;\n }\n}\n\nfunction errorMessage<T>(error: T): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction patternToRegExp(pattern: string): RegExp {\n const escaped = pattern.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n return new RegExp(`^${escaped.replace(/\\\\\\$\\\\\\{[^}]+\\\\\\}/g, \".+\")}$`);\n}\n\nfunction matchesTestId(pattern: string, actual: string): boolean {\n return pattern.includes(\"${\") ? patternToRegExp(pattern).test(actual) : pattern === actual;\n}\n\nfunction formatMethodSignature(method: PomManifestMethod): string {\n const parameters = method.parameters.map((parameter) => {\n const rest = parameter.isRestParameter ? \"...\" : \"\";\n const optional = parameter.hasQuestionToken ? \"?\" : \"\";\n // Normalized manifest parameters retain the original typeExpression for\n // provenance, but it may also contain the initializer (for example\n // `string = \"\"`). Prefer the split type to avoid printing it twice.\n const type = parameter.type ?? parameter.typeExpression ?? \"unknown\";\n const initializer = parameter.initializer === undefined ? \"\" : ` = ${parameter.initializer}`;\n return `${rest}${parameter.name}${optional}: ${type}${initializer}`;\n });\n return `${method.name}(${parameters.join(\", \")})`;\n}\n\nfunction availabilityState(elements: readonly PomRenderedElement[]): PomMethodAvailability[\"state\"] {\n if (!elements.length) return \"absent\";\n if (!elements.some(element => element.visible)) return \"hidden\";\n if (!elements.some(element => element.visible && element.enabled)) return \"disabled\";\n return \"present\";\n}\n\nfunction buildComponentAvailability(\n manifest: PomManifest,\n renderedElements: readonly PomRenderedElement[],\n activeComponentName?: string,\n): PomComponentAvailability | null {\n const renderedTestIds = Array.from(new Set(renderedElements.map(element => element.testId)));\n const candidates = Object.values(manifest).map((component) => ({\n component,\n matchedTestIds: renderedTestIds.filter(actual => component.entries.some(entry => matchesTestId(entry.testId, actual))).length,\n }));\n candidates.sort((a, b) => b.matchedTestIds - a.matchedTestIds\n || Number(b.component.kind === \"view\") - Number(a.component.kind === \"view\")\n || a.component.componentName.localeCompare(b.component.componentName));\n\n const activeCandidate = candidates.find(candidate => candidate.component.componentName === activeComponentName);\n const selected = activeCandidate ?? candidates[0];\n if (!selected || (selected.matchedTestIds === 0 && !activeCandidate)) return null;\n\n const methods = new Map<string, { method: PomManifestMethod; testIds: Set<string> }>();\n for (const entry of selected.component.entries) {\n for (const method of entry.generatedMethods) {\n const key = `${method.kind}:${method.name}`;\n const current = methods.get(key) ?? { method, testIds: new Set<string>() };\n current.testIds.add(entry.testId);\n methods.set(key, current);\n }\n }\n\n return {\n componentName: selected.component.componentName,\n className: selected.component.className,\n sourceFile: selected.component.sourceFile,\n matchedTestIds: selected.matchedTestIds,\n methods: Array.from(methods.values())\n .map(({ method, testIds }) => {\n const expectedTestIds = Array.from(testIds).sort((a, b) => a.localeCompare(b));\n const matchingElements = renderedElements.filter(element => expectedTestIds.some(pattern => matchesTestId(pattern, element.testId)));\n return {\n methodName: method.name,\n kind: method.kind,\n signature: formatMethodSignature(method),\n expectedTestIds,\n state: availabilityState(matchingElements),\n } satisfies PomMethodAvailability;\n })\n .sort((a, b) => a.methodName.localeCompare(b.methodName)),\n };\n}\n\nfunction remainingMilliseconds(deadline: number): number {\n return Math.max(0, deadline - Date.now());\n}\n\nasync function withinBudget<T>(deadline: number, operation: () => Promise<T>): Promise<T> {\n const remaining = remainingMilliseconds(deadline);\n if (remaining <= 0) throw new Error(\"diagnostic capture budget exhausted\");\n\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n return await Promise.race([\n operation(),\n new Promise<T>((_resolve, reject) => {\n timer = setTimeout(() => reject(new Error(\"diagnostic capture budget exhausted\")), remaining);\n }),\n ]);\n }\n finally {\n if (timer) clearTimeout(timer);\n }\n}\n\nfunction installPageListeners(page: Page, buffers: EventBuffers): void {\n page.on(\"console\", message => pushBounded(buffers.console, `[${message.type()}] ${message.text()}`));\n page.on(\"pageerror\", error => pushBounded(buffers.pageErrors, errorMessage(error)));\n page.on(\"request\", (request) => {\n buffers.pendingRequests.set(request, {\n method: request.method(),\n resourceType: request.resourceType(),\n startedAt: Date.now(),\n url: request.url(),\n });\n });\n page.on(\"requestfinished\", request => buffers.pendingRequests.delete(request));\n page.on(\"requestfailed\", (request) => {\n buffers.pendingRequests.delete(request);\n const failure = request.failure()?.errorText ?? \"request failed\";\n pushBounded(buffers.networkFailures, `${request.method()} ${formatNetworkUrl(request.url())} — ${failure}`);\n });\n page.on(\"response\", (response) => {\n if (response.status() >= 400) {\n pushBounded(buffers.networkFailures, `${response.status()} ${response.request().method()} ${formatNetworkUrl(response.url())}`);\n const failure: PomHttpFailure = {\n status: response.status(),\n method: response.request().method(),\n url: formatNetworkUrl(response.url()),\n contentType: response.headers()[\"content-type\"] ?? null,\n };\n pushHttpFailureBounded(buffers.httpFailures, failure);\n\n const capture: Promise<void> = response.text()\n .then((body) => {\n if (body) failure.body = truncateText(body, MAX_HTTP_FAILURE_BODY_LENGTH);\n })\n .catch((error) => {\n failure.bodyCaptureError = errorMessage(error);\n })\n .finally(() => buffers.httpFailureBodyCaptures.delete(capture));\n buffers.httpFailureBodyCaptures.add(capture);\n }\n });\n}\n\nasync function settleHttpFailureBodies(buffers: EventBuffers, deadline: number): Promise<void> {\n const captures = Array.from(buffers.httpFailureBodyCaptures);\n if (!captures.length) return;\n\n const waitMs = Math.min(HTTP_FAILURE_BODY_SETTLE_BUDGET_MS, remainingMilliseconds(deadline));\n if (waitMs <= 0) return;\n\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n await Promise.race([\n Promise.allSettled(captures),\n new Promise<void>((resolve) => {\n timer = setTimeout(resolve, waitMs);\n }),\n ]);\n }\n finally {\n if (timer) clearTimeout(timer);\n }\n}\n\nasync function captureRenderedElements(\n page: Page,\n testIdAttribute: string,\n): Promise<{ title: string; elements: PomRenderedElement[]; routerNavigation: PomRouterNavigationSnapshot | null }> {\n return page.evaluate(({ attribute, routerGlobalName }) => {\n const elements = Array.from(document.querySelectorAll(`[${CSS.escape(attribute)}]`));\n const isVisibleElement = (candidate: HTMLElement) => {\n const style = getComputedStyle(candidate);\n const rect = candidate.getBoundingClientRect();\n return style.display !== \"none\"\n && style.visibility !== \"hidden\"\n && Number.parseFloat(style.opacity || \"1\") > 0\n && rect.width > 0\n && rect.height > 0;\n };\n const rendered = elements.map((element) => {\n const htmlElement = element as HTMLElement;\n const disabled = (\"disabled\" in htmlElement && Boolean((htmlElement as HTMLButtonElement).disabled))\n || htmlElement.getAttribute(\"aria-disabled\") === \"true\";\n const text = htmlElement.textContent?.replace(/\\s+/g, \" \").trim();\n const inputType = htmlElement instanceof HTMLInputElement ? htmlElement.type.toLowerCase() : \"\";\n const labels = htmlElement instanceof HTMLInputElement ? Array.from(htmlElement.labels ?? []) : [];\n const labelText = labels.length\n ? labels\n .map(label => label.textContent?.replace(/\\s+/g, \" \").trim())\n .filter((value): value is string => Boolean(value))\n .join(\" \")\n : \"\";\n const visible = isVisibleElement(htmlElement)\n || ((inputType === \"checkbox\" || inputType === \"radio\") && labels.some(label => isVisibleElement(label)));\n const role = htmlElement.getAttribute(\"role\")\n ?? (htmlElement.tagName === \"BUTTON\" ? \"button\" : null)\n ?? (htmlElement.tagName === \"A\" && htmlElement.hasAttribute(\"href\") ? \"link\" : null)\n ?? (inputType === \"checkbox\" || inputType === \"radio\" ? inputType : null)\n ?? (htmlElement.tagName === \"TEXTAREA\" || (htmlElement.tagName === \"INPUT\" && inputType !== \"hidden\") ? \"textbox\" : null)\n ?? (htmlElement.tagName === \"SELECT\" ? \"combobox\" : null);\n const name = htmlElement.getAttribute(\"aria-label\")\n ?? htmlElement.getAttribute(\"title\")\n ?? (labelText || null)\n ?? (text ? text.slice(0, 160) : null);\n return {\n testId: htmlElement.getAttribute(attribute) ?? \"\",\n tag: htmlElement.tagName.toLowerCase(),\n role,\n name,\n visible,\n enabled: !disabled,\n };\n }).filter(element => element.testId.length > 0);\n\n const routerBridge = Reflect.get(globalThis, routerGlobalName) as\n | { navigation?: PomRouterNavigationSnapshot }\n | undefined;\n const rawNavigation = routerBridge?.navigation;\n const routerNavigation = rawNavigation\n ? {\n id: rawNavigation.id,\n status: rawNavigation.status,\n stage: rawNavigation.stage,\n targetName: rawNavigation.targetName,\n ...(rawNavigation.error ? { error: rawNavigation.error } : {}),\n }\n : null;\n\n return { title: document.title, elements: rendered, routerNavigation };\n }, { attribute: testIdAttribute, routerGlobalName: \"__vuePomGeneratorRouter\" });\n}\n\nasync function capturePage(\n page: Page,\n pageIndex: number,\n manifest: PomManifest,\n testInfo: PomDiagnosticsTestInfo,\n testIdAttribute: string,\n deadline: number,\n activeAction: PomActiveAction | null,\n): Promise<PomPageFailureSnapshot> {\n const captureErrors: string[] = [];\n const snapshot: PomPageFailureSnapshot = {\n url: page.url(),\n title: null,\n closed: page.isClosed(),\n ariaSnapshot: null,\n renderedElements: [],\n component: null,\n routerNavigation: null,\n captureErrors,\n };\n if (snapshot.closed) return snapshot;\n\n try {\n const rendered = await withinBudget(deadline, () => captureRenderedElements(page, testIdAttribute));\n snapshot.title = rendered.title;\n snapshot.renderedElements = rendered.elements;\n snapshot.component = buildComponentAvailability(manifest, rendered.elements, activeAction?.componentName);\n snapshot.routerNavigation = rendered.routerNavigation;\n }\n catch (error) {\n captureErrors.push(`DOM inventory: ${errorMessage(error)}`);\n }\n\n try {\n snapshot.ariaSnapshot = await withinBudget(deadline, () => page.locator(\"body\").ariaSnapshot({\n timeout: remainingMilliseconds(deadline),\n }));\n }\n catch (error) {\n snapshot.ariaSnapshotError = errorMessage(error);\n }\n\n if (pageIndex === 0 && remainingMilliseconds(deadline) > 0) {\n const screenshotPath = testInfo.outputPath(\"vue-pom-generator-failure.png\");\n try {\n await withinBudget(deadline, () => page.screenshot({\n path: screenshotPath,\n fullPage: true,\n timeout: remainingMilliseconds(deadline),\n }));\n await testInfo.attach(POM_FAILURE_SCREENSHOT_ATTACHMENT_NAME, { path: screenshotPath, contentType: \"image/png\" });\n snapshot.screenshotPath = screenshotPath;\n }\n catch (error) {\n captureErrors.push(`Screenshot: ${errorMessage(error)}`);\n }\n }\n\n return snapshot;\n}\n\nexport function recordPomAction(page: object, action: PomActiveAction): void {\n const globalRecord = globalThis as typeof globalThis & {\n [POM_ACTIVE_ACTION_REGISTRY]?: WeakMap<object, PomActiveAction>;\n };\n const registry = globalRecord[POM_ACTIVE_ACTION_REGISTRY] ?? new WeakMap<object, PomActiveAction>();\n globalRecord[POM_ACTIVE_ACTION_REGISTRY] = registry;\n registry.set(page, {\n ...action,\n expectedTestIds: [...action.expectedTestIds],\n });\n}\n\nexport function getActivePomAction(page: object): PomActiveAction | null {\n const globalRecord = globalThis as typeof globalThis & {\n [POM_ACTIVE_ACTION_REGISTRY]?: WeakMap<object, PomActiveAction>;\n };\n return globalRecord[POM_ACTIVE_ACTION_REGISTRY]?.get(page) ?? null;\n}\n\nexport function installPomFailureDiagnostics(\n page: Page,\n manifest: PomManifest,\n testInfo: PomDiagnosticsTestInfo,\n options: PomFailureDiagnosticsOptions = {},\n): PomFailureDiagnosticsCapture {\n const context: BrowserContext = page.context();\n const pages = new Set<Page>();\n const buffers: EventBuffers = {\n console: [],\n pageErrors: [],\n networkFailures: [],\n httpFailures: [],\n httpFailureBodyCaptures: new Set(),\n pendingRequests: new Map(),\n };\n let captured: Promise<PomFailureDiagnostics> | null = null;\n\n const registerPage = (candidate: Page) => {\n if (pages.has(candidate)) return;\n pages.add(candidate);\n installPageListeners(candidate, buffers);\n };\n for (const existingPage of context.pages()) registerPage(existingPage);\n context.on(\"page\", registerPage);\n\n return {\n capture() {\n if (captured) return captured;\n captured = (async () => {\n const captureBudgetMs = options.captureBudgetMs ?? DEFAULT_CAPTURE_BUDGET_MS;\n const deadline = Date.now() + captureBudgetMs;\n await settleHttpFailureBodies(buffers, deadline);\n const activeAction = getActivePomAction(page);\n const pageSnapshots: PomPageFailureSnapshot[] = [];\n for (const [index, candidate] of Array.from(pages).entries()) {\n pageSnapshots.push(await capturePage(\n candidate,\n index,\n manifest,\n testInfo,\n options.testIdAttribute ?? \"data-testid\",\n deadline,\n activeAction,\n ));\n }\n\n const jsonPath = testInfo.outputPath(\"vue-pom-generator-failure.json\");\n const diagnostics: PomFailureDiagnostics = {\n schemaVersion: 1,\n capturedAt: new Date().toISOString(),\n captureBudgetMs,\n activeAction,\n pages: pageSnapshots,\n console: [...buffers.console],\n pageErrors: [...buffers.pageErrors],\n networkFailures: [...buffers.networkFailures],\n httpFailures: buffers.httpFailures.map(failure => ({ ...failure })),\n pendingRequests: Array.from(buffers.pendingRequests.values())\n .map(request => `${request.method} ${request.resourceType} ${formatNetworkUrl(request.url)} — pending ${Date.now() - request.startedAt}ms`)\n .slice(-MAX_BUFFERED_EVENTS),\n jsonPath,\n };\n await writeFile(jsonPath, `${JSON.stringify(diagnostics, null, 2)}\\n`, \"utf8\");\n await testInfo.attach(POM_FAILURE_ATTACHMENT_NAME, { path: jsonPath, contentType: \"application/json\" });\n return diagnostics;\n })();\n return captured;\n },\n };\n}\n","import { readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type {\n Reporter,\n TestCase,\n TestResult,\n} from \"@playwright/test/reporter\";\n\nimport {\n POM_FAILURE_ATTACHMENT_NAME,\n type PomFailureDiagnostics,\n type PomPageFailureSnapshot,\n} from \"../class-generation/diagnostics\";\n\nconst DEFAULT_MAX_OUTPUT_CHARACTERS = 32_000;\nconst DEFAULT_MAX_METHODS = 80;\nconst DEFAULT_MAX_ELEMENTS = 80;\nconst DEFAULT_MAX_EVENTS = 30;\nconst DEFAULT_MAX_ARIA_CHARACTERS = 8_000;\n\nexport interface PomFailureReporterOptions {\n maxOutputCharacters?: number;\n}\n\nfunction shellQuote(value: string): string {\n let quoted = \"'\";\n for (const character of value) {\n quoted += character === \"'\" ? `'\"'\"'` : character;\n }\n return `${quoted}'`;\n}\n\nfunction readDiagnostics(result: TestResult): PomFailureDiagnostics | null {\n const attachment = result.attachments.find(candidate => candidate.name === POM_FAILURE_ATTACHMENT_NAME);\n if (!attachment) return null;\n\n try {\n if (attachment.body) return JSON.parse(attachment.body.toString(\"utf8\")) as PomFailureDiagnostics;\n if (attachment.path) return JSON.parse(readFileSync(attachment.path, \"utf8\")) as PomFailureDiagnostics;\n }\n catch {\n return null;\n }\n return null;\n}\n\nfunction appendLimited(lines: string[], heading: string, values: readonly string[], limit: number): void {\n if (!values.length) return;\n lines.push(heading);\n for (const value of values.slice(-limit)) lines.push(` ${value}`);\n const omitted = Math.max(0, values.length - limit);\n if (omitted) lines.push(` … ${omitted} earlier entries omitted`);\n}\n\nfunction formatPage(lines: string[], page: PomPageFailureSnapshot, index: number): void {\n lines.push(`Page ${index + 1}: ${page.url || \"<no URL>\"}`);\n if (page.title) lines.push(`Title: ${page.title}`);\n if (page.closed) lines.push(\"State: page was already closed\");\n if (page.routerNavigation) {\n lines.push(\n `Generated router navigation: ${page.routerNavigation.status} at ${page.routerNavigation.stage} -> ${page.routerNavigation.targetName}`,\n );\n if (page.routerNavigation.error) lines.push(`Router error: ${page.routerNavigation.error}`);\n }\n\n if (page.component) {\n const available = page.component.methods.filter(method => method.state === \"present\").length;\n lines.push(\n `Generated POM match: ${page.component.className} (${page.component.matchedTestIds} rendered test ids; ${available}/${page.component.methods.length} methods currently present)`,\n );\n lines.push(`Vue source: ${page.component.sourceFile}`);\n for (const method of page.component.methods.slice(0, DEFAULT_MAX_METHODS)) {\n lines.push(` [${method.state}] ${method.signature} <- ${method.expectedTestIds.join(\" | \")}`);\n }\n const omittedMethods = Math.max(0, page.component.methods.length - DEFAULT_MAX_METHODS);\n if (omittedMethods) lines.push(` … ${omittedMethods} generated methods omitted; see JSON`);\n lines.push(\" Availability describes the current page state; an unavailable method is not inherently an error.\");\n }\n else {\n lines.push(\"Generated POM match: no active page POM identified from rendered test ids\");\n }\n\n if (page.renderedElements.length) {\n lines.push(\"Rendered generated elements:\");\n for (const element of page.renderedElements.slice(0, DEFAULT_MAX_ELEMENTS)) {\n const state = `${element.visible ? \"visible\" : \"hidden\"}/${element.enabled ? \"enabled\" : \"disabled\"}`;\n const semantics = [element.role ? `role=${element.role}` : null, element.name ? `name=${JSON.stringify(element.name)}` : null]\n .filter(Boolean)\n .join(\" \");\n lines.push(` ${element.testId} <${element.tag}> ${state}${semantics ? ` ${semantics}` : \"\"}`);\n }\n const omittedElements = Math.max(0, page.renderedElements.length - DEFAULT_MAX_ELEMENTS);\n if (omittedElements) lines.push(` … ${omittedElements} rendered elements omitted; see JSON`);\n }\n\n if (page.ariaSnapshot) {\n const aria = page.ariaSnapshot.slice(0, DEFAULT_MAX_ARIA_CHARACTERS);\n lines.push(\"Accessibility snapshot:\", aria);\n if (aria.length < page.ariaSnapshot.length) {\n lines.push(` … ${page.ariaSnapshot.length - aria.length} accessibility-snapshot characters omitted; see JSON`);\n }\n }\n else if (page.ariaSnapshotError) {\n lines.push(`Accessibility snapshot unavailable: ${page.ariaSnapshotError}`);\n }\n\n appendLimited(lines, \"Capture warnings:\", page.captureErrors, DEFAULT_MAX_EVENTS);\n}\n\nfunction formatErrors(result: TestResult): string[] {\n if (!result.errors.length) return [\"Playwright error: failure did not include an Error object\"];\n return result.errors.map((error, index) => {\n const value = error.stack ?? error.message ?? error.value ?? \"Unknown error\";\n return `Error ${index + 1}:\\n${String(value).slice(0, 6_000)}`;\n });\n}\n\nfunction isolatedCommand(test: TestCase): string {\n const location = `${path.relative(process.cwd(), test.location.file)}:${test.location.line}`;\n return `npx playwright test ${shellQuote(location)} --project=${shellQuote(test.parent.project()?.name ?? \"chromium\")} --max-failures=1`;\n}\n\nfunction boundOutput(lines: string[], footer: string[], maximum: number): string {\n const full = [...lines, ...footer].join(\"\\n\");\n if (full.length <= maximum) return full;\n\n const footerText = footer.join(\"\\n\");\n const marker = `\\n… report truncated by ${full.length - maximum} characters; use the JSON artifact for complete structured diagnostics …\\n`;\n const available = Math.max(0, maximum - footerText.length - marker.length - 1);\n return `${lines.join(\"\\n\").slice(0, available)}${marker}${footerText}`;\n}\n\nexport function formatPomFailureReport(\n test: TestCase,\n result: TestResult,\n diagnostics: PomFailureDiagnostics | null,\n options: PomFailureReporterOptions = {},\n): string {\n const title = test.titlePath().join(\" › \");\n const lines = [\n \"================ VUE POM FAILURE DIAGNOSTICS ================\",\n `Test: ${title}`,\n `Location: ${test.location.file}:${test.location.line}:${test.location.column}`,\n `Attempt: ${result.retry + 1}`,\n `Status: ${result.status} (expected ${test.expectedStatus})`,\n ...formatErrors(result),\n ];\n\n if (diagnostics) {\n if (diagnostics.activeAction) {\n lines.push(\n `Active generated action: ${diagnostics.activeAction.componentName ? `${diagnostics.activeAction.componentName}.` : \"\"}${diagnostics.activeAction.methodName}`,\n );\n if (diagnostics.activeAction.expectedTestIds.length) {\n lines.push(`Expected generated test ids: ${diagnostics.activeAction.expectedTestIds.join(\" | \")}`);\n }\n }\n else {\n lines.push(\"Active generated action: none recorded\");\n }\n diagnostics.pages.forEach((page, index) => formatPage(lines, page, index));\n appendLimited(lines, \"Browser console:\", diagnostics.console, DEFAULT_MAX_EVENTS);\n appendLimited(lines, \"Page errors:\", diagnostics.pageErrors, DEFAULT_MAX_EVENTS);\n appendLimited(lines, \"Network failures:\", diagnostics.networkFailures, DEFAULT_MAX_EVENTS);\n appendLimited(\n lines,\n \"HTTP error responses:\",\n (diagnostics.httpFailures ?? []).map((failure) => {\n const heading = `${failure.status} ${failure.method} ${failure.url}${failure.contentType ? ` (${failure.contentType})` : \"\"}`;\n if (failure.body) return `${heading}\\nResponse body:\\n${failure.body}`;\n if (failure.bodyCaptureError) return `${heading}\\nResponse body unavailable: ${failure.bodyCaptureError}`;\n return heading;\n }),\n DEFAULT_MAX_EVENTS,\n );\n appendLimited(lines, \"Requests still pending at failure:\", diagnostics.pendingRequests ?? [], DEFAULT_MAX_EVENTS);\n }\n else {\n lines.push(\n \"Browser diagnostics: unavailable. The test did not initialize generated POM fixtures, the page closed before capture, or capture itself failed.\",\n );\n }\n\n const footer = [\n diagnostics ? `Structured diagnostics: ${diagnostics.jsonPath}` : \"Structured diagnostics: unavailable\",\n `Isolated rerun: ${isolatedCommand(test)}`,\n \"=============================================================\",\n ];\n return boundOutput(lines, footer, options.maxOutputCharacters ?? DEFAULT_MAX_OUTPUT_CHARACTERS);\n}\n\nexport default class PomFailureReporter implements Reporter {\n private readonly options: PomFailureReporterOptions;\n\n public constructor(options: PomFailureReporterOptions = {}) {\n this.options = options;\n }\n\n public onTestEnd(test: TestCase, result: TestResult): void {\n if (result.status === test.expectedStatus || result.status === \"skipped\") return;\n const diagnostics = readDiagnostics(result);\n process.stdout.write(`${formatPomFailureReport(test, result, diagnostics, this.options)}\\n`);\n }\n\n public printsToStdio(): boolean {\n return true;\n }\n}\n"],"names":[],"mappings":";;;AAIO,MAAM,8BAA8B;ACU3C,MAAM,gCAAgC;AACtC,MAAM,sBAAsB;AAC5B,MAAM,uBAAuB;AAC7B,MAAM,qBAAqB;AAC3B,MAAM,8BAA8B;AAMpC,SAAS,WAAW,OAAuB;AACzC,MAAI,SAAS;AACb,aAAW,aAAa,OAAO;AAC7B,cAAU,cAAc,MAAM,UAAU;AAAA,EAC1C;AACA,SAAO,GAAG,MAAM;AAClB;AAEA,SAAS,gBAAgB,QAAkD;AACzE,QAAM,aAAa,OAAO,YAAY,KAAK,CAAA,cAAa,UAAU,SAAS,2BAA2B;AACtG,MAAI,CAAC,WAAY,QAAO;AAExB,MAAI;AACF,QAAI,WAAW,KAAM,QAAO,KAAK,MAAM,WAAW,KAAK,SAAS,MAAM,CAAC;AACvE,QAAI,WAAW,KAAM,QAAO,KAAK,MAAM,aAAa,WAAW,MAAM,MAAM,CAAC;AAAA,EAC9E,QACM;AACJ,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,SAAS,cAAc,OAAiB,SAAiB,QAA2B,OAAqB;AACvG,MAAI,CAAC,OAAO,OAAQ;AACpB,QAAM,KAAK,OAAO;AAClB,aAA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AAAA,EACzC;AAAA,EAEV,YAAY,UAAqC,IAAI;AAC1D,SAAK,UAAU;AAAA,EACjB;AAAA,EAEO,UAAU,MAAgB,QAA0B;AACzD,QAAI,OAAO,WAAW,KAAK,kBAAkB,OAAO,WAAW,UAAW;AAC1E,UAAM,cAAc,gBAAgB,MAAM;AAC1C,YAAQ,OAAO,MAAM,GAAG,uBAAuB,MAAM,QAAQ,aAAa,KAAK,OAAO,CAAC;AAAA,CAAI;AAAA,EAC7F;AAAA,EAEO,gBAAyB;AAC9B,WAAO;AAAA,EACT;AACF;"}
@@ -1,9 +1,11 @@
1
1
  import type { PluginOption } from "vite";
2
+ import type { ElementMetadata } from "../../metadata-collector";
2
3
  import type { IComponentDependencies, NativeWrappersMap } from "../../utils";
3
4
  import type { VuePomGeneratorLogger } from "../logger";
4
5
  import type { ResolvedGenerationSupportOptions } from "../resolved-generation-options";
5
6
  interface BuildProcessorOptions {
6
7
  componentHierarchyMap: Map<string, IComponentDependencies>;
8
+ elementMetadata: Map<string, Map<string, ElementMetadata>>;
7
9
  crossFileKeyRegistry: Map<string, string>;
8
10
  vueFilesPathMap: Map<string, string>;
9
11
  getPageDirs: () => string[];
@@ -1 +1 @@
1
- {"version":3,"file":"build-plugin.d.ts","sourceRoot":"","sources":["../../../plugin/internal/build-plugin.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAKzC,OAAO,KAAK,EAAE,sBAAsB,EAAE,iBAAiB,EAA6B,MAAM,aAAa,CAAC;AAExG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEvD,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAGvF,UAAU,qBAAqB;IAC7B,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;IAC3D,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,eA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