mcp-web-validator 1.3.51 → 1.3.54

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 (174) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +64 -4
  3. package/dist/audit-history.d.ts +9 -0
  4. package/dist/audit-history.js +27 -0
  5. package/dist/audit-history.js.map +1 -1
  6. package/dist/index.js +2508 -2
  7. package/dist/index.js.map +1 -1
  8. package/dist/mcp-bounds.js +8 -3
  9. package/dist/mcp-bounds.js.map +1 -1
  10. package/dist/modules/browser-ux/lighthouse-lab-probe.d.ts +21 -0
  11. package/dist/modules/browser-ux/lighthouse-lab-probe.js +190 -0
  12. package/dist/modules/browser-ux/lighthouse-lab-probe.js.map +1 -0
  13. package/dist/modules/browser-ux/lighthouse-lab.d.ts +61 -0
  14. package/dist/modules/browser-ux/lighthouse-lab.js +98 -0
  15. package/dist/modules/browser-ux/lighthouse-lab.js.map +1 -0
  16. package/dist/modules/browser-ux/media-diagnostics.d.ts +41 -0
  17. package/dist/modules/browser-ux/media-diagnostics.js +183 -0
  18. package/dist/modules/browser-ux/media-diagnostics.js.map +1 -0
  19. package/dist/modules/browser-ux/raw-rendered-diff.d.ts +70 -0
  20. package/dist/modules/browser-ux/raw-rendered-diff.js +262 -0
  21. package/dist/modules/browser-ux/raw-rendered-diff.js.map +1 -0
  22. package/dist/modules/browser-ux/raw-rendered-probe.d.ts +17 -0
  23. package/dist/modules/browser-ux/raw-rendered-probe.js +163 -0
  24. package/dist/modules/browser-ux/raw-rendered-probe.js.map +1 -0
  25. package/dist/modules/browser-ux/resource-failures-probe.d.ts +11 -0
  26. package/dist/modules/browser-ux/resource-failures-probe.js +231 -0
  27. package/dist/modules/browser-ux/resource-failures-probe.js.map +1 -0
  28. package/dist/modules/browser-ux/resource-failures.d.ts +79 -0
  29. package/dist/modules/browser-ux/resource-failures.js +178 -0
  30. package/dist/modules/browser-ux/resource-failures.js.map +1 -0
  31. package/dist/modules/browser-ux/viewport-parity-probe.d.ts +5 -0
  32. package/dist/modules/browser-ux/viewport-parity-probe.js +316 -0
  33. package/dist/modules/browser-ux/viewport-parity-probe.js.map +1 -0
  34. package/dist/modules/browser-ux/viewport-parity.d.ts +112 -0
  35. package/dist/modules/browser-ux/viewport-parity.js +224 -0
  36. package/dist/modules/browser-ux/viewport-parity.js.map +1 -0
  37. package/dist/modules/browser-ux/wcag-interactions.d.ts +95 -0
  38. package/dist/modules/browser-ux/wcag-interactions.js +360 -0
  39. package/dist/modules/browser-ux/wcag-interactions.js.map +1 -0
  40. package/dist/modules/change-regression/availability-history-store.d.ts +18 -0
  41. package/dist/modules/change-regression/availability-history-store.js +168 -0
  42. package/dist/modules/change-regression/availability-history-store.js.map +1 -0
  43. package/dist/modules/change-regression/crawler-log-correlation.d.ts +111 -0
  44. package/dist/modules/change-regression/crawler-log-correlation.js +374 -0
  45. package/dist/modules/change-regression/crawler-log-correlation.js.map +1 -0
  46. package/dist/modules/change-regression/google-common-crawler-ip.d.ts +15 -0
  47. package/dist/modules/change-regression/google-common-crawler-ip.js +129 -0
  48. package/dist/modules/change-regression/google-common-crawler-ip.js.map +1 -0
  49. package/dist/modules/change-regression/historical-comparisons.d.ts +120 -0
  50. package/dist/modules/change-regression/historical-comparisons.js +330 -0
  51. package/dist/modules/change-regression/historical-comparisons.js.map +1 -0
  52. package/dist/modules/change-regression/production-change-comparison.d.ts +68 -0
  53. package/dist/modules/change-regression/production-change-comparison.js +214 -0
  54. package/dist/modules/change-regression/production-change-comparison.js.map +1 -0
  55. package/dist/modules/change-regression/regression-alerts.d.ts +73 -0
  56. package/dist/modules/change-regression/regression-alerts.js +183 -0
  57. package/dist/modules/change-regression/regression-alerts.js.map +1 -0
  58. package/dist/modules/change-regression/strict-observation-time.d.ts +7 -0
  59. package/dist/modules/change-regression/strict-observation-time.js +31 -0
  60. package/dist/modules/change-regression/strict-observation-time.js.map +1 -0
  61. package/dist/modules/content-schema/citation-methodology-consistency.d.ts +108 -0
  62. package/dist/modules/content-schema/citation-methodology-consistency.js +360 -0
  63. package/dist/modules/content-schema/citation-methodology-consistency.js.map +1 -0
  64. package/dist/modules/content-schema/competitor-intent-comparison.d.ts +74 -0
  65. package/dist/modules/content-schema/competitor-intent-comparison.js +185 -0
  66. package/dist/modules/content-schema/competitor-intent-comparison.js.map +1 -0
  67. package/dist/modules/content-schema/empty-boilerplate-content.d.ts +36 -0
  68. package/dist/modules/content-schema/empty-boilerplate-content.js +225 -0
  69. package/dist/modules/content-schema/empty-boilerplate-content.js.map +1 -0
  70. package/dist/modules/content-schema/extract-citation-methodology.d.ts +6 -0
  71. package/dist/modules/content-schema/extract-citation-methodology.js +201 -0
  72. package/dist/modules/content-schema/extract-citation-methodology.js.map +1 -0
  73. package/dist/modules/content-schema/extract-competitor-intent.d.ts +2 -0
  74. package/dist/modules/content-schema/extract-competitor-intent.js +140 -0
  75. package/dist/modules/content-schema/extract-competitor-intent.js.map +1 -0
  76. package/dist/modules/content-schema/extract-main-content.d.ts +6 -0
  77. package/dist/modules/content-schema/extract-main-content.js +33 -0
  78. package/dist/modules/content-schema/extract-main-content.js.map +1 -0
  79. package/dist/modules/content-schema/extract-metadata-consistency.d.ts +3 -0
  80. package/dist/modules/content-schema/extract-metadata-consistency.js +62 -0
  81. package/dist/modules/content-schema/extract-metadata-consistency.js.map +1 -0
  82. package/dist/modules/content-schema/extract-product-claims.d.ts +3 -0
  83. package/dist/modules/content-schema/extract-product-claims.js +58 -0
  84. package/dist/modules/content-schema/extract-product-claims.js.map +1 -0
  85. package/dist/modules/content-schema/extract-structured-data.d.ts +3 -0
  86. package/dist/modules/content-schema/extract-structured-data.js +25 -0
  87. package/dist/modules/content-schema/extract-structured-data.js.map +1 -0
  88. package/dist/modules/content-schema/metadata-consistency.d.ts +66 -0
  89. package/dist/modules/content-schema/metadata-consistency.js +282 -0
  90. package/dist/modules/content-schema/metadata-consistency.js.map +1 -0
  91. package/dist/modules/content-schema/product-claims.d.ts +73 -0
  92. package/dist/modules/content-schema/product-claims.js +195 -0
  93. package/dist/modules/content-schema/product-claims.js.map +1 -0
  94. package/dist/modules/content-schema/same-language-duplicates.d.ts +52 -0
  95. package/dist/modules/content-schema/same-language-duplicates.js +158 -0
  96. package/dist/modules/content-schema/same-language-duplicates.js.map +1 -0
  97. package/dist/modules/content-schema/structured-data-validation.d.ts +37 -0
  98. package/dist/modules/content-schema/structured-data-validation.js +385 -0
  99. package/dist/modules/content-schema/structured-data-validation.js.map +1 -0
  100. package/dist/modules/external-metrics/crux-field-probe.d.ts +10 -0
  101. package/dist/modules/external-metrics/crux-field-probe.js +113 -0
  102. package/dist/modules/external-metrics/crux-field-probe.js.map +1 -0
  103. package/dist/modules/external-metrics/crux-field.d.ts +61 -0
  104. package/dist/modules/external-metrics/crux-field.js +231 -0
  105. package/dist/modules/external-metrics/crux-field.js.map +1 -0
  106. package/dist/modules/http-crawl/availability-observations.d.ts +68 -0
  107. package/dist/modules/http-crawl/availability-observations.js +206 -0
  108. package/dist/modules/http-crawl/availability-observations.js.map +1 -0
  109. package/dist/modules/http-crawl/availability-probe.d.ts +8 -0
  110. package/dist/modules/http-crawl/availability-probe.js +46 -0
  111. package/dist/modules/http-crawl/availability-probe.js.map +1 -0
  112. package/dist/modules/http-crawl/crawler-access-probe.d.ts +6 -0
  113. package/dist/modules/http-crawl/crawler-access-probe.js +79 -0
  114. package/dist/modules/http-crawl/crawler-access-probe.js.map +1 -0
  115. package/dist/modules/http-crawl/crawler-access.d.ts +75 -0
  116. package/dist/modules/http-crawl/crawler-access.js +404 -0
  117. package/dist/modules/http-crawl/crawler-access.js.map +1 -0
  118. package/dist/modules/http-crawl/http-delivery-probe.d.ts +3 -0
  119. package/dist/modules/http-crawl/http-delivery-probe.js +44 -0
  120. package/dist/modules/http-crawl/http-delivery-probe.js.map +1 -0
  121. package/dist/modules/http-crawl/http-delivery.d.ts +64 -0
  122. package/dist/modules/http-crawl/http-delivery.js +273 -0
  123. package/dist/modules/http-crawl/http-delivery.js.map +1 -0
  124. package/dist/modules/http-crawl/https-security.d.ts +84 -0
  125. package/dist/modules/http-crawl/https-security.js +441 -0
  126. package/dist/modules/http-crawl/https-security.js.map +1 -0
  127. package/dist/modules/http-crawl/non-html-directives.d.ts +74 -0
  128. package/dist/modules/http-crawl/non-html-directives.js +353 -0
  129. package/dist/modules/http-crawl/non-html-directives.js.map +1 -0
  130. package/dist/modules/http-crawl/redirect-canonical-chains.d.ts +80 -0
  131. package/dist/modules/http-crawl/redirect-canonical-chains.js +459 -0
  132. package/dist/modules/http-crawl/redirect-canonical-chains.js.map +1 -0
  133. package/dist/modules/http-crawl/redirect-canonical-probe.d.ts +6 -0
  134. package/dist/modules/http-crawl/redirect-canonical-probe.js +83 -0
  135. package/dist/modules/http-crawl/redirect-canonical-probe.js.map +1 -0
  136. package/dist/modules/http-crawl/sitemap-inventory-probe.d.ts +8 -0
  137. package/dist/modules/http-crawl/sitemap-inventory-probe.js +155 -0
  138. package/dist/modules/http-crawl/sitemap-inventory-probe.js.map +1 -0
  139. package/dist/modules/http-crawl/sitemap-inventory.d.ts +107 -0
  140. package/dist/modules/http-crawl/sitemap-inventory.js +557 -0
  141. package/dist/modules/http-crawl/sitemap-inventory.js.map +1 -0
  142. package/dist/modules/http-crawl/url-variants.d.ts +86 -0
  143. package/dist/modules/http-crawl/url-variants.js +379 -0
  144. package/dist/modules/http-crawl/url-variants.js.map +1 -0
  145. package/dist/modules/site-architecture/extract-internal-links.d.ts +3 -0
  146. package/dist/modules/site-architecture/extract-internal-links.js +88 -0
  147. package/dist/modules/site-architecture/extract-internal-links.js.map +1 -0
  148. package/dist/modules/site-architecture/extract-multilingual-page.d.ts +2 -0
  149. package/dist/modules/site-architecture/extract-multilingual-page.js +29 -0
  150. package/dist/modules/site-architecture/extract-multilingual-page.js.map +1 -0
  151. package/dist/modules/site-architecture/internal-link-graph-probe.d.ts +7 -0
  152. package/dist/modules/site-architecture/internal-link-graph-probe.js +116 -0
  153. package/dist/modules/site-architecture/internal-link-graph-probe.js.map +1 -0
  154. package/dist/modules/site-architecture/internal-link-graph.d.ts +113 -0
  155. package/dist/modules/site-architecture/internal-link-graph.js +414 -0
  156. package/dist/modules/site-architecture/internal-link-graph.js.map +1 -0
  157. package/dist/modules/site-architecture/internal-link-quality.d.ts +77 -0
  158. package/dist/modules/site-architecture/internal-link-quality.js +260 -0
  159. package/dist/modules/site-architecture/internal-link-quality.js.map +1 -0
  160. package/dist/modules/site-architecture/multilingual-clusters.d.ts +82 -0
  161. package/dist/modules/site-architecture/multilingual-clusters.js +363 -0
  162. package/dist/modules/site-architecture/multilingual-clusters.js.map +1 -0
  163. package/dist/network.d.ts +4 -0
  164. package/dist/network.js +25 -8
  165. package/dist/network.js.map +1 -1
  166. package/dist/presentation.d.ts +53 -0
  167. package/dist/presentation.js +526 -0
  168. package/dist/presentation.js.map +1 -1
  169. package/dist/screenshot.d.ts +2 -1
  170. package/dist/screenshot.js +4 -2
  171. package/dist/screenshot.js.map +1 -1
  172. package/dist/seo-auditor.js +16 -6
  173. package/dist/seo-auditor.js.map +1 -1
  174. package/package.json +7 -4
@@ -0,0 +1,79 @@
1
+ /**
2
+ * V08: bounded redacted browser resource observations.
3
+ * HTTP 4xx/5xx are responses, NOT Puppeteer requestfailed events; request
4
+ * transport failures, tool-policy blocks and still-pending requests are
5
+ * independent categories. No URLs, headers or exception text is returned.
6
+ */
7
+ export declare const MAX_RESOURCE_OBSERVATIONS = 64;
8
+ export declare const MAX_RESOURCE_FINDINGS = 20;
9
+ export declare const MAX_RESOURCE_BROWSER_MS = 24000;
10
+ export declare const RESOURCE_TYPES: readonly ["document", "script", "stylesheet", "image", "font", "xhr", "fetch", "media", "other"];
11
+ export declare const RESOURCE_OUTCOMES: readonly ["http", "transport_failed", "tool_blocked", "pending"];
12
+ export declare const RESOURCE_FAILURE_REASONS: readonly ["dns", "timeout", "tls", "connection", "canceled", "other"];
13
+ export declare const RESOURCE_ORIGINS: readonly ["same_origin", "third_party", "unknown"];
14
+ export declare const RESOURCE_FINDING_CODES: readonly ["document_http_error", "document_transport_failed", "script_http_error", "script_transport_failed", "stylesheet_http_error", "stylesheet_transport_failed", "api_http_error", "api_transport_failed", "image_http_error", "font_http_error", "other_http_error", "other_transport_failed", "third_party_failures", "slow_resource_sample", "resource_budget_reached", "tool_blocked_resources", "pending_resources", "navigation_incomplete"];
15
+ export type ResourceType = typeof RESOURCE_TYPES[number];
16
+ export type ResourceOutcome = typeof RESOURCE_OUTCOMES[number];
17
+ export type ResourceFailureReason = typeof RESOURCE_FAILURE_REASONS[number];
18
+ export type ResourceOrigin = typeof RESOURCE_ORIGINS[number];
19
+ export type ResourceFindingCode = typeof RESOURCE_FINDING_CODES[number];
20
+ export interface ResourceObservation {
21
+ resource_type: ResourceType;
22
+ origin: ResourceOrigin;
23
+ outcome: ResourceOutcome;
24
+ status_code?: number;
25
+ failure_reason?: ResourceFailureReason;
26
+ duration_ms?: number;
27
+ }
28
+ export interface ResourceReviewInput {
29
+ observations: ResourceObservation[];
30
+ /** Number of requests blocked after the fixed report observation cap. */
31
+ additional_budget_blocked?: number;
32
+ /** Whether main navigation completed before its deadline. */
33
+ navigation_completed?: boolean;
34
+ }
35
+ export interface ResourceTypeSummary {
36
+ resource_type: ResourceType;
37
+ attempted: number;
38
+ http_responses: number;
39
+ http_4xx: number;
40
+ http_5xx: number;
41
+ transport_failures: number;
42
+ blocked_by_tool: number;
43
+ still_pending: number;
44
+ }
45
+ export interface ResourceFinding {
46
+ code: ResourceFindingCode;
47
+ severity: "warning" | "info";
48
+ count: number;
49
+ message: string;
50
+ }
51
+ export interface ResourceFailureReview {
52
+ scope: "caller_supplied_resource_observations" | "guarded_public_browser_resources";
53
+ browser_executed: boolean;
54
+ requests_recorded: number;
55
+ http_responses: number;
56
+ http_2xx_3xx: number;
57
+ http_4xx: number;
58
+ http_5xx: number;
59
+ http_429: number;
60
+ transport_failures: number;
61
+ tool_blocked_requests: number;
62
+ pending_requests: number;
63
+ additional_budget_blocked: number;
64
+ critical_resource_failures: number;
65
+ api_failures: number;
66
+ image_failures: number;
67
+ third_party_failures: number;
68
+ slow_requests: number;
69
+ navigation_completed: boolean | null;
70
+ resource_types: ResourceTypeSummary[];
71
+ coverage_limited: true;
72
+ limitations: string[];
73
+ total_findings: number;
74
+ findings: ResourceFinding[];
75
+ findings_truncated: boolean;
76
+ error?: string;
77
+ }
78
+ export declare function emptyResourceFailureReview(scope?: ResourceFailureReview["scope"]): ResourceFailureReview;
79
+ export declare function analyzeResourceFailures(input: ResourceReviewInput, scope?: ResourceFailureReview["scope"]): ResourceFailureReview;
@@ -0,0 +1,178 @@
1
+ /**
2
+ * V08: bounded redacted browser resource observations.
3
+ * HTTP 4xx/5xx are responses, NOT Puppeteer requestfailed events; request
4
+ * transport failures, tool-policy blocks and still-pending requests are
5
+ * independent categories. No URLs, headers or exception text is returned.
6
+ */
7
+ export const MAX_RESOURCE_OBSERVATIONS = 64;
8
+ export const MAX_RESOURCE_FINDINGS = 20;
9
+ export const MAX_RESOURCE_BROWSER_MS = 24_000;
10
+ export const RESOURCE_TYPES = [
11
+ "document", "script", "stylesheet", "image", "font", "xhr", "fetch",
12
+ "media", "other",
13
+ ];
14
+ export const RESOURCE_OUTCOMES = [
15
+ "http", "transport_failed", "tool_blocked", "pending",
16
+ ];
17
+ export const RESOURCE_FAILURE_REASONS = [
18
+ "dns", "timeout", "tls", "connection", "canceled", "other",
19
+ ];
20
+ export const RESOURCE_ORIGINS = ["same_origin", "third_party", "unknown"];
21
+ export const RESOURCE_FINDING_CODES = [
22
+ "document_http_error", "document_transport_failed",
23
+ "script_http_error", "script_transport_failed",
24
+ "stylesheet_http_error", "stylesheet_transport_failed",
25
+ "api_http_error", "api_transport_failed",
26
+ "image_http_error", "font_http_error",
27
+ "other_http_error", "other_transport_failed",
28
+ "third_party_failures", "slow_resource_sample",
29
+ "resource_budget_reached", "tool_blocked_resources",
30
+ "pending_resources", "navigation_incomplete",
31
+ ];
32
+ const limitations = [
33
+ "The report is an observed, bounded network sample from a local browser or caller evidence; it is not a continuous uptime or Googlebot resource-loading audit.",
34
+ "HTTP 4xx/5xx responses, transport failures, explicit tool-policy blocks and pending requests are distinct. Tool blocks are not website failures.",
35
+ "A failed image, stylesheet or script is an investigation lead, not proof of visible breakage, Google indexing failure or a ranking cause.",
36
+ "Only capped status/transport type/count observations are returned; URLs, query tokens, response bodies, headers and browser error messages are not exposed.",
37
+ ];
38
+ export function emptyResourceFailureReview(scope = "caller_supplied_resource_observations") {
39
+ return {
40
+ scope, browser_executed: false, requests_recorded: 0,
41
+ http_responses: 0, http_2xx_3xx: 0, http_4xx: 0, http_5xx: 0,
42
+ http_429: 0, transport_failures: 0, tool_blocked_requests: 0,
43
+ pending_requests: 0, additional_budget_blocked: 0,
44
+ critical_resource_failures: 0, api_failures: 0,
45
+ image_failures: 0, third_party_failures: 0, slow_requests: 0,
46
+ navigation_completed: null,
47
+ resource_types: RESOURCE_TYPES.map((resource_type) => ({
48
+ resource_type, attempted: 0, http_responses: 0, http_4xx: 0,
49
+ http_5xx: 0, transport_failures: 0, blocked_by_tool: 0,
50
+ still_pending: 0,
51
+ })),
52
+ coverage_limited: true, limitations, total_findings: 0, findings: [],
53
+ findings_truncated: false,
54
+ };
55
+ }
56
+ function validEnum(list, value) {
57
+ return typeof value === "string" && list.includes(value);
58
+ }
59
+ const critical = (type) => ["document", "script", "stylesheet"].includes(type);
60
+ const isApi = (type) => type === "xhr" || type === "fetch";
61
+ const isHttpError = (row) => row.outcome === "http" && (row.status_code ?? 0) >= 400;
62
+ const hasTransportError = (row) => row.outcome === "transport_failed";
63
+ export function analyzeResourceFailures(input, scope = "caller_supplied_resource_observations") {
64
+ if (!input || !Array.isArray(input.observations) ||
65
+ input.observations.length === 0 || input.observations.length > MAX_RESOURCE_OBSERVATIONS ||
66
+ (input.additional_budget_blocked !== undefined &&
67
+ (!Number.isSafeInteger(input.additional_budget_blocked) ||
68
+ input.additional_budget_blocked < 0 || input.additional_budget_blocked > 1_000_000)) ||
69
+ (input.navigation_completed !== undefined &&
70
+ typeof input.navigation_completed !== "boolean")) {
71
+ throw new Error("Supply one to 64 fixed-shape observed resource outcomes.");
72
+ }
73
+ const result = emptyResourceFailureReview(scope);
74
+ result.browser_executed = scope === "guarded_public_browser_resources";
75
+ result.requests_recorded = input.observations.length;
76
+ result.additional_budget_blocked = input.additional_budget_blocked ?? 0;
77
+ result.navigation_completed = input.navigation_completed ?? null;
78
+ for (const [i, row] of input.observations.entries()) {
79
+ if (!row || typeof row !== "object" ||
80
+ !validEnum(RESOURCE_TYPES, row.resource_type) ||
81
+ !validEnum(RESOURCE_OUTCOMES, row.outcome) ||
82
+ !validEnum(RESOURCE_ORIGINS, row.origin) ||
83
+ (row.status_code !== undefined &&
84
+ (!Number.isInteger(row.status_code) || row.status_code < 200 ||
85
+ row.status_code > 599 || row.outcome !== "http")) ||
86
+ (row.outcome === "http" && row.status_code === undefined) ||
87
+ (row.failure_reason !== undefined &&
88
+ (!validEnum(RESOURCE_FAILURE_REASONS, row.failure_reason) ||
89
+ row.outcome !== "transport_failed")) ||
90
+ (row.outcome === "transport_failed" && row.failure_reason === undefined) ||
91
+ (row.duration_ms !== undefined &&
92
+ (!Number.isFinite(row.duration_ms) || row.duration_ms < 0 ||
93
+ row.duration_ms > 600_000))) {
94
+ throw new Error("Invalid browser resource observation at ordinal " + (i + 1));
95
+ }
96
+ const type = result.resource_types.find((x) => x.resource_type === row.resource_type);
97
+ type.attempted++;
98
+ const httpError = isHttpError(row);
99
+ const transportError = hasTransportError(row);
100
+ const failed = httpError || transportError;
101
+ if (row.outcome === "http") {
102
+ result.http_responses++;
103
+ type.http_responses++;
104
+ if (row.status_code >= 500) {
105
+ result.http_5xx++;
106
+ type.http_5xx++;
107
+ }
108
+ else if (row.status_code >= 400) {
109
+ result.http_4xx++;
110
+ type.http_4xx++;
111
+ }
112
+ else
113
+ result.http_2xx_3xx++;
114
+ if (row.status_code === 429)
115
+ result.http_429++;
116
+ }
117
+ else if (transportError) {
118
+ result.transport_failures++;
119
+ type.transport_failures++;
120
+ }
121
+ else if (row.outcome === "tool_blocked") {
122
+ result.tool_blocked_requests++;
123
+ type.blocked_by_tool++;
124
+ }
125
+ else {
126
+ result.pending_requests++;
127
+ type.still_pending++;
128
+ }
129
+ if (failed && critical(row.resource_type))
130
+ result.critical_resource_failures++;
131
+ if (failed && isApi(row.resource_type))
132
+ result.api_failures++;
133
+ if (failed && row.resource_type === "image")
134
+ result.image_failures++;
135
+ if (failed && row.origin === "third_party")
136
+ result.third_party_failures++;
137
+ if (row.duration_ms !== undefined && row.duration_ms > 3_000 &&
138
+ row.outcome === "http")
139
+ result.slow_requests++;
140
+ }
141
+ const all = [];
142
+ const add = (code, severity, count, message) => {
143
+ if (count)
144
+ all.push({ code, severity, count, message });
145
+ };
146
+ const count = (type, predicate) => input.observations.filter((row) => row.resource_type === type && predicate(row)).length;
147
+ for (const [type, prefix] of [
148
+ ["document", "document"], ["script", "script"],
149
+ ["stylesheet", "stylesheet"],
150
+ ]) {
151
+ add((prefix + "_http_error"), "warning", count(type, isHttpError), "A sampled " + prefix +
152
+ " returned HTTP 4xx/5xx; investigate server response and resource dependency.");
153
+ add((prefix + "_transport_failed"), "warning", count(type, hasTransportError), "A sampled " + prefix +
154
+ " request failed at the network/browser transport level without a usable response.");
155
+ }
156
+ add("api_http_error", "warning", input.observations.filter((row) => isApi(row.resource_type) && isHttpError(row)).length, "A sampled fetch/XHR API request returned HTTP 4xx/5xx.");
157
+ add("api_transport_failed", "warning", input.observations.filter((row) => isApi(row.resource_type) && hasTransportError(row)).length, "A sampled fetch/XHR request failed before receiving a usable HTTP response.");
158
+ add("image_http_error", "info", count("image", isHttpError), "One or more sampled image requests returned HTTP 4xx/5xx; verify affected image elements.");
159
+ add("font_http_error", "info", count("font", isHttpError), "A sampled font request returned HTTP 4xx/5xx; verify visible fallback and font loading.");
160
+ add("other_http_error", "info", input.observations.filter((row) => !critical(row.resource_type) && !isApi(row.resource_type)
161
+ && row.resource_type !== "image" && row.resource_type !== "font" &&
162
+ isHttpError(row)).length, "Other sampled resource requests returned HTTP 4xx/5xx.");
163
+ add("other_transport_failed", "info", input.observations.filter((row) => !critical(row.resource_type) &&
164
+ !isApi(row.resource_type) && hasTransportError(row)).length, "A non-critical sampled resource request failed at the transport level.");
165
+ add("third_party_failures", "info", result.third_party_failures, "Some attempted third-party requests failed; compare against browser privacy and network policy.");
166
+ add("slow_resource_sample", "info", result.slow_requests, "Some completed resource responses exceeded three seconds in this limited browser sample.");
167
+ add("resource_budget_reached", "info", result.additional_budget_blocked, "The diagnostic stopped additional network requests at its fixed observation cap; the page was not fully loaded.");
168
+ add("tool_blocked_resources", "info", result.tool_blocked_requests, "The validator blocked some requests by policy; these are not proven failures of the site's resources.");
169
+ add("pending_resources", "info", result.pending_requests, "Some requests were still pending when the sampling window ended; no failure is presumed.");
170
+ add("navigation_incomplete", "warning", result.navigation_completed === false ? 1 : 0, "The browser navigation did not complete within the bounded diagnostic window; inspect independently.");
171
+ all.sort((a, b) => (a.severity === b.severity ? 0 : a.severity === "warning" ? -1 : 1)
172
+ || a.code.localeCompare(b.code));
173
+ result.total_findings = all.length;
174
+ result.findings = all.slice(0, MAX_RESOURCE_FINDINGS);
175
+ result.findings_truncated = all.length > MAX_RESOURCE_FINDINGS;
176
+ return result;
177
+ }
178
+ //# sourceMappingURL=resource-failures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-failures.js","sourceRoot":"","sources":["../../../src/modules/browser-ux/resource-failures.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAC5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACxC,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAC9C,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,E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P 4xx/5xx are responses, NOT Puppeteer requestfailed events; request\n * transport failures, tool-policy blocks and still-pending requests are\n * independent categories. No URLs, headers or exception text is returned.\n */\nexport const MAX_RESOURCE_OBSERVATIONS = 64;\nexport const MAX_RESOURCE_FINDINGS = 20;\nexport const MAX_RESOURCE_BROWSER_MS = 24_000;\nexport const RESOURCE_TYPES = [\n \"document\", \"script\", \"stylesheet\", \"image\", \"font\", \"xhr\", \"fetch\",\n \"media\", \"other\",\n] as const;\nexport const RESOURCE_OUTCOMES = [\n \"http\", \"transport_failed\", \"tool_blocked\", \"pending\",\n] as const;\nexport const RESOURCE_FAILURE_REASONS = [\n \"dns\", \"timeout\", \"tls\", \"connection\", \"canceled\", \"other\",\n] as const;\nexport const RESOURCE_ORIGINS = [\"same_origin\", \"third_party\", \"unknown\"] as const;\nexport const RESOURCE_FINDING_CODES = [\n \"document_http_error\", \"document_transport_failed\",\n \"script_http_error\", \"script_transport_failed\",\n \"stylesheet_http_error\", \"stylesheet_transport_failed\",\n \"api_http_error\", \"api_transport_failed\",\n \"image_http_error\", \"font_http_error\",\n \"other_http_error\", \"other_transport_failed\",\n \"third_party_failures\", \"slow_resource_sample\",\n \"resource_budget_reached\", \"tool_blocked_resources\",\n \"pending_resources\", \"navigation_incomplete\",\n] as const;\n\nexport type ResourceType = typeof RESOURCE_TYPES[number];\nexport type ResourceOutcome = typeof RESOURCE_OUTCOMES[number];\nexport type ResourceFailureReason = typeof RESOURCE_FAILURE_REASONS[number];\nexport type ResourceOrigin = typeof RESOURCE_ORIGINS[number];\nexport type ResourceFindingCode = typeof RESOURCE_FINDING_CODES[number];\nexport interface ResourceObservation {\n resource_type: ResourceType;\n origin: ResourceOrigin;\n outcome: ResourceOutcome;\n status_code?: number;\n failure_reason?: ResourceFailureReason;\n duration_ms?: number;\n}\nexport interface ResourceReviewInput {\n observations: ResourceObservation[];\n /** Number of requests blocked after the fixed report observation cap. */\n additional_budget_blocked?: number;\n /** Whether main navigation completed before its deadline. */\n navigation_completed?: boolean;\n}\nexport interface ResourceTypeSummary {\n resource_type: ResourceType;\n attempted: number;\n http_responses: number;\n http_4xx: number;\n http_5xx: number;\n transport_failures: number;\n blocked_by_tool: number;\n still_pending: number;\n}\nexport interface ResourceFinding {\n code: ResourceFindingCode;\n severity: \"warning\" | \"info\";\n count: number;\n message: string;\n}\nexport interface ResourceFailureReview {\n scope: \"caller_supplied_resource_observations\" | \"guarded_public_browser_resources\";\n browser_executed: boolean;\n requests_recorded: number;\n http_responses: number;\n http_2xx_3xx: number;\n http_4xx: number;\n http_5xx: number;\n http_429: number;\n transport_failures: number;\n tool_blocked_requests: number;\n pending_requests: number;\n additional_budget_blocked: number;\n critical_resource_failures: number;\n api_failures: number;\n image_failures: number;\n third_party_failures: number;\n slow_requests: number;\n navigation_completed: boolean | null;\n resource_types: ResourceTypeSummary[];\n coverage_limited: true;\n limitations: string[];\n total_findings: number;\n findings: ResourceFinding[];\n findings_truncated: boolean;\n error?: string;\n}\nconst limitations = [\n \"The report is an observed, bounded network sample from a local browser or caller evidence; it is not a continuous uptime or Googlebot resource-loading audit.\",\n \"HTTP 4xx/5xx responses, transport failures, explicit tool-policy blocks and pending requests are distinct. Tool blocks are not website failures.\",\n \"A failed image, stylesheet or script is an investigation lead, not proof of visible breakage, Google indexing failure or a ranking cause.\",\n \"Only capped status/transport type/count observations are returned; URLs, query tokens, response bodies, headers and browser error messages are not exposed.\",\n];\n\nexport function emptyResourceFailureReview(\n scope: ResourceFailureReview[\"scope\"] = \"caller_supplied_resource_observations\",\n): ResourceFailureReview {\n return {\n scope, browser_executed: false, requests_recorded: 0,\n http_responses: 0, http_2xx_3xx: 0, http_4xx: 0, http_5xx: 0,\n http_429: 0, transport_failures: 0, tool_blocked_requests: 0,\n pending_requests: 0, additional_budget_blocked: 0,\n critical_resource_failures: 0, api_failures: 0,\n image_failures: 0, third_party_failures: 0, slow_requests: 0,\n navigation_completed: null,\n resource_types: RESOURCE_TYPES.map((resource_type) => ({\n resource_type, attempted: 0, http_responses: 0, http_4xx: 0,\n http_5xx: 0, transport_failures: 0, blocked_by_tool: 0,\n still_pending: 0,\n })),\n coverage_limited: true, limitations, total_findings: 0, findings: [],\n findings_truncated: false,\n };\n}\n\nfunction validEnum<T extends string>(list: readonly T[], value: unknown): value is T {\n return typeof value === \"string\" && list.includes(value as T);\n}\nconst critical = (type: ResourceType): boolean =>\n [\"document\", \"script\", \"stylesheet\"].includes(type);\nconst isApi = (type: ResourceType): boolean => type === \"xhr\" || type === \"fetch\";\nconst isHttpError = (row: ResourceObservation): boolean =>\n row.outcome === \"http\" && (row.status_code ?? 0) >= 400;\nconst hasTransportError = (row: ResourceObservation): boolean => row.outcome === \"transport_failed\";\n\nexport function analyzeResourceFailures(\n input: ResourceReviewInput,\n scope: ResourceFailureReview[\"scope\"] = \"caller_supplied_resource_observations\",\n): ResourceFailureReview {\n if (!input || !Array.isArray(input.observations) ||\n input.observations.length === 0 || input.observations.length > MAX_RESOURCE_OBSERVATIONS ||\n (input.additional_budget_blocked !== undefined &&\n (!Number.isSafeInteger(input.additional_budget_blocked) ||\n input.additional_budget_blocked < 0 || input.additional_budget_blocked > 1_000_000)) ||\n (input.navigation_completed !== undefined &&\n typeof input.navigation_completed !== \"boolean\")) {\n throw new Error(\"Supply one to 64 fixed-shape observed resource outcomes.\");\n }\n const result = emptyResourceFailureReview(scope);\n result.browser_executed = scope === \"guarded_public_browser_resources\";\n result.requests_recorded = input.observations.length;\n result.additional_budget_blocked = input.additional_budget_blocked ?? 0;\n result.navigation_completed = input.navigation_completed ?? null;\n for (const [i, row] of input.observations.entries()) {\n if (!row || typeof row !== \"object\" ||\n !validEnum(RESOURCE_TYPES, row.resource_type) ||\n !validEnum(RESOURCE_OUTCOMES, row.outcome) ||\n !validEnum(RESOURCE_ORIGINS, row.origin) ||\n (row.status_code !== undefined &&\n (!Number.isInteger(row.status_code) || row.status_code < 200 ||\n row.status_code > 599 || row.outcome !== \"http\")) ||\n (row.outcome === \"http\" && row.status_code === undefined) ||\n (row.failure_reason !== undefined &&\n (!validEnum(RESOURCE_FAILURE_REASONS, row.failure_reason) ||\n row.outcome !== \"transport_failed\")) ||\n (row.outcome === \"transport_failed\" && row.failure_reason === undefined) ||\n (row.duration_ms !== undefined &&\n (!Number.isFinite(row.duration_ms) || row.duration_ms < 0 ||\n row.duration_ms > 600_000))) {\n throw new Error(\"Invalid browser resource observation at ordinal \" + (i + 1));\n }\n const type = result.resource_types.find((x) => x.resource_type === row.resource_type)!;\n type.attempted++;\n const httpError = isHttpError(row);\n const transportError = hasTransportError(row);\n const failed = httpError || transportError;\n if (row.outcome === \"http\") {\n result.http_responses++;\n type.http_responses++;\n if (row.status_code! >= 500) { result.http_5xx++; type.http_5xx++; }\n else if (row.status_code! >= 400) { result.http_4xx++; type.http_4xx++; }\n else result.http_2xx_3xx++;\n if (row.status_code === 429) result.http_429++;\n } else if (transportError) {\n result.transport_failures++;\n type.transport_failures++;\n } else if (row.outcome === \"tool_blocked\") {\n result.tool_blocked_requests++;\n type.blocked_by_tool++;\n } else {\n result.pending_requests++;\n type.still_pending++;\n }\n if (failed && critical(row.resource_type)) result.critical_resource_failures++;\n if (failed && isApi(row.resource_type)) result.api_failures++;\n if (failed && row.resource_type === \"image\") result.image_failures++;\n if (failed && row.origin === \"third_party\") result.third_party_failures++;\n if (row.duration_ms !== undefined && row.duration_ms > 3_000 &&\n row.outcome === \"http\") result.slow_requests++;\n }\n const all: ResourceFinding[] = [];\n const add = (code: ResourceFindingCode, severity: \"warning\" | \"info\",\n count: number, message: string) => {\n if (count) all.push({ code, severity, count, message });\n };\n const count = (type: ResourceType, predicate: (row: ResourceObservation) => boolean) =>\n input.observations.filter((row) => row.resource_type === type && predicate(row)).length;\n for (const [type, prefix] of [\n [\"document\", \"document\"], [\"script\", \"script\"],\n [\"stylesheet\", \"stylesheet\"],\n ] as const) {\n add((prefix + \"_http_error\") as ResourceFindingCode, \"warning\",\n count(type, isHttpError), \"A sampled \" + prefix +\n \" returned HTTP 4xx/5xx; investigate server response and resource dependency.\");\n add((prefix + \"_transport_failed\") as ResourceFindingCode, \"warning\",\n count(type, hasTransportError), \"A sampled \" + prefix +\n \" request failed at the network/browser transport level without a usable response.\");\n }\n add(\"api_http_error\", \"warning\",\n input.observations.filter((row) => isApi(row.resource_type) && isHttpError(row)).length,\n \"A sampled fetch/XHR API request returned HTTP 4xx/5xx.\");\n add(\"api_transport_failed\", \"warning\",\n input.observations.filter((row) => isApi(row.resource_type) && hasTransportError(row)).length,\n \"A sampled fetch/XHR request failed before receiving a usable HTTP response.\");\n add(\"image_http_error\", \"info\", count(\"image\", isHttpError),\n \"One or more sampled image requests returned HTTP 4xx/5xx; verify affected image elements.\");\n add(\"font_http_error\", \"info\", count(\"font\", isHttpError),\n \"A sampled font request returned HTTP 4xx/5xx; verify visible fallback and font loading.\");\n add(\"other_http_error\", \"info\",\n input.observations.filter((row) => !critical(row.resource_type) && !isApi(row.resource_type)\n && row.resource_type !== \"image\" && row.resource_type !== \"font\" &&\n isHttpError(row)).length,\n \"Other sampled resource requests returned HTTP 4xx/5xx.\");\n add(\"other_transport_failed\", \"info\",\n input.observations.filter((row) => !critical(row.resource_type) &&\n !isApi(row.resource_type) && hasTransportError(row)).length,\n \"A non-critical sampled resource request failed at the transport level.\");\n add(\"third_party_failures\", \"info\", result.third_party_failures,\n \"Some attempted third-party requests failed; compare against browser privacy and network policy.\");\n add(\"slow_resource_sample\", \"info\", result.slow_requests,\n \"Some completed resource responses exceeded three seconds in this limited browser sample.\");\n add(\"resource_budget_reached\", \"info\", result.additional_budget_blocked,\n \"The diagnostic stopped additional network requests at its fixed observation cap; the page was not fully loaded.\");\n add(\"tool_blocked_resources\", \"info\", result.tool_blocked_requests,\n \"The validator blocked some requests by policy; these are not proven failures of the site's resources.\");\n add(\"pending_resources\", \"info\", result.pending_requests,\n \"Some requests were still pending when the sampling window ended; no failure is presumed.\");\n add(\"navigation_incomplete\", \"warning\", result.navigation_completed === false ? 1 : 0,\n \"The browser navigation did not complete within the bounded diagnostic window; inspect independently.\");\n all.sort((a, b) => (a.severity === b.severity ? 0 : a.severity === \"warning\" ? -1 : 1)\n || a.code.localeCompare(b.code));\n result.total_findings = all.length;\n result.findings = all.slice(0, MAX_RESOURCE_FINDINGS);\n result.findings_truncated = all.length > MAX_RESOURCE_FINDINGS;\n return result;\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import { type ScreenshotBrowserRuntime } from "../../screenshot.js";
2
+ import { type ViewportParityReview, type ParityScope } from "./viewport-parity.js";
3
+ export declare function inspectViewportParity(html: string, pageUrl: string, runtime?: ScreenshotBrowserRuntime, scope?: ParityScope): Promise<ViewportParityReview>;
4
+ /** One public robots-gated HTML GET, then two isolated offline viewports. */
5
+ export declare function inspectPublicViewportParity(url: string, runtime?: ScreenshotBrowserRuntime): Promise<ViewportParityReview>;
@@ -0,0 +1,316 @@
1
+ /**
2
+ * V09 local-only browser comparator. Same sanitized HTML, separate mobile and
3
+ * desktop pages, fixed viewports, scripts disabled and deny-all transport.
4
+ * Only a native summary may receive Enter/tap; no links or forms activated.
5
+ */
6
+ import { load } from "cheerio";
7
+ import { defaultScreenshotBrowserRuntime, } from "../../screenshot.js";
8
+ import { safeHttpResourceUrl } from "../http-crawl/non-html-directives.js";
9
+ import { fetchGuardedPublicHtml } from "./raw-rendered-probe.js";
10
+ import { analyzeViewportParity, MAX_PARITY_HTML_BYTES, MAX_PARITY_BROWSER_MS, MOBILE_VIEWPORT, DESKTOP_VIEWPORT, MAX_PARITY_CONTROLS, MAX_PARITY_LINKS, MAX_PARITY_TAB_STEPS, MAX_PARITY_WORDS, } from "./viewport-parity.js";
11
+ const DENY_ALL_PROXY = "http://127.0.0.1:9";
12
+ const CONTROL_SELECTOR = 'a[href],button,input:not([type="hidden"]),select,textarea,summary,'
13
+ + '[tabindex],[role="button"],[role="link"],[role="checkbox"],[role="switch"]';
14
+ const textBytes = (s) => new TextEncoder().encode(s).byteLength;
15
+ const normalizedMarkup = (raw) => {
16
+ const $ = load(raw);
17
+ $("script").filter((_, el) => {
18
+ const type = ($(el).attr("type") ?? "").split(";", 1)[0].trim().toLowerCase();
19
+ // Structured data is inert JSON, not executable JavaScript. Retain it for
20
+ // equivalent mobile/desktop SEO metadata counts.
21
+ return type !== "application/ld+json" && type !== "application/json";
22
+ }).remove();
23
+ $("iframe,frame,frameset,object,embed,portal").remove();
24
+ $('meta[http-equiv="refresh" i]').remove();
25
+ $("*").each((_, element) => {
26
+ if (!("attribs" in element) || !element.attribs)
27
+ return;
28
+ for (const name of Object.keys(element.attribs)) {
29
+ if (/^on[a-z]+$/iu.test(name))
30
+ $(element).removeAttr(name);
31
+ }
32
+ });
33
+ return $.html();
34
+ };
35
+ export async function inspectViewportParity(html, pageUrl, runtime = defaultScreenshotBrowserRuntime, scope = "isolated_supplied_html_viewports") {
36
+ if (!safeHttpResourceUrl(pageUrl) || typeof html !== "string" ||
37
+ !html.trim() || textBytes(html) > MAX_PARITY_HTML_BYTES) {
38
+ throw new Error("Provide one safe public URL label and HTML within the 400 KB byte limit.");
39
+ }
40
+ const safeMarkup = normalizedMarkup(html);
41
+ if (textBytes(safeMarkup) > MAX_PARITY_HTML_BYTES) {
42
+ throw new Error("The normalized HTML exceeded the bounded viewport input size.");
43
+ }
44
+ let browser;
45
+ let timer;
46
+ let pendingFailure;
47
+ let blocked = 0;
48
+ try {
49
+ browser = await runtime.launch(DENY_ALL_PROXY);
50
+ timer = setTimeout(() => { void browser?.close().catch(() => { }); }, MAX_PARITY_BROWSER_MS);
51
+ timer.unref?.();
52
+ const samples = [];
53
+ for (const [kind, vp] of [
54
+ ["mobile", MOBILE_VIEWPORT], ["desktop", DESKTOP_VIEWPORT],
55
+ ]) {
56
+ const page = await browser.newPage();
57
+ page.setDefaultTimeout(5_000);
58
+ page.setDefaultNavigationTimeout(8_000);
59
+ // Viewports must be configured before HTML is parsed: isMobile affects
60
+ // meta viewport behavior, touch/scale and CSS media query evaluation.
61
+ await page.setViewport({ ...vp });
62
+ await page.setJavaScriptEnabled(false);
63
+ await page.setOfflineMode(true);
64
+ await page.setRequestInterception(true);
65
+ page.on("request", (request) => {
66
+ blocked++;
67
+ void request.abort("blockedbyclient").catch(() => { });
68
+ });
69
+ await page.setContent(safeMarkup, {
70
+ waitUntil: "domcontentloaded", timeout: 8_000,
71
+ });
72
+ const snapshot = await page.evaluate((url, selector, wordCap, linkCap, controlCap, requestedWidth) => {
73
+ const dom = globalThis.document;
74
+ const win = globalThis;
75
+ const compute = win.getComputedStyle;
76
+ const withinViewport = (el) => {
77
+ if (!el || el.closest("[hidden],[inert],[aria-hidden='true']"))
78
+ return false;
79
+ const s = compute(el);
80
+ const r = el.getBoundingClientRect();
81
+ return s.display !== "none" &&
82
+ s.visibility !== "hidden" && s.visibility !== "collapse" &&
83
+ Number.parseFloat(s.opacity || "1") > 0 &&
84
+ r.width > 0 && r.height > 0;
85
+ };
86
+ const words = (text) => (text.normalize("NFKC").toLocaleLowerCase("en")
87
+ .match(/[\p{L}\p{N}]+/gu) ?? [])
88
+ .filter((token) => token.length >= 2 && token.length <= 60)
89
+ .slice(0, wordCap);
90
+ const title = String(dom.querySelector("head title")?.textContent ?? "")
91
+ .replace(/\s+/gu, " ").trim().slice(0, 256);
92
+ const desc = String(dom.querySelector('head meta[name="description" i]')
93
+ ?.getAttribute("content") ?? "").trim().slice(0, 256);
94
+ const firstH1 = String(dom.querySelector("body h1")?.textContent ?? "")
95
+ .replace(/\s+/gu, " ").trim().slice(0, 256);
96
+ const main = dom.querySelector("main,[role='main'],article") ?? dom.body;
97
+ // Keep CSS-hidden page content in the DOM comparison, but exclude
98
+ // inert script/style/template text that is not page copy. Clone only
99
+ // the bounded supplied document so JSON-LD counts stay unchanged.
100
+ const textOnlyMain = main?.cloneNode(true);
101
+ textOnlyMain?.querySelectorAll("script,style,template")
102
+ .forEach((node) => node.remove());
103
+ const rawText = String(textOnlyMain?.textContent ?? "");
104
+ const visibleText = String(main?.innerText ?? "");
105
+ const rawTokens = words(rawText);
106
+ const visibleTokens = words(visibleText);
107
+ const anchors = Array.from(dom.querySelectorAll("body a[href]"));
108
+ const origin = new URL(url).origin;
109
+ let base = url;
110
+ let foreignBase = false;
111
+ const baseHref = dom.querySelector("head base[href]")?.getAttribute("href");
112
+ if (baseHref) {
113
+ try {
114
+ const candidate = new URL(baseHref, url);
115
+ if (candidate.origin === origin && !candidate.search &&
116
+ !candidate.username && !candidate.password && !candidate.port) {
117
+ base = candidate.href;
118
+ }
119
+ else
120
+ foreignBase = true;
121
+ }
122
+ catch {
123
+ foreignBase = true;
124
+ }
125
+ }
126
+ const links = [], visibleLinks = [], navLinks = [];
127
+ for (const anchor of anchors.slice(0, linkCap)) {
128
+ const raw = String(anchor.getAttribute("href") ?? "").trim();
129
+ if (!raw || raw.length > 1_024 || raw.startsWith("#") ||
130
+ (foreignBase && !/^[a-z][a-z0-9+.-]*:/iu.test(raw) &&
131
+ !raw.startsWith("//")))
132
+ continue;
133
+ try {
134
+ const resolved = new URL(raw, base);
135
+ if (!["https:", "http:"].includes(resolved.protocol) ||
136
+ resolved.origin !== origin || resolved.username ||
137
+ resolved.password || resolved.port || resolved.search ||
138
+ raw.includes("?"))
139
+ continue;
140
+ resolved.hash = "";
141
+ const label = resolved.href;
142
+ links.push(label);
143
+ if (withinViewport(anchor)) {
144
+ visibleLinks.push(label);
145
+ if (anchor.closest("nav,header,footer,[role='navigation']")) {
146
+ navLinks.push(label);
147
+ }
148
+ }
149
+ }
150
+ catch { /* Invalid/unsupported link is not evidence. */ }
151
+ }
152
+ const controls = Array.from(dom.querySelectorAll(selector));
153
+ let visibleControls = 0, focusable = 0, smallTargets = 0;
154
+ for (const el of controls.slice(0, controlCap)) {
155
+ if (!withinViewport(el))
156
+ continue;
157
+ visibleControls++;
158
+ if (el.tabIndex >= 0 && !el.disabled)
159
+ focusable++;
160
+ const box = el.getBoundingClientRect();
161
+ if (box.width < 24 || box.height < 24)
162
+ smallTargets++;
163
+ }
164
+ const rawCanonicals = [];
165
+ let canonicalDeclarations = 0;
166
+ for (const link of Array.from(dom.querySelectorAll("head link[rel]"))) {
167
+ if (!String(link.rel ?? "").toLowerCase().split(/\s+/u).includes("canonical"))
168
+ continue;
169
+ canonicalDeclarations++;
170
+ try {
171
+ const c = new URL(String(link.getAttribute("href")), url);
172
+ c.hash = "";
173
+ if (["http:", "https:"].includes(c.protocol) &&
174
+ !c.username && !c.password && !c.port && !c.search &&
175
+ c.href.length <= 512)
176
+ rawCanonicals.push(c.href);
177
+ }
178
+ catch { /* No reliable canonical label from this markup. */ }
179
+ }
180
+ const robots = Array.from(dom.querySelectorAll("head meta[name][content]"));
181
+ const noindex = robots.some((meta) => ["robots", "googlebot"].includes(String(meta.name ?? "").toLowerCase()) &&
182
+ /(?:^|[\s,;])(?:noindex|none)(?:$|[\s,;])/iu.test(String(meta.content ?? "")));
183
+ const jsonld = Array.from(dom.querySelectorAll("script[type]"))
184
+ .filter((script) => String(script.getAttribute("type") ?? "")
185
+ .split(";", 1)[0].trim().toLowerCase() === "application/ld+json")
186
+ .length;
187
+ const effective = Math.round(Number(win.innerWidth) || 0);
188
+ const scrollWidth = Math.round(Number(dom.documentElement?.scrollWidth) || effective);
189
+ return {
190
+ width: 0, height: 0,
191
+ effective_layout_width: effective,
192
+ viewport_meta_present: Boolean(dom.querySelector('head meta[name="viewport" i]')),
193
+ title, description: desc, first_h1: firstH1,
194
+ h1_count: dom.querySelectorAll("body h1").length,
195
+ main_dom_words: rawTokens, main_visible_words: visibleTokens,
196
+ same_origin_links: [...new Set(links)],
197
+ visible_links: [...new Set(visibleLinks)],
198
+ visible_nav_links: [...new Set(navLinks)],
199
+ canonical: canonicalDeclarations === 0 ? null :
200
+ canonicalDeclarations === 1 && rawCanonicals.length === 1
201
+ ? rawCanonicals[0] : "unverified",
202
+ noindex, jsonld_blocks: jsonld,
203
+ controls_seen: controls.length, visible_controls: visibleControls,
204
+ keyboard_focusable_controls: focusable,
205
+ small_visible_controls: smallTargets,
206
+ observed_keyboard_targets: 0, keyboard_incomplete: false,
207
+ disclosure_toggled: null,
208
+ // In mobile emulation, innerWidth may itself expand to the widest
209
+ // unbreakable element. Compare against the configured CSS viewport,
210
+ // otherwise a 650px element can incorrectly look like zero overflow.
211
+ horizontal_overflow_px: Math.max(0, Math.max(scrollWidth, effective) - requestedWidth),
212
+ sample_truncated: rawText.length > 65_536 ||
213
+ visibleText.length > 65_536 || controls.length > controlCap ||
214
+ anchors.length > linkCap || words(rawText).length >= wordCap ||
215
+ words(visibleText).length >= wordCap,
216
+ };
217
+ }, pageUrl, CONTROL_SELECTOR, MAX_PARITY_WORDS, MAX_PARITY_LINKS, MAX_PARITY_CONTROLS, vp.width);
218
+ // The evidence contract records the requested *CSS screen* dimensions.
219
+ // Browser effective viewport width is recorded separately.
220
+ snapshot.width = vp.width;
221
+ snapshot.height = vp.height;
222
+ const seen = new Set();
223
+ if (snapshot.keyboard_focusable_controls > 0) {
224
+ try {
225
+ await page.evaluate(() => { globalThis.document.activeElement?.blur?.(); });
226
+ for (let i = 0; i < MAX_PARITY_TAB_STEPS; i++) {
227
+ await page.keyboard.press("Tab");
228
+ const ordinal = await page.evaluate((selector, cap) => {
229
+ const dom = globalThis.document;
230
+ const index = Array.from(dom.querySelectorAll(selector))
231
+ .indexOf(dom.activeElement) + 1;
232
+ return index <= cap ? index : 0;
233
+ }, CONTROL_SELECTOR, MAX_PARITY_CONTROLS);
234
+ if (!ordinal || seen.has(ordinal))
235
+ break;
236
+ seen.add(ordinal);
237
+ }
238
+ snapshot.observed_keyboard_targets = seen.size;
239
+ snapshot.keyboard_incomplete = snapshot.keyboard_focusable_controls > seen.size &&
240
+ (seen.size >= MAX_PARITY_TAB_STEPS ||
241
+ snapshot.controls_seen > MAX_PARITY_CONTROLS);
242
+ }
243
+ catch {
244
+ snapshot.keyboard_incomplete = true;
245
+ }
246
+ }
247
+ // Native <details> is the only element that can be activated. No arbitrary
248
+ // click, link navigation or form submission is allowed in this diagnostic.
249
+ const summary = await page.evaluate(() => {
250
+ const dom = globalThis.document;
251
+ const el = dom.querySelector("details > summary");
252
+ if (!el || el.closest("[hidden],[inert]"))
253
+ return null;
254
+ const s = globalThis.getComputedStyle(el);
255
+ const box = el.getBoundingClientRect();
256
+ const width = Number(globalThis.innerWidth);
257
+ const height = Number(globalThis.innerHeight);
258
+ if (s.display === "none" || s.visibility !== "visible" ||
259
+ box.width < 1 || box.height < 1 || box.right <= 0 || box.bottom <= 0 ||
260
+ box.left >= width || box.top >= height)
261
+ return null;
262
+ return {
263
+ x: Math.min(width - 2, Math.max(2, box.left + box.width / 2)),
264
+ y: Math.min(height - 2, Math.max(2, box.top + box.height / 2)),
265
+ before: Boolean(el.parentElement?.open),
266
+ };
267
+ });
268
+ if (summary) {
269
+ try {
270
+ if (kind === "mobile") {
271
+ await page.touchscreen.tap(summary.x, summary.y);
272
+ }
273
+ else {
274
+ await page.evaluate(() => {
275
+ globalThis.document.querySelector("details > summary")?.focus();
276
+ });
277
+ await page.keyboard.press("Enter");
278
+ }
279
+ const after = await page.evaluate(() => Boolean(globalThis.document
280
+ .querySelector("details > summary")?.parentElement?.open));
281
+ snapshot.disclosure_toggled = summary.before !== after;
282
+ }
283
+ catch {
284
+ snapshot.disclosure_toggled = false;
285
+ }
286
+ }
287
+ samples.push(snapshot);
288
+ await page.close();
289
+ }
290
+ return analyzeViewportParity(pageUrl, samples[0], samples[1], {
291
+ scope, blockedResources: Math.min(1_000, blocked),
292
+ });
293
+ }
294
+ catch (cause) {
295
+ pendingFailure = cause;
296
+ throw cause;
297
+ }
298
+ finally {
299
+ if (timer)
300
+ clearTimeout(timer);
301
+ try {
302
+ if (browser)
303
+ await browser.close();
304
+ }
305
+ catch (cause) {
306
+ if (!pendingFailure)
307
+ throw cause;
308
+ }
309
+ }
310
+ }
311
+ /** One public robots-gated HTML GET, then two isolated offline viewports. */
312
+ export async function inspectPublicViewportParity(url, runtime = defaultScreenshotBrowserRuntime) {
313
+ const { page_url, raw_html } = await fetchGuardedPublicHtml(url);
314
+ return inspectViewportParity(raw_html, page_url, runtime, "isolated_public_html_viewports");
315
+ }
316
+ //# sourceMappingURL=viewport-parity-probe.js.map