mcp-web-validator 1.3.51 → 1.3.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/README.md +64 -4
- package/dist/audit-history.d.ts +9 -0
- package/dist/audit-history.js +27 -0
- package/dist/audit-history.js.map +1 -1
- package/dist/index.js +2508 -2
- package/dist/index.js.map +1 -1
- package/dist/modules/browser-ux/lighthouse-lab-probe.d.ts +21 -0
- package/dist/modules/browser-ux/lighthouse-lab-probe.js +190 -0
- package/dist/modules/browser-ux/lighthouse-lab-probe.js.map +1 -0
- package/dist/modules/browser-ux/lighthouse-lab.d.ts +61 -0
- package/dist/modules/browser-ux/lighthouse-lab.js +98 -0
- package/dist/modules/browser-ux/lighthouse-lab.js.map +1 -0
- package/dist/modules/browser-ux/media-diagnostics.d.ts +41 -0
- package/dist/modules/browser-ux/media-diagnostics.js +183 -0
- package/dist/modules/browser-ux/media-diagnostics.js.map +1 -0
- package/dist/modules/browser-ux/raw-rendered-diff.d.ts +70 -0
- package/dist/modules/browser-ux/raw-rendered-diff.js +262 -0
- package/dist/modules/browser-ux/raw-rendered-diff.js.map +1 -0
- package/dist/modules/browser-ux/raw-rendered-probe.d.ts +17 -0
- package/dist/modules/browser-ux/raw-rendered-probe.js +163 -0
- package/dist/modules/browser-ux/raw-rendered-probe.js.map +1 -0
- package/dist/modules/browser-ux/resource-failures-probe.d.ts +11 -0
- package/dist/modules/browser-ux/resource-failures-probe.js +231 -0
- package/dist/modules/browser-ux/resource-failures-probe.js.map +1 -0
- package/dist/modules/browser-ux/resource-failures.d.ts +79 -0
- package/dist/modules/browser-ux/resource-failures.js +178 -0
- package/dist/modules/browser-ux/resource-failures.js.map +1 -0
- package/dist/modules/browser-ux/viewport-parity-probe.d.ts +5 -0
- package/dist/modules/browser-ux/viewport-parity-probe.js +307 -0
- package/dist/modules/browser-ux/viewport-parity-probe.js.map +1 -0
- package/dist/modules/browser-ux/viewport-parity.d.ts +112 -0
- package/dist/modules/browser-ux/viewport-parity.js +224 -0
- package/dist/modules/browser-ux/viewport-parity.js.map +1 -0
- package/dist/modules/browser-ux/wcag-interactions.d.ts +95 -0
- package/dist/modules/browser-ux/wcag-interactions.js +360 -0
- package/dist/modules/browser-ux/wcag-interactions.js.map +1 -0
- package/dist/modules/change-regression/availability-history-store.d.ts +18 -0
- package/dist/modules/change-regression/availability-history-store.js +168 -0
- package/dist/modules/change-regression/availability-history-store.js.map +1 -0
- package/dist/modules/change-regression/crawler-log-correlation.d.ts +111 -0
- package/dist/modules/change-regression/crawler-log-correlation.js +374 -0
- package/dist/modules/change-regression/crawler-log-correlation.js.map +1 -0
- package/dist/modules/change-regression/google-common-crawler-ip.d.ts +15 -0
- package/dist/modules/change-regression/google-common-crawler-ip.js +129 -0
- package/dist/modules/change-regression/google-common-crawler-ip.js.map +1 -0
- package/dist/modules/change-regression/historical-comparisons.d.ts +120 -0
- package/dist/modules/change-regression/historical-comparisons.js +330 -0
- package/dist/modules/change-regression/historical-comparisons.js.map +1 -0
- package/dist/modules/change-regression/production-change-comparison.d.ts +68 -0
- package/dist/modules/change-regression/production-change-comparison.js +214 -0
- package/dist/modules/change-regression/production-change-comparison.js.map +1 -0
- package/dist/modules/change-regression/regression-alerts.d.ts +73 -0
- package/dist/modules/change-regression/regression-alerts.js +183 -0
- package/dist/modules/change-regression/regression-alerts.js.map +1 -0
- package/dist/modules/change-regression/strict-observation-time.d.ts +7 -0
- package/dist/modules/change-regression/strict-observation-time.js +31 -0
- package/dist/modules/change-regression/strict-observation-time.js.map +1 -0
- package/dist/modules/content-schema/citation-methodology-consistency.d.ts +108 -0
- package/dist/modules/content-schema/citation-methodology-consistency.js +360 -0
- package/dist/modules/content-schema/citation-methodology-consistency.js.map +1 -0
- package/dist/modules/content-schema/competitor-intent-comparison.d.ts +74 -0
- package/dist/modules/content-schema/competitor-intent-comparison.js +185 -0
- package/dist/modules/content-schema/competitor-intent-comparison.js.map +1 -0
- package/dist/modules/content-schema/empty-boilerplate-content.d.ts +36 -0
- package/dist/modules/content-schema/empty-boilerplate-content.js +225 -0
- package/dist/modules/content-schema/empty-boilerplate-content.js.map +1 -0
- package/dist/modules/content-schema/extract-citation-methodology.d.ts +6 -0
- package/dist/modules/content-schema/extract-citation-methodology.js +201 -0
- package/dist/modules/content-schema/extract-citation-methodology.js.map +1 -0
- package/dist/modules/content-schema/extract-competitor-intent.d.ts +2 -0
- package/dist/modules/content-schema/extract-competitor-intent.js +140 -0
- package/dist/modules/content-schema/extract-competitor-intent.js.map +1 -0
- package/dist/modules/content-schema/extract-main-content.d.ts +6 -0
- package/dist/modules/content-schema/extract-main-content.js +33 -0
- package/dist/modules/content-schema/extract-main-content.js.map +1 -0
- package/dist/modules/content-schema/extract-metadata-consistency.d.ts +3 -0
- package/dist/modules/content-schema/extract-metadata-consistency.js +62 -0
- package/dist/modules/content-schema/extract-metadata-consistency.js.map +1 -0
- package/dist/modules/content-schema/extract-product-claims.d.ts +3 -0
- package/dist/modules/content-schema/extract-product-claims.js +58 -0
- package/dist/modules/content-schema/extract-product-claims.js.map +1 -0
- package/dist/modules/content-schema/extract-structured-data.d.ts +3 -0
- package/dist/modules/content-schema/extract-structured-data.js +25 -0
- package/dist/modules/content-schema/extract-structured-data.js.map +1 -0
- package/dist/modules/content-schema/metadata-consistency.d.ts +66 -0
- package/dist/modules/content-schema/metadata-consistency.js +282 -0
- package/dist/modules/content-schema/metadata-consistency.js.map +1 -0
- package/dist/modules/content-schema/product-claims.d.ts +73 -0
- package/dist/modules/content-schema/product-claims.js +195 -0
- package/dist/modules/content-schema/product-claims.js.map +1 -0
- package/dist/modules/content-schema/same-language-duplicates.d.ts +52 -0
- package/dist/modules/content-schema/same-language-duplicates.js +158 -0
- package/dist/modules/content-schema/same-language-duplicates.js.map +1 -0
- package/dist/modules/content-schema/structured-data-validation.d.ts +37 -0
- package/dist/modules/content-schema/structured-data-validation.js +385 -0
- package/dist/modules/content-schema/structured-data-validation.js.map +1 -0
- package/dist/modules/external-metrics/crux-field-probe.d.ts +10 -0
- package/dist/modules/external-metrics/crux-field-probe.js +113 -0
- package/dist/modules/external-metrics/crux-field-probe.js.map +1 -0
- package/dist/modules/external-metrics/crux-field.d.ts +61 -0
- package/dist/modules/external-metrics/crux-field.js +231 -0
- package/dist/modules/external-metrics/crux-field.js.map +1 -0
- package/dist/modules/http-crawl/availability-observations.d.ts +68 -0
- package/dist/modules/http-crawl/availability-observations.js +206 -0
- package/dist/modules/http-crawl/availability-observations.js.map +1 -0
- package/dist/modules/http-crawl/availability-probe.d.ts +8 -0
- package/dist/modules/http-crawl/availability-probe.js +46 -0
- package/dist/modules/http-crawl/availability-probe.js.map +1 -0
- package/dist/modules/http-crawl/crawler-access-probe.d.ts +6 -0
- package/dist/modules/http-crawl/crawler-access-probe.js +79 -0
- package/dist/modules/http-crawl/crawler-access-probe.js.map +1 -0
- package/dist/modules/http-crawl/crawler-access.d.ts +75 -0
- package/dist/modules/http-crawl/crawler-access.js +404 -0
- package/dist/modules/http-crawl/crawler-access.js.map +1 -0
- package/dist/modules/http-crawl/http-delivery-probe.d.ts +3 -0
- package/dist/modules/http-crawl/http-delivery-probe.js +44 -0
- package/dist/modules/http-crawl/http-delivery-probe.js.map +1 -0
- package/dist/modules/http-crawl/http-delivery.d.ts +64 -0
- package/dist/modules/http-crawl/http-delivery.js +269 -0
- package/dist/modules/http-crawl/http-delivery.js.map +1 -0
- package/dist/modules/http-crawl/https-security.d.ts +84 -0
- package/dist/modules/http-crawl/https-security.js +441 -0
- package/dist/modules/http-crawl/https-security.js.map +1 -0
- package/dist/modules/http-crawl/non-html-directives.d.ts +74 -0
- package/dist/modules/http-crawl/non-html-directives.js +353 -0
- package/dist/modules/http-crawl/non-html-directives.js.map +1 -0
- package/dist/modules/http-crawl/redirect-canonical-chains.d.ts +80 -0
- package/dist/modules/http-crawl/redirect-canonical-chains.js +459 -0
- package/dist/modules/http-crawl/redirect-canonical-chains.js.map +1 -0
- package/dist/modules/http-crawl/redirect-canonical-probe.d.ts +6 -0
- package/dist/modules/http-crawl/redirect-canonical-probe.js +83 -0
- package/dist/modules/http-crawl/redirect-canonical-probe.js.map +1 -0
- package/dist/modules/http-crawl/sitemap-inventory-probe.d.ts +8 -0
- package/dist/modules/http-crawl/sitemap-inventory-probe.js +155 -0
- package/dist/modules/http-crawl/sitemap-inventory-probe.js.map +1 -0
- package/dist/modules/http-crawl/sitemap-inventory.d.ts +107 -0
- package/dist/modules/http-crawl/sitemap-inventory.js +557 -0
- package/dist/modules/http-crawl/sitemap-inventory.js.map +1 -0
- package/dist/modules/http-crawl/url-variants.d.ts +86 -0
- package/dist/modules/http-crawl/url-variants.js +379 -0
- package/dist/modules/http-crawl/url-variants.js.map +1 -0
- package/dist/modules/site-architecture/extract-internal-links.d.ts +3 -0
- package/dist/modules/site-architecture/extract-internal-links.js +88 -0
- package/dist/modules/site-architecture/extract-internal-links.js.map +1 -0
- package/dist/modules/site-architecture/extract-multilingual-page.d.ts +2 -0
- package/dist/modules/site-architecture/extract-multilingual-page.js +29 -0
- package/dist/modules/site-architecture/extract-multilingual-page.js.map +1 -0
- package/dist/modules/site-architecture/internal-link-graph-probe.d.ts +7 -0
- package/dist/modules/site-architecture/internal-link-graph-probe.js +116 -0
- package/dist/modules/site-architecture/internal-link-graph-probe.js.map +1 -0
- package/dist/modules/site-architecture/internal-link-graph.d.ts +113 -0
- package/dist/modules/site-architecture/internal-link-graph.js +414 -0
- package/dist/modules/site-architecture/internal-link-graph.js.map +1 -0
- package/dist/modules/site-architecture/internal-link-quality.d.ts +77 -0
- package/dist/modules/site-architecture/internal-link-quality.js +260 -0
- package/dist/modules/site-architecture/internal-link-quality.js.map +1 -0
- package/dist/modules/site-architecture/multilingual-clusters.d.ts +82 -0
- package/dist/modules/site-architecture/multilingual-clusters.js +363 -0
- package/dist/modules/site-architecture/multilingual-clusters.js.map +1 -0
- package/dist/network.d.ts +4 -0
- package/dist/network.js +18 -2
- package/dist/network.js.map +1 -1
- package/dist/presentation.d.ts +53 -0
- package/dist/presentation.js +526 -0
- package/dist/presentation.js.map +1 -1
- package/dist/screenshot.d.ts +2 -1
- package/dist/screenshot.js +4 -2
- package/dist/screenshot.js.map +1 -1
- package/dist/seo-auditor.js +16 -6
- package/dist/seo-auditor.js.map +1 -1
- package/package.json +7 -4
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import * as cheerio from "cheerio";
|
|
2
|
+
/**
|
|
3
|
+
* P1-10: local-only, static HTML media evidence.
|
|
4
|
+
* Do not fetch sources, execute scripts, infer decoded assets or claim WCAG compliance.
|
|
5
|
+
*/
|
|
6
|
+
export const MAX_MEDIA_HTML_BYTES = 180_000;
|
|
7
|
+
export const MAX_MEDIA_ELEMENTS = 160;
|
|
8
|
+
export const MAX_MEDIA_FINDINGS = 12;
|
|
9
|
+
export function emptyMediaDiagnostics() {
|
|
10
|
+
return {
|
|
11
|
+
scope: "caller_supplied_static_media_markup_only",
|
|
12
|
+
images_observed: 0, pictures_observed: 0, videos_observed: 0,
|
|
13
|
+
source_elements_observed: 0, track_elements_observed: 0,
|
|
14
|
+
media_elements_checked: 0, media_elements_truncated: false,
|
|
15
|
+
images_without_explicit_alt: 0, images_with_empty_alt: 0,
|
|
16
|
+
images_without_intrinsic_dimensions: 0, lazy_images_without_intrinsic_dimensions: 0,
|
|
17
|
+
image_sources_unobserved: 0, videos_without_observed_source: 0,
|
|
18
|
+
videos_without_caption_track: 0, picture_fallbacks_unobserved: 0,
|
|
19
|
+
coverage_limited: true,
|
|
20
|
+
limitations: ["The supplied static HTML could not be reviewed within the declared media limits."],
|
|
21
|
+
total_findings: 0, findings: [], findings_truncated: false,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function hasValue(value) {
|
|
25
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
26
|
+
}
|
|
27
|
+
function validDimension(value) {
|
|
28
|
+
return typeof value === "string" && /^[1-9][0-9]*$/u.test(value.trim());
|
|
29
|
+
}
|
|
30
|
+
export function reviewMediaHtml(htmlContent) {
|
|
31
|
+
if (!htmlContent || new TextEncoder().encode(htmlContent).byteLength > MAX_MEDIA_HTML_BYTES) {
|
|
32
|
+
throw new Error("Media HTML must be nonempty and at most 180,000 UTF-8 bytes.");
|
|
33
|
+
}
|
|
34
|
+
const $ = cheerio.load(htmlContent);
|
|
35
|
+
// Template and noscript bodies are inert source fragments in this static
|
|
36
|
+
// view. Do not infer that their media are rendered, even without a browser.
|
|
37
|
+
$("template, noscript").remove();
|
|
38
|
+
const hidden = (element) => $(element).closest('[hidden], [aria-hidden="true"]').length > 0 ||
|
|
39
|
+
$(element).parentsUntil("html").addBack().toArray().some((parent) => /(?:^|;)\s*(?:display\s*:\s*none|visibility\s*:\s*hidden)\s*(?:;|$)/iu
|
|
40
|
+
.test($(parent).attr("style") ?? ""));
|
|
41
|
+
const media = $("img, picture, video").toArray().filter((element) => !hidden(element));
|
|
42
|
+
const images = media.filter((element) => $(element).is("img"));
|
|
43
|
+
const pictures = media.filter((element) => $(element).is("picture"));
|
|
44
|
+
const videos = media.filter((element) => $(element).is("video"));
|
|
45
|
+
const sources = $("picture > source, video > source").toArray().filter((element) => !hidden(element));
|
|
46
|
+
const tracks = $("video > track").toArray().filter((element) => !hidden(element));
|
|
47
|
+
const selected = media.slice(0, MAX_MEDIA_ELEMENTS);
|
|
48
|
+
// Resolve ARIA label ID references once. This is only a static label hint,
|
|
49
|
+
// not an implementation of the browser accessibility-name algorithm.
|
|
50
|
+
const labelled = new Map();
|
|
51
|
+
$("[id]").each((_, element) => {
|
|
52
|
+
const id = $(element).attr("id");
|
|
53
|
+
if (id && !labelled.has(id))
|
|
54
|
+
labelled.set(id, hasValue($(element).text()));
|
|
55
|
+
});
|
|
56
|
+
const namedBy = (element) => {
|
|
57
|
+
if (hasValue(element.attr("aria-label")) || hasValue(element.attr("title")))
|
|
58
|
+
return true;
|
|
59
|
+
const references = (element.attr("aria-labelledby") ?? "").trim().split(/\s+/u);
|
|
60
|
+
return references.some((id) => labelled.get(id) === true);
|
|
61
|
+
};
|
|
62
|
+
const findings = [];
|
|
63
|
+
let imagesWithoutAlt = 0, emptyAlt = 0, noDimensions = 0, lazyNoDimensions = 0;
|
|
64
|
+
let imageSourcesUnobserved = 0, videosWithoutSource = 0, videosWithoutCaptions = 0, picturesWithoutImg = 0;
|
|
65
|
+
function add(code, severity, mediaType, element, message) {
|
|
66
|
+
findings.push({ code, severity, media_type: mediaType, element, message });
|
|
67
|
+
}
|
|
68
|
+
selected.forEach((element, i) => {
|
|
69
|
+
const number = i + 1;
|
|
70
|
+
const node = $(element);
|
|
71
|
+
if (node.is("img")) {
|
|
72
|
+
const alt = node.attr("alt");
|
|
73
|
+
const role = (node.attr("role") ?? "").trim().toLowerCase().split(/\s+/u)[0];
|
|
74
|
+
const explicitlyDecorative = role === "presentation" || role === "none";
|
|
75
|
+
const explicitlySemantic = role === "img" || role === "image";
|
|
76
|
+
const sourcePresent = hasValue(node.attr("src")) || hasValue(node.attr("srcset"));
|
|
77
|
+
if (!sourcePresent) {
|
|
78
|
+
imageSourcesUnobserved++;
|
|
79
|
+
add("image_source_unobserved", "warning", "image", number, "No nonempty src or srcset attribute was observed. Client-side source assignment remains unverified.");
|
|
80
|
+
}
|
|
81
|
+
if (alt === undefined) {
|
|
82
|
+
imagesWithoutAlt++;
|
|
83
|
+
if (!explicitlyDecorative && !namedBy(node)) {
|
|
84
|
+
add("image_name_unobserved", "warning", "image", number, "No explicit alt or supported static name fallback was observed; review the intended image purpose.");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else if (alt === "") {
|
|
88
|
+
emptyAlt++;
|
|
89
|
+
if (explicitlySemantic && !namedBy(node)) {
|
|
90
|
+
add("image_name_unobserved", "warning", "image", number, "An image explicitly given semantic image role has empty alt and no static name fallback.");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
else if (alt.trim() === "") {
|
|
94
|
+
add("image_whitespace_alt", "warning", "image", number, "Whitespace-only alt is neither an explicitly empty decorative alternative nor a meaningful text alternative.");
|
|
95
|
+
}
|
|
96
|
+
const link = node.closest("a[href]");
|
|
97
|
+
if (link.length > 0 && !namedBy(link) && !hasValue(link.text()) &&
|
|
98
|
+
!link.find("img").toArray().some((image) => hasValue($(image).attr("alt")) || namedBy($(image)))) {
|
|
99
|
+
add("linked_image_name_unobserved", "warning", "image", number, "The image appears in a link without a static accessible name; review whether the link has usable label text.");
|
|
100
|
+
}
|
|
101
|
+
const dimensions = validDimension(node.attr("width")) && validDimension(node.attr("height"));
|
|
102
|
+
if (!dimensions)
|
|
103
|
+
noDimensions++;
|
|
104
|
+
const loading = node.attr("loading")?.trim().toLowerCase();
|
|
105
|
+
if (loading !== undefined && !["eager", "lazy"].includes(loading)) {
|
|
106
|
+
add("image_invalid_loading", "info", "image", number, "The loading attribute has an unrecognized static value; browser behavior is not verified.");
|
|
107
|
+
}
|
|
108
|
+
if (loading === "lazy" && !dimensions) {
|
|
109
|
+
lazyNoDimensions++;
|
|
110
|
+
add("image_lazy_dimensions_unobserved", "info", "image", number, "A lazy-loaded image has no positive intrinsic width and height attributes. CSS sizing may still reserve space.");
|
|
111
|
+
}
|
|
112
|
+
const decoding = node.attr("decoding")?.trim().toLowerCase();
|
|
113
|
+
if (decoding !== undefined && !["sync", "async", "auto"].includes(decoding)) {
|
|
114
|
+
add("image_invalid_decoding", "info", "image", number, "The decoding attribute has an unrecognized static value; rendering behavior is not verified.");
|
|
115
|
+
}
|
|
116
|
+
const fetchpriority = node.attr("fetchpriority")?.trim().toLowerCase();
|
|
117
|
+
if (fetchpriority !== undefined && !["high", "low", "auto"].includes(fetchpriority)) {
|
|
118
|
+
add("image_invalid_fetchpriority", "info", "image", number, "The fetchpriority attribute has an unrecognized static value; request priority is not measured.");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else if (node.is("picture")) {
|
|
122
|
+
if (node.children("img").length === 0) {
|
|
123
|
+
picturesWithoutImg++;
|
|
124
|
+
add("picture_fallback_unobserved", "warning", "picture", number, "No direct img fallback was observed in this picture element.");
|
|
125
|
+
}
|
|
126
|
+
if (node.children("source").toArray().some((source) => !hasValue($(source).attr("srcset")))) {
|
|
127
|
+
add("picture_source_srcset_unobserved", "info", "picture", number, "A picture source lacks a nonempty srcset; responsive candidate selection is unverified.");
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
else if (node.is("video")) {
|
|
131
|
+
const sourcePresent = hasValue(node.attr("src")) ||
|
|
132
|
+
node.children("source").toArray().some((source) => hasValue($(source).attr("src")));
|
|
133
|
+
if (!sourcePresent) {
|
|
134
|
+
videosWithoutSource++;
|
|
135
|
+
add("video_source_unobserved", "info", "video", number, "No video src or direct source src was observed. Dynamically assigned media remains unverified.");
|
|
136
|
+
}
|
|
137
|
+
const captionTracks = node.children("track").filter((_, track) => {
|
|
138
|
+
const kind = ($(track).attr("kind") ?? "subtitles").trim().toLowerCase();
|
|
139
|
+
return kind === "captions" || kind === "subtitles";
|
|
140
|
+
});
|
|
141
|
+
if (captionTracks.length === 0) {
|
|
142
|
+
videosWithoutCaptions++;
|
|
143
|
+
add("video_caption_track_unobserved", "info", "video", number, "No captions/subtitles track was observed; verify whether alternatives are needed for the media's purpose.");
|
|
144
|
+
}
|
|
145
|
+
else if (captionTracks.toArray().some((track) => !hasValue($(track).attr("src")))) {
|
|
146
|
+
add("video_caption_source_unobserved", "warning", "video", number, "A captions/subtitles track lacks a nonempty src; playback and text alternatives remain unverified.");
|
|
147
|
+
}
|
|
148
|
+
if (node.attr("autoplay") !== undefined && node.attr("muted") === undefined) {
|
|
149
|
+
add("video_autoplay_without_muted", "info", "video", number, "Autoplay is declared without muted; browser autoplay policy may prevent playback.");
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
findings.sort((a, b) => (a.severity === b.severity ? 0 : a.severity === "warning" ? -1 : 1) ||
|
|
154
|
+
a.element - b.element || a.code.localeCompare(b.code));
|
|
155
|
+
return {
|
|
156
|
+
scope: "caller_supplied_static_media_markup_only",
|
|
157
|
+
images_observed: images.length,
|
|
158
|
+
pictures_observed: pictures.length,
|
|
159
|
+
videos_observed: videos.length,
|
|
160
|
+
source_elements_observed: sources.length,
|
|
161
|
+
track_elements_observed: tracks.length,
|
|
162
|
+
media_elements_checked: selected.length,
|
|
163
|
+
media_elements_truncated: media.length > selected.length,
|
|
164
|
+
images_without_explicit_alt: imagesWithoutAlt,
|
|
165
|
+
images_with_empty_alt: emptyAlt,
|
|
166
|
+
images_without_intrinsic_dimensions: noDimensions,
|
|
167
|
+
lazy_images_without_intrinsic_dimensions: lazyNoDimensions,
|
|
168
|
+
image_sources_unobserved: imageSourcesUnobserved,
|
|
169
|
+
videos_without_observed_source: videosWithoutSource,
|
|
170
|
+
videos_without_caption_track: videosWithoutCaptions,
|
|
171
|
+
picture_fallbacks_unobserved: picturesWithoutImg,
|
|
172
|
+
coverage_limited: true,
|
|
173
|
+
limitations: [
|
|
174
|
+
"Only caller-supplied static HTML media declarations were inspected. No network fetch, browser rendering, JavaScript, CSS, layout, decoded assets, video playback, or caption contents were verified.",
|
|
175
|
+
"Missing intrinsic image dimensions may be handled in CSS; empty alt may be intentional. Counts of possible problems cover only checked elements, not unseen or capped elements.",
|
|
176
|
+
...(media.length > selected.length ? ["The media sample reached its per-request element cap; unexamined elements remain unverified."] : []),
|
|
177
|
+
],
|
|
178
|
+
total_findings: findings.length,
|
|
179
|
+
findings: findings.slice(0, MAX_MEDIA_FINDINGS),
|
|
180
|
+
findings_truncated: findings.length > MAX_MEDIA_FINDINGS,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=media-diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-diagnostics.js","sourceRoot":"","sources":["../../../src/modules/browser-ux/media-diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAEnC;;;GAGG;AACH,MAAM,CAAC,MAA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CAAC,CAAC,CAAC,8FAA8F,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5I;QACD,cAAc,EAAE,QAAQ,CAAC,MAAM;QAC/B,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,kBAAkB,CAAC;QAC/C,kBAAkB,EAAE,QAAQ,CAAC,MAAM,GAAG,kBAAkB;KACzD,CAAC;AACJ,CAAC","sourcesContent":["import * as cheerio from \"cheerio\";\n\n/**\n * P1-10: local-only, static HTML media evidence.\n * Do not fetch sources, execute scripts, infer decoded assets or claim WCAG compliance.\n */\nexport const MAX_MEDIA_HTML_BYTES = 180_000;\nexport const MAX_MEDIA_ELEMENTS = 160;\nexport const MAX_MEDIA_FINDINGS = 12;\n\nexport type MediaFindingCode =\n | \"image_name_unobserved\"\n | \"image_whitespace_alt\"\n | \"linked_image_name_unobserved\"\n | \"image_source_unobserved\"\n | \"image_lazy_dimensions_unobserved\"\n | \"image_invalid_loading\"\n | \"image_invalid_decoding\"\n | \"image_invalid_fetchpriority\"\n | \"picture_fallback_unobserved\"\n | \"picture_source_srcset_unobserved\"\n | \"video_source_unobserved\"\n | \"video_caption_track_unobserved\"\n | \"video_caption_source_unobserved\"\n | \"video_autoplay_without_muted\";\n\nexport interface MediaFinding {\n code: MediaFindingCode;\n severity: \"warning\" | \"info\";\n media_type: \"image\" | \"picture\" | \"video\";\n element: number;\n message: string;\n}\n\nexport interface MediaDiagnostics {\n scope: \"caller_supplied_static_media_markup_only\";\n images_observed: number;\n pictures_observed: number;\n videos_observed: number;\n source_elements_observed: number;\n track_elements_observed: number;\n media_elements_checked: number;\n media_elements_truncated: boolean;\n images_without_explicit_alt: number;\n images_with_empty_alt: number;\n images_without_intrinsic_dimensions: number;\n lazy_images_without_intrinsic_dimensions: number;\n image_sources_unobserved: number;\n videos_without_observed_source: number;\n videos_without_caption_track: number;\n picture_fallbacks_unobserved: number;\n coverage_limited: true;\n limitations: string[];\n total_findings: number;\n findings: MediaFinding[];\n findings_truncated: boolean;\n error?: string;\n}\n\nexport function emptyMediaDiagnostics(): MediaDiagnostics {\n return {\n scope: \"caller_supplied_static_media_markup_only\",\n images_observed: 0, pictures_observed: 0, videos_observed: 0,\n source_elements_observed: 0, track_elements_observed: 0,\n media_elements_checked: 0, media_elements_truncated: false,\n images_without_explicit_alt: 0, images_with_empty_alt: 0,\n images_without_intrinsic_dimensions: 0, lazy_images_without_intrinsic_dimensions: 0,\n image_sources_unobserved: 0, videos_without_observed_source: 0,\n videos_without_caption_track: 0, picture_fallbacks_unobserved: 0,\n coverage_limited: true,\n limitations: [\"The supplied static HTML could not be reviewed within the declared media limits.\"],\n total_findings: 0, findings: [], findings_truncated: false,\n };\n}\n\nfunction hasValue(value: string | undefined): boolean {\n return typeof value === \"string\" && value.trim().length > 0;\n}\n\nfunction validDimension(value: string | undefined): boolean {\n return typeof value === \"string\" && /^[1-9][0-9]*$/u.test(value.trim());\n}\n\nexport function reviewMediaHtml(htmlContent: string): MediaDiagnostics {\n if (!htmlContent || new TextEncoder().encode(htmlContent).byteLength > MAX_MEDIA_HTML_BYTES) {\n throw new Error(\"Media HTML must be nonempty and at most 180,000 UTF-8 bytes.\");\n }\n const $ = cheerio.load(htmlContent);\n // Template and noscript bodies are inert source fragments in this static\n // view. Do not infer that their media are rendered, even without a browser.\n $(\"template, noscript\").remove();\n const hidden = (element: Parameters<typeof $>[0]): boolean =>\n $(element).closest('[hidden], [aria-hidden=\"true\"]').length > 0 ||\n $(element).parentsUntil(\"html\").addBack().toArray().some((parent) =>\n /(?:^|;)\\s*(?:display\\s*:\\s*none|visibility\\s*:\\s*hidden)\\s*(?:;|$)/iu\n .test($(parent).attr(\"style\") ?? \"\"));\n\n const media = $(\"img, picture, video\").toArray().filter((element) => !hidden(element));\n const images = media.filter((element) => $(element).is(\"img\"));\n const pictures = media.filter((element) => $(element).is(\"picture\"));\n const videos = media.filter((element) => $(element).is(\"video\"));\n const sources = $(\"picture > source, video > source\").toArray().filter((element) => !hidden(element));\n const tracks = $(\"video > track\").toArray().filter((element) => !hidden(element));\n const selected = media.slice(0, MAX_MEDIA_ELEMENTS);\n\n // Resolve ARIA label ID references once. This is only a static label hint,\n // not an implementation of the browser accessibility-name algorithm.\n const labelled = new Map<string, boolean>();\n $(\"[id]\").each((_, element) => {\n const id = $(element).attr(\"id\");\n if (id && !labelled.has(id)) labelled.set(id, hasValue($(element).text()));\n });\n const namedBy = (element: ReturnType<typeof $>): boolean => {\n if (hasValue(element.attr(\"aria-label\")) || hasValue(element.attr(\"title\"))) return true;\n const references = (element.attr(\"aria-labelledby\") ?? \"\").trim().split(/\\s+/u);\n return references.some((id) => labelled.get(id) === true);\n };\n const findings: MediaFinding[] = [];\n let imagesWithoutAlt = 0, emptyAlt = 0, noDimensions = 0, lazyNoDimensions = 0;\n let imageSourcesUnobserved = 0, videosWithoutSource = 0, videosWithoutCaptions = 0, picturesWithoutImg = 0;\n\n function add(code: MediaFindingCode, severity: MediaFinding[\"severity\"],\n mediaType: MediaFinding[\"media_type\"], element: number, message: string) {\n findings.push({ code, severity, media_type: mediaType, element, message });\n }\n\n selected.forEach((element, i) => {\n const number = i + 1;\n const node = $(element);\n if (node.is(\"img\")) {\n const alt = node.attr(\"alt\");\n const role = (node.attr(\"role\") ?? \"\").trim().toLowerCase().split(/\\s+/u)[0];\n const explicitlyDecorative = role === \"presentation\" || role === \"none\";\n const explicitlySemantic = role === \"img\" || role === \"image\";\n const sourcePresent = hasValue(node.attr(\"src\")) || hasValue(node.attr(\"srcset\"));\n if (!sourcePresent) {\n imageSourcesUnobserved++;\n add(\"image_source_unobserved\", \"warning\", \"image\", number,\n \"No nonempty src or srcset attribute was observed. Client-side source assignment remains unverified.\");\n }\n if (alt === undefined) {\n imagesWithoutAlt++;\n if (!explicitlyDecorative && !namedBy(node)) {\n add(\"image_name_unobserved\", \"warning\", \"image\", number,\n \"No explicit alt or supported static name fallback was observed; review the intended image purpose.\");\n }\n } else if (alt === \"\") {\n emptyAlt++;\n if (explicitlySemantic && !namedBy(node)) {\n add(\"image_name_unobserved\", \"warning\", \"image\", number,\n \"An image explicitly given semantic image role has empty alt and no static name fallback.\");\n }\n } else if (alt.trim() === \"\") {\n add(\"image_whitespace_alt\", \"warning\", \"image\", number,\n \"Whitespace-only alt is neither an explicitly empty decorative alternative nor a meaningful text alternative.\");\n }\n const link = node.closest(\"a[href]\");\n if (link.length > 0 && !namedBy(link) && !hasValue(link.text()) &&\n !link.find(\"img\").toArray().some((image) =>\n hasValue($(image).attr(\"alt\")) || namedBy($(image)))) {\n add(\"linked_image_name_unobserved\", \"warning\", \"image\", number,\n \"The image appears in a link without a static accessible name; review whether the link has usable label text.\");\n }\n const dimensions = validDimension(node.attr(\"width\")) && validDimension(node.attr(\"height\"));\n if (!dimensions) noDimensions++;\n const loading = node.attr(\"loading\")?.trim().toLowerCase();\n if (loading !== undefined && ![\"eager\", \"lazy\"].includes(loading)) {\n add(\"image_invalid_loading\", \"info\", \"image\", number,\n \"The loading attribute has an unrecognized static value; browser behavior is not verified.\");\n }\n if (loading === \"lazy\" && !dimensions) {\n lazyNoDimensions++;\n add(\"image_lazy_dimensions_unobserved\", \"info\", \"image\", number,\n \"A lazy-loaded image has no positive intrinsic width and height attributes. CSS sizing may still reserve space.\");\n }\n const decoding = node.attr(\"decoding\")?.trim().toLowerCase();\n if (decoding !== undefined && ![\"sync\", \"async\", \"auto\"].includes(decoding)) {\n add(\"image_invalid_decoding\", \"info\", \"image\", number,\n \"The decoding attribute has an unrecognized static value; rendering behavior is not verified.\");\n }\n const fetchpriority = node.attr(\"fetchpriority\")?.trim().toLowerCase();\n if (fetchpriority !== undefined && ![\"high\", \"low\", \"auto\"].includes(fetchpriority)) {\n add(\"image_invalid_fetchpriority\", \"info\", \"image\", number,\n \"The fetchpriority attribute has an unrecognized static value; request priority is not measured.\");\n }\n } else if (node.is(\"picture\")) {\n if (node.children(\"img\").length === 0) {\n picturesWithoutImg++;\n add(\"picture_fallback_unobserved\", \"warning\", \"picture\", number,\n \"No direct img fallback was observed in this picture element.\");\n }\n if (node.children(\"source\").toArray().some((source) => !hasValue($(source).attr(\"srcset\")))) {\n add(\"picture_source_srcset_unobserved\", \"info\", \"picture\", number,\n \"A picture source lacks a nonempty srcset; responsive candidate selection is unverified.\");\n }\n } else if (node.is(\"video\")) {\n const sourcePresent = hasValue(node.attr(\"src\")) ||\n node.children(\"source\").toArray().some((source) => hasValue($(source).attr(\"src\")));\n if (!sourcePresent) {\n videosWithoutSource++;\n add(\"video_source_unobserved\", \"info\", \"video\", number,\n \"No video src or direct source src was observed. Dynamically assigned media remains unverified.\");\n }\n const captionTracks = node.children(\"track\").filter((_, track) => {\n const kind = ($(track).attr(\"kind\") ?? \"subtitles\").trim().toLowerCase();\n return kind === \"captions\" || kind === \"subtitles\";\n });\n if (captionTracks.length === 0) {\n videosWithoutCaptions++;\n add(\"video_caption_track_unobserved\", \"info\", \"video\", number,\n \"No captions/subtitles track was observed; verify whether alternatives are needed for the media's purpose.\");\n } else if (captionTracks.toArray().some((track) => !hasValue($(track).attr(\"src\")))) {\n add(\"video_caption_source_unobserved\", \"warning\", \"video\", number,\n \"A captions/subtitles track lacks a nonempty src; playback and text alternatives remain unverified.\");\n }\n if (node.attr(\"autoplay\") !== undefined && node.attr(\"muted\") === undefined) {\n add(\"video_autoplay_without_muted\", \"info\", \"video\", number,\n \"Autoplay is declared without muted; browser autoplay policy may prevent playback.\");\n }\n }\n });\n\n findings.sort((a, b) => (a.severity === b.severity ? 0 : a.severity === \"warning\" ? -1 : 1) ||\n a.element - b.element || a.code.localeCompare(b.code));\n return {\n scope: \"caller_supplied_static_media_markup_only\",\n images_observed: images.length,\n pictures_observed: pictures.length,\n videos_observed: videos.length,\n source_elements_observed: sources.length,\n track_elements_observed: tracks.length,\n media_elements_checked: selected.length,\n media_elements_truncated: media.length > selected.length,\n images_without_explicit_alt: imagesWithoutAlt,\n images_with_empty_alt: emptyAlt,\n images_without_intrinsic_dimensions: noDimensions,\n lazy_images_without_intrinsic_dimensions: lazyNoDimensions,\n image_sources_unobserved: imageSourcesUnobserved,\n videos_without_observed_source: videosWithoutSource,\n videos_without_caption_track: videosWithoutCaptions,\n picture_fallbacks_unobserved: picturesWithoutImg,\n coverage_limited: true,\n limitations: [\n \"Only caller-supplied static HTML media declarations were inspected. No network fetch, browser rendering, JavaScript, CSS, layout, decoded assets, video playback, or caption contents were verified.\",\n \"Missing intrinsic image dimensions may be handled in CSS; empty alt may be intentional. Counts of possible problems cover only checked elements, not unseen or capped elements.\",\n ...(media.length > selected.length ? [\"The media sample reached its per-request element cap; unexamined elements remain unverified.\"] : []),\n ],\n total_findings: findings.length,\n findings: findings.slice(0, MAX_MEDIA_FINDINGS),\n findings_truncated: findings.length > MAX_MEDIA_FINDINGS,\n };\n}\n"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export declare const MAX_RENDER_HTML_BYTES = 524288;
|
|
2
|
+
export declare const MAX_RENDER_TOTAL_HTML_BYTES = 1048576;
|
|
3
|
+
export declare const MAX_RENDER_FINDINGS = 18;
|
|
4
|
+
export declare const MAX_RENDER_LINKS = 200;
|
|
5
|
+
export declare const MAX_RENDER_WORDS = 10000;
|
|
6
|
+
export declare const MAX_RENDER_BROWSER_MS = 15000;
|
|
7
|
+
export declare const RENDER_FINDING_CODES: readonly ["title_removed", "title_added", "title_changed", "description_removed", "description_added", "h1_removed", "h1_added", "main_text_dropped", "main_text_added", "main_text_changed", "links_removed", "links_added", "noindex_added", "noindex_removed", "canonical_changed", "jsonld_removed", "jsonld_added", "external_scripts_blocked", "resources_blocked", "script_errors_observed", "snapshot_coverage_limited"];
|
|
8
|
+
export type RenderFindingCode = typeof RENDER_FINDING_CODES[number];
|
|
9
|
+
export type RenderScope = "caller_supplied_rendered_snapshot" | "isolated_inline_script_chromium" | "isolated_public_html_inline_script_sample";
|
|
10
|
+
export interface RawRenderedInput {
|
|
11
|
+
page_url: string;
|
|
12
|
+
raw_html: string;
|
|
13
|
+
rendered_html: string;
|
|
14
|
+
}
|
|
15
|
+
export interface RenderEvidence {
|
|
16
|
+
scope?: RenderScope;
|
|
17
|
+
browser_executed?: boolean;
|
|
18
|
+
inline_scripts_attempted?: boolean;
|
|
19
|
+
external_resources_blocked?: number;
|
|
20
|
+
script_errors_observed?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface RenderSnapshot {
|
|
23
|
+
title_present: boolean;
|
|
24
|
+
title_characters: number;
|
|
25
|
+
description_present: boolean;
|
|
26
|
+
description_characters: number;
|
|
27
|
+
h1_count: number;
|
|
28
|
+
main_words: number;
|
|
29
|
+
same_origin_link_targets: number;
|
|
30
|
+
query_links_excluded: number;
|
|
31
|
+
external_link_targets: number;
|
|
32
|
+
canonicals: "missing" | "self" | "different" | "ambiguous";
|
|
33
|
+
noindex_declared: boolean;
|
|
34
|
+
jsonld_blocks: number;
|
|
35
|
+
external_script_tags: number;
|
|
36
|
+
inline_script_tags: number;
|
|
37
|
+
sample_truncated: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface RenderFinding {
|
|
40
|
+
code: RenderFindingCode;
|
|
41
|
+
severity: "warning" | "info";
|
|
42
|
+
message: string;
|
|
43
|
+
}
|
|
44
|
+
export interface RawRenderedReview {
|
|
45
|
+
scope: RenderScope;
|
|
46
|
+
browser_executed: boolean;
|
|
47
|
+
inline_scripts_attempted: boolean;
|
|
48
|
+
external_resources_blocked: number;
|
|
49
|
+
script_errors_observed: number;
|
|
50
|
+
raw: RenderSnapshot;
|
|
51
|
+
rendered: RenderSnapshot;
|
|
52
|
+
title_changed: boolean;
|
|
53
|
+
h1_changed: boolean;
|
|
54
|
+
canonical_changed: boolean;
|
|
55
|
+
noindex_changed: boolean;
|
|
56
|
+
shared_main_words: number;
|
|
57
|
+
main_words_removed: number;
|
|
58
|
+
main_words_added: number;
|
|
59
|
+
link_targets_removed: number;
|
|
60
|
+
link_targets_added: number;
|
|
61
|
+
unchanged_link_targets: number;
|
|
62
|
+
coverage_limited: true;
|
|
63
|
+
limitations: string[];
|
|
64
|
+
total_findings: number;
|
|
65
|
+
findings: RenderFinding[];
|
|
66
|
+
findings_truncated: boolean;
|
|
67
|
+
error?: string;
|
|
68
|
+
}
|
|
69
|
+
export declare function emptyRawRenderedReview(scope?: RenderScope): RawRenderedReview;
|
|
70
|
+
export declare function analyzeRawRendered(input: RawRenderedInput, evidence?: RenderEvidence): RawRenderedReview;
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V07: deterministic, redacted comparison of HTTP source HTML and a browser
|
|
3
|
+
* rendered DOM snapshot. This analyzer is pure; Chromium is a separate local
|
|
4
|
+
* probe. Rendering is NOT equivalent to Google WRS or its index decision.
|
|
5
|
+
*/
|
|
6
|
+
import { load } from "cheerio";
|
|
7
|
+
import { safeLinkPageUrl } from "../site-architecture/internal-link-quality.js";
|
|
8
|
+
export const MAX_RENDER_HTML_BYTES = 524_288;
|
|
9
|
+
export const MAX_RENDER_TOTAL_HTML_BYTES = 1_048_576;
|
|
10
|
+
export const MAX_RENDER_FINDINGS = 18;
|
|
11
|
+
export const MAX_RENDER_LINKS = 200;
|
|
12
|
+
export const MAX_RENDER_WORDS = 10_000;
|
|
13
|
+
export const MAX_RENDER_BROWSER_MS = 15_000;
|
|
14
|
+
export const RENDER_FINDING_CODES = [
|
|
15
|
+
"title_removed", "title_added", "title_changed",
|
|
16
|
+
"description_removed", "description_added",
|
|
17
|
+
"h1_removed", "h1_added",
|
|
18
|
+
"main_text_dropped", "main_text_added", "main_text_changed",
|
|
19
|
+
"links_removed", "links_added",
|
|
20
|
+
"noindex_added", "noindex_removed",
|
|
21
|
+
"canonical_changed", "jsonld_removed", "jsonld_added",
|
|
22
|
+
"external_scripts_blocked", "resources_blocked",
|
|
23
|
+
"script_errors_observed", "snapshot_coverage_limited",
|
|
24
|
+
];
|
|
25
|
+
const encoder = new TextEncoder();
|
|
26
|
+
const bytes = (value) => encoder.encode(value).byteLength;
|
|
27
|
+
function boundedUrl(value) {
|
|
28
|
+
if (typeof value !== "string" || bytes(value) > 512 ||
|
|
29
|
+
/[\u0000-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069\\]/u.test(value))
|
|
30
|
+
return undefined;
|
|
31
|
+
return safeLinkPageUrl(value);
|
|
32
|
+
}
|
|
33
|
+
const noindexPattern = /(?:^|[\s,;])(?:noindex|none)(?:$|[\s,;])/iu;
|
|
34
|
+
const hasRel = (raw, token) => (raw ?? "").toLowerCase().split(/\s+/u).includes(token);
|
|
35
|
+
const textWords = (raw) => (raw.normalize("NFKC").toLocaleLowerCase("en").match(/[\p{L}\p{N}]+/gu) ?? [])
|
|
36
|
+
.filter((word) => word.length >= 2 && word.length <= 60)
|
|
37
|
+
.slice(0, MAX_RENDER_WORDS);
|
|
38
|
+
function inspect(html, sourceUrl) {
|
|
39
|
+
const $ = load(html);
|
|
40
|
+
const head = $("head");
|
|
41
|
+
const title = head.find("title").first().text().replace(/\s+/gu, " ").trim().slice(0, 600);
|
|
42
|
+
const description = head.find('meta[name="description" i]').first()
|
|
43
|
+
.attr("content")?.replace(/\s+/gu, " ").trim().slice(0, 1200) ?? "";
|
|
44
|
+
const metaNoindex = head.find("meta[name][content]").toArray().some((el) => {
|
|
45
|
+
const name = ($(el).attr("name") ?? "").trim().toLowerCase();
|
|
46
|
+
return ["robots", "googlebot"].includes(name) &&
|
|
47
|
+
noindexPattern.test($(el).attr("content") ?? "");
|
|
48
|
+
});
|
|
49
|
+
const canonicals = head.find("link[rel][href]").toArray().filter((el) => hasRel($(el).attr("rel"), "canonical"));
|
|
50
|
+
const normalizedCanonicals = new Set();
|
|
51
|
+
let ambiguousCanonical = false;
|
|
52
|
+
for (const el of canonicals) {
|
|
53
|
+
const href = $(el).attr("href");
|
|
54
|
+
if (!href) {
|
|
55
|
+
ambiguousCanonical = true;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const url = new URL(href, sourceUrl);
|
|
60
|
+
url.hash = "";
|
|
61
|
+
const safe = boundedUrl(url.href);
|
|
62
|
+
if (safe)
|
|
63
|
+
normalizedCanonicals.add(safe);
|
|
64
|
+
else
|
|
65
|
+
ambiguousCanonical = true;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
ambiguousCanonical = true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const canonicalState = canonicals.length === 0 ? "missing" :
|
|
72
|
+
ambiguousCanonical || normalizedCanonicals.size !== 1 ? "ambiguous" :
|
|
73
|
+
normalizedCanonicals.has(sourceUrl) ? "self" : "different";
|
|
74
|
+
// Evaluate only text visible in the source HTML structure, not CSS computed
|
|
75
|
+
// visibility or Google-selected content. Dynamic styles are out of scope.
|
|
76
|
+
const main = $("main,[role='main'],article").first();
|
|
77
|
+
const root = main.length ? main.clone() : $("body").first().clone();
|
|
78
|
+
root.find("script,style,noscript,template,svg,nav,header,footer,aside").remove();
|
|
79
|
+
const words = textWords(root.text());
|
|
80
|
+
const links = new Set();
|
|
81
|
+
const external = new Set();
|
|
82
|
+
let queryLinks = 0;
|
|
83
|
+
let truncated = false;
|
|
84
|
+
const baseHref = head.find("base[href]").first().attr("href");
|
|
85
|
+
let base = sourceUrl;
|
|
86
|
+
let unsafeBase = false;
|
|
87
|
+
if (baseHref !== undefined) {
|
|
88
|
+
try {
|
|
89
|
+
const candidate = new URL(baseHref, sourceUrl);
|
|
90
|
+
const safe = boundedUrl(candidate.href);
|
|
91
|
+
if (safe && candidate.origin === new URL(sourceUrl).origin)
|
|
92
|
+
base = safe;
|
|
93
|
+
else
|
|
94
|
+
unsafeBase = true;
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
unsafeBase = true;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const anchors = $("body a[href]").toArray();
|
|
101
|
+
if (anchors.length > MAX_RENDER_LINKS)
|
|
102
|
+
truncated = true;
|
|
103
|
+
for (const el of anchors.slice(0, MAX_RENDER_LINKS)) {
|
|
104
|
+
const raw = ($(el).attr("href") ?? "").trim();
|
|
105
|
+
if (!raw || raw.length > 1024 || raw.startsWith("#"))
|
|
106
|
+
continue;
|
|
107
|
+
if (unsafeBase && !/^[a-z][a-z0-9+.-]*:/iu.test(raw) && !raw.startsWith("//")) {
|
|
108
|
+
truncated = true;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
const url = new URL(raw, base);
|
|
113
|
+
if (!["https:", "http:"].includes(url.protocol) ||
|
|
114
|
+
url.username || url.password || url.port)
|
|
115
|
+
continue;
|
|
116
|
+
if (url.origin !== new URL(sourceUrl).origin) {
|
|
117
|
+
external.add(url.origin);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (url.search || raw.includes("?")) {
|
|
121
|
+
queryLinks++;
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
url.hash = "";
|
|
125
|
+
const safe = boundedUrl(url.href);
|
|
126
|
+
if (safe)
|
|
127
|
+
links.add(safe);
|
|
128
|
+
}
|
|
129
|
+
catch { /* No graph edge for unsafe or invalid URLs. */ }
|
|
130
|
+
}
|
|
131
|
+
const scripts = $("script").toArray();
|
|
132
|
+
const snapshot = {
|
|
133
|
+
title_present: Boolean(title), title_characters: title.length,
|
|
134
|
+
description_present: Boolean(description), description_characters: description.length,
|
|
135
|
+
h1_count: $("body h1").length, main_words: words.length,
|
|
136
|
+
same_origin_link_targets: links.size, query_links_excluded: queryLinks,
|
|
137
|
+
external_link_targets: external.size,
|
|
138
|
+
canonicals: canonicalState, noindex_declared: metaNoindex,
|
|
139
|
+
jsonld_blocks: scripts.filter((el) => ($(el).attr("type") ?? "").trim().toLowerCase() === "application/ld+json").length,
|
|
140
|
+
external_script_tags: scripts.filter((el) => Boolean($(el).attr("src"))).length,
|
|
141
|
+
inline_script_tags: scripts.filter((el) => !$(el).attr("src") && !["application/ld+json", "application/json"].includes(($(el).attr("type") ?? "").trim().toLowerCase())).length,
|
|
142
|
+
sample_truncated: truncated || root.text().length > 100_000,
|
|
143
|
+
};
|
|
144
|
+
return { snapshot, title, firstH1: $("body h1").first().text().trim().slice(0, 600),
|
|
145
|
+
canonicalState, canonicalSet: normalizedCanonicals,
|
|
146
|
+
links, words: new Set(words) };
|
|
147
|
+
}
|
|
148
|
+
const limitations = [
|
|
149
|
+
"This tool compares supplied source and rendered HTML snapshots; it does not verify Googlebot, Google Web Rendering Service, indexing, search results or historical production behavior.",
|
|
150
|
+
"Browser inline-script mode executes only local inline JavaScript in fresh, network-denied Chromium; external modules, frameworks, APIs, fonts, images and stylesheets do not load.",
|
|
151
|
+
"Static DOM comparisons do not prove visual visibility, interactivity, hydration success, accessibility, semantic equivalence or actual loaded resource availability.",
|
|
152
|
+
"All URL paths, titles, headings, text and script/console contents are omitted from output. Links with queries are excluded; only capped same-origin path-only links are compared.",
|
|
153
|
+
];
|
|
154
|
+
export function emptyRawRenderedReview(scope = "caller_supplied_rendered_snapshot") {
|
|
155
|
+
const blank = {
|
|
156
|
+
title_present: false, title_characters: 0,
|
|
157
|
+
description_present: false, description_characters: 0,
|
|
158
|
+
h1_count: 0, main_words: 0, same_origin_link_targets: 0,
|
|
159
|
+
query_links_excluded: 0, external_link_targets: 0,
|
|
160
|
+
canonicals: "missing", noindex_declared: false,
|
|
161
|
+
jsonld_blocks: 0, external_script_tags: 0,
|
|
162
|
+
inline_script_tags: 0, sample_truncated: false,
|
|
163
|
+
};
|
|
164
|
+
return {
|
|
165
|
+
scope, browser_executed: false, inline_scripts_attempted: false,
|
|
166
|
+
external_resources_blocked: 0, script_errors_observed: 0,
|
|
167
|
+
raw: { ...blank }, rendered: { ...blank },
|
|
168
|
+
title_changed: false, h1_changed: false, canonical_changed: false,
|
|
169
|
+
noindex_changed: false, shared_main_words: 0,
|
|
170
|
+
main_words_removed: 0, main_words_added: 0,
|
|
171
|
+
link_targets_removed: 0, link_targets_added: 0,
|
|
172
|
+
unchanged_link_targets: 0, coverage_limited: true,
|
|
173
|
+
limitations, total_findings: 0, findings: [], findings_truncated: false,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
export function analyzeRawRendered(input, evidence = {}) {
|
|
177
|
+
const url = boundedUrl(input?.page_url);
|
|
178
|
+
if (!url || typeof input.raw_html !== "string" || !input.raw_html.trim() ||
|
|
179
|
+
typeof input.rendered_html !== "string" || !input.rendered_html.trim() ||
|
|
180
|
+
bytes(input.raw_html) > MAX_RENDER_HTML_BYTES ||
|
|
181
|
+
bytes(input.rendered_html) > MAX_RENDER_HTML_BYTES ||
|
|
182
|
+
bytes(input.raw_html) + bytes(input.rendered_html) > MAX_RENDER_TOTAL_HTML_BYTES) {
|
|
183
|
+
throw new Error("Provide a safe page URL and two bounded HTML snapshots.");
|
|
184
|
+
}
|
|
185
|
+
const raw = inspect(input.raw_html, url);
|
|
186
|
+
const rendered = inspect(input.rendered_html, url);
|
|
187
|
+
const report = emptyRawRenderedReview(evidence.scope);
|
|
188
|
+
report.browser_executed = evidence.browser_executed === true;
|
|
189
|
+
report.inline_scripts_attempted = evidence.inline_scripts_attempted === true;
|
|
190
|
+
report.external_resources_blocked = Math.min(1000, Math.max(0, evidence.external_resources_blocked ?? 0));
|
|
191
|
+
report.script_errors_observed = Math.min(100, Math.max(0, evidence.script_errors_observed ?? 0));
|
|
192
|
+
report.raw = raw.snapshot;
|
|
193
|
+
report.rendered = rendered.snapshot;
|
|
194
|
+
report.title_changed = raw.title !== rendered.title;
|
|
195
|
+
report.h1_changed = raw.firstH1 !== rendered.firstH1;
|
|
196
|
+
report.canonical_changed = raw.canonicalState !== rendered.canonicalState ||
|
|
197
|
+
raw.canonicalSet.size !== rendered.canonicalSet.size ||
|
|
198
|
+
[...raw.canonicalSet].some((value) => !rendered.canonicalSet.has(value));
|
|
199
|
+
report.noindex_changed = raw.snapshot.noindex_declared !== rendered.snapshot.noindex_declared;
|
|
200
|
+
report.shared_main_words = [...raw.words].filter((word) => rendered.words.has(word)).length;
|
|
201
|
+
report.main_words_removed = [...raw.words].filter((word) => !rendered.words.has(word)).length;
|
|
202
|
+
report.main_words_added = [...rendered.words].filter((word) => !raw.words.has(word)).length;
|
|
203
|
+
report.link_targets_removed = [...raw.links].filter((target) => !rendered.links.has(target)).length;
|
|
204
|
+
report.link_targets_added = [...rendered.links].filter((target) => !raw.links.has(target)).length;
|
|
205
|
+
report.unchanged_link_targets = [...raw.links].filter((target) => rendered.links.has(target)).length;
|
|
206
|
+
const records = [];
|
|
207
|
+
const add = (code, severity, message) => records.push({ code, severity, message });
|
|
208
|
+
if (report.raw.title_present && !report.rendered.title_present)
|
|
209
|
+
add("title_removed", "warning", "An observed source title is absent from the rendered DOM.");
|
|
210
|
+
else if (!report.raw.title_present && report.rendered.title_present)
|
|
211
|
+
add("title_added", "info", "A title appears only after rendering; non-rendering crawlers may not see it.");
|
|
212
|
+
else if (report.title_changed)
|
|
213
|
+
add("title_changed", "info", "The rendered title differs from the HTTP source title.");
|
|
214
|
+
if (report.raw.description_present && !report.rendered.description_present)
|
|
215
|
+
add("description_removed", "warning", "A source meta description is absent from the rendered DOM.");
|
|
216
|
+
else if (!report.raw.description_present && report.rendered.description_present)
|
|
217
|
+
add("description_added", "info", "The rendered DOM adds a meta description not present in source HTML.");
|
|
218
|
+
if (report.raw.h1_count > 0 && report.rendered.h1_count === 0)
|
|
219
|
+
add("h1_removed", "warning", "A source H1 heading was absent after rendering.");
|
|
220
|
+
else if (report.raw.h1_count === 0 && report.rendered.h1_count > 0)
|
|
221
|
+
add("h1_added", "info", "The rendered DOM introduces an H1 absent in source HTML.");
|
|
222
|
+
if (report.raw.main_words >= 20 &&
|
|
223
|
+
report.rendered.main_words < Math.floor(report.raw.main_words * 0.65)) {
|
|
224
|
+
add("main_text_dropped", "warning", "Rendered main content has substantially fewer words than the supplied source.");
|
|
225
|
+
}
|
|
226
|
+
else if (report.rendered.main_words >= 20 &&
|
|
227
|
+
report.raw.main_words < Math.floor(report.rendered.main_words * 0.65)) {
|
|
228
|
+
add("main_text_added", "info", "Main textual content is predominantly rendered rather than available in source.");
|
|
229
|
+
}
|
|
230
|
+
else if (report.main_words_removed > 15 && report.raw.main_words >= 20) {
|
|
231
|
+
add("main_text_changed", "info", "Some distinct source text tokens were absent in the rendered sample.");
|
|
232
|
+
}
|
|
233
|
+
if (report.link_targets_removed)
|
|
234
|
+
add("links_removed", "warning", "One or more source same-origin links are absent in the rendered DOM.");
|
|
235
|
+
if (report.link_targets_added)
|
|
236
|
+
add("links_added", "info", "One or more same-origin links appear only in the rendered DOM.");
|
|
237
|
+
if (!report.raw.noindex_declared && report.rendered.noindex_declared)
|
|
238
|
+
add("noindex_added", "warning", "The rendered head declares noindex absent in source; verify indexing intentions.");
|
|
239
|
+
if (report.raw.noindex_declared && !report.rendered.noindex_declared)
|
|
240
|
+
add("noindex_removed", "warning", "The source noindex declaration is missing after rendering; verify effective directives.");
|
|
241
|
+
if (report.canonical_changed)
|
|
242
|
+
add("canonical_changed", "warning", "The observed canonical declaration changes during rendering.");
|
|
243
|
+
if (report.rendered.jsonld_blocks < report.raw.jsonld_blocks)
|
|
244
|
+
add("jsonld_removed", "info", "Some source JSON-LD blocks are no longer present in the rendered DOM.");
|
|
245
|
+
if (report.rendered.jsonld_blocks > report.raw.jsonld_blocks)
|
|
246
|
+
add("jsonld_added", "info", "Additional JSON-LD script blocks appear in the rendered DOM.");
|
|
247
|
+
if (report.browser_executed && report.raw.external_script_tags)
|
|
248
|
+
add("external_scripts_blocked", "info", "External scripts were not loaded in the isolated offline browser; hydration may be incomplete.");
|
|
249
|
+
if (report.browser_executed && report.external_resources_blocked)
|
|
250
|
+
add("resources_blocked", "info", "Chromium attempted one or more external resource requests, all blocked.");
|
|
251
|
+
if (report.browser_executed && report.script_errors_observed)
|
|
252
|
+
add("script_errors_observed", "info", "One or more JavaScript runtime errors occurred; error text was discarded.");
|
|
253
|
+
if (report.raw.sample_truncated || report.rendered.sample_truncated)
|
|
254
|
+
add("snapshot_coverage_limited", "info", "Link or text sampling reached a fixed cap; some DOM evidence was not compared.");
|
|
255
|
+
records.sort((a, b) => (a.severity === b.severity ? 0 : a.severity === "warning" ? -1 : 1)
|
|
256
|
+
|| a.code.localeCompare(b.code));
|
|
257
|
+
report.total_findings = records.length;
|
|
258
|
+
report.findings = records.slice(0, MAX_RENDER_FINDINGS);
|
|
259
|
+
report.findings_truncated = records.length > MAX_RENDER_FINDINGS;
|
|
260
|
+
return report;
|
|
261
|
+
}
|
|
262
|
+
//# sourceMappingURL=raw-rendered-diff.js.map
|