@decocms/parity 0.35.31 → 0.35.32
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 +12 -0
- package/dist/cli.js +415 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
|
+
* **`first-viewport-ssr` check (html module)** answers "is what the user sees in the first viewport
|
|
13
|
+
already in the server response, or does it arrive later?". A deferred header (a skeleton in the
|
|
14
|
+
server HTML that client JS fills in) passed `ssr-no-js` (the rest of the page carried the text)
|
|
15
|
+
and `lazy-section-presence` (the final DOM has the section on both sides). `capturePage` now
|
|
16
|
+
compares, per top-level section, the final DOM with the navigation response's raw HTML (text,
|
|
17
|
+
links, images, form fields; `<script>` payloads never count), matched by manifest key / landmark.
|
|
18
|
+
Cand defers a first-viewport section prod server-renders: `high`. Both sides defer it: `medium`
|
|
19
|
+
`first-viewport:improve:*`, worded as an improvement and left to the owner's `as-is` / `upgrade`
|
|
20
|
+
call; no cap, never critical. A localhost cand whose every judged section is deferred (the page
|
|
21
|
+
rendered client-side) is inconclusive. New optional `PageCapture.firstViewport`; older
|
|
22
|
+
recordings and `--golden` files parse unchanged and judge inconclusive. Tolerances in
|
|
23
|
+
`TOLERANCES.firstViewportSsr`.
|
|
12
24
|
* **`click-blocker-parity` check (visual module)** answers "can the user click the page on the
|
|
13
25
|
candidate where they can on prod?". `capturePage` now samples a 5x5 grid of viewport points
|
|
14
26
|
with `elementFromPoint` (one `page.evaluate`, at first-visit state, before the autoscroll and
|
package/dist/cli.js
CHANGED
|
@@ -76844,6 +76844,32 @@ var TOLERANCES = {
|
|
|
76844
76844
|
note: "A background, border or `::backdrop` colour with alpha below this, or an element chain whose opacity multiplies down below it, is treated as painting nothing. Matches 'nearly invisible' (a confirm button at opacity 0.02) without calling a faint tint invisible. Baked into the recorded `paints` flag, so changing it applies to new captures only."
|
|
76845
76845
|
}
|
|
76846
76846
|
},
|
|
76847
|
+
firstViewportSsr: {
|
|
76848
|
+
minViewportShare: {
|
|
76849
|
+
value: 0.05,
|
|
76850
|
+
unit: "ratio (0-1)",
|
|
76851
|
+
basis: "assumed",
|
|
76852
|
+
note: "A section counts as 'in the first viewport' for first-viewport-ssr only when it covers at least this share of the viewport area (a full-width band about 65 px tall on a 900 px viewport). Below it the section merely pokes in: a cart count, a thin promo strip, a sliver of the next block. Bottom-anchored fixed layers (consent bar, chat bubble) are dropped by the probe itself."
|
|
76853
|
+
},
|
|
76854
|
+
deferredBelow: {
|
|
76855
|
+
value: 0.5,
|
|
76856
|
+
unit: "ratio (0-1)",
|
|
76857
|
+
basis: "assumed",
|
|
76858
|
+
note: "A section is deferred when the mean, over the content kinds it has in the final DOM (text, links, images, form fields), of min(1, server count / final count) is at or below this. A skeleton keeps a logo or a wrapper link and loses the rest, so a single well-covered kind must not clear it (that is why it is a mean, not a max); a section the client merely adds to (a few more links after hydration, extra carousel slides) stays well above it. Not calibrated against real storefronts."
|
|
76859
|
+
},
|
|
76860
|
+
contentMinChars: {
|
|
76861
|
+
value: 20,
|
|
76862
|
+
unit: "chars",
|
|
76863
|
+
basis: "assumed",
|
|
76864
|
+
note: "Text counts as a content kind of a section only when its final DOM holds at least this many characters; a cart '3' or a 'Menu' label is not content. Links, images and form fields count from 1. A section with no content kind at or above the floor is not judgeable (it is empty in the final render too, which is another check's question)."
|
|
76865
|
+
},
|
|
76866
|
+
maxSections: {
|
|
76867
|
+
value: 40,
|
|
76868
|
+
unit: "count",
|
|
76869
|
+
basis: "assumed",
|
|
76870
|
+
note: "Sections recorded per page, first-viewport ones first. Bounds the size of a recording; below-the-fold sections are only kept so the other side's counterpart can be found."
|
|
76871
|
+
}
|
|
76872
|
+
},
|
|
76847
76873
|
geometry: {
|
|
76848
76874
|
subpixelPx: {
|
|
76849
76875
|
value: 1,
|
|
@@ -79924,6 +79950,156 @@ function withHtmlSnapshot(check) {
|
|
|
79924
79950
|
return guarded;
|
|
79925
79951
|
}
|
|
79926
79952
|
|
|
79953
|
+
// src/checks/first-viewport-ssr.ts
|
|
79954
|
+
var T = TOLERANCES.firstViewportSsr;
|
|
79955
|
+
function firstViewportSsr(ctx) {
|
|
79956
|
+
const start = Date.now();
|
|
79957
|
+
const { pairs } = pairCaptures(ctx.prodPages, ctx.candPages);
|
|
79958
|
+
const issues = [];
|
|
79959
|
+
const judged = [];
|
|
79960
|
+
const unjudged = [];
|
|
79961
|
+
for (const pair of pairs) {
|
|
79962
|
+
const why = unjudgeable2(pair.prod.firstViewport, pair.cand.firstViewport);
|
|
79963
|
+
if (why) {
|
|
79964
|
+
unjudged.push(pair.key);
|
|
79965
|
+
issues.push({
|
|
79966
|
+
id: `first-viewport:no-probe:${pair.key}`,
|
|
79967
|
+
severity: "low",
|
|
79968
|
+
inconclusive: true,
|
|
79969
|
+
category: "performance",
|
|
79970
|
+
page: pair.key,
|
|
79971
|
+
check: "first-viewport-ssr",
|
|
79972
|
+
summary: `${pair.key}: first-viewport probe unavailable (${why}) — not compared by first-viewport-ssr`,
|
|
79973
|
+
details: "Without server HTML and judgeable first-viewport sections on both sides there is nothing to compare, and absence is not evidence that the server rendered them. Re-capture with a current parity."
|
|
79974
|
+
});
|
|
79975
|
+
continue;
|
|
79976
|
+
}
|
|
79977
|
+
judged.push(pair.key);
|
|
79978
|
+
issues.push(...judgePair2(pair));
|
|
79979
|
+
}
|
|
79980
|
+
const live = issues.filter((i) => !i.inconclusive);
|
|
79981
|
+
const compared = judged.length;
|
|
79982
|
+
const status = live.some((i) => i.severity === "high" || i.severity === "critical") ? "fail" : live.length > 0 ? "warn" : compared === 0 ? "skipped" : "pass";
|
|
79983
|
+
const regressions = live.filter((i) => i.id.startsWith("first-viewport:regression:")).length;
|
|
79984
|
+
const summary = compared === 0 ? `nothing compared: ${pairs.length === 0 ? "no prod x cand page pairs" : `${unjudged.length} of ${pairs.length} page pair(s) had no judgeable first-viewport probe`}` : `${compared} page pair(s) compared, ${regressions} first-viewport regression(s), ${live.length - regressions} deferred section(s) prod shares${unjudged.length ? `, ${unjudged.length} without a probe` : ""}`;
|
|
79985
|
+
return {
|
|
79986
|
+
name: "first-viewport-ssr",
|
|
79987
|
+
status,
|
|
79988
|
+
severity: "high",
|
|
79989
|
+
durationMs: Date.now() - start,
|
|
79990
|
+
summary,
|
|
79991
|
+
issues,
|
|
79992
|
+
...unitCounts({
|
|
79993
|
+
unit: "page-pair",
|
|
79994
|
+
judged,
|
|
79995
|
+
unjudged,
|
|
79996
|
+
issues,
|
|
79997
|
+
informational: (i) => i.id.startsWith("first-viewport:prod-deferred:")
|
|
79998
|
+
}),
|
|
79999
|
+
data: { pairs: pairs.length, compared, withoutProbe: unjudged.length }
|
|
80000
|
+
};
|
|
80001
|
+
}
|
|
80002
|
+
function kindsOf(final, server) {
|
|
80003
|
+
const s = server ?? { text: 0, links: 0, images: 0, inputs: 0 };
|
|
80004
|
+
const all = [
|
|
80005
|
+
{ label: "text chars", final: final.text, server: s.text },
|
|
80006
|
+
{ label: "links", final: final.links, server: s.links },
|
|
80007
|
+
{ label: "images", final: final.images, server: s.images },
|
|
80008
|
+
{ label: "inputs", final: final.inputs, server: s.inputs }
|
|
80009
|
+
];
|
|
80010
|
+
return all.filter((k) => k.final >= (k.label === "text chars" ? T.contentMinChars.value : 1));
|
|
80011
|
+
}
|
|
80012
|
+
var judgeable = (s) => kindsOf(s.final, s.server).length > 0;
|
|
80013
|
+
var inViewport = (s) => s.share >= T.minViewportShare.value && judgeable(s);
|
|
80014
|
+
function serverShare(s) {
|
|
80015
|
+
const kinds = kindsOf(s.final, s.server);
|
|
80016
|
+
return kinds.reduce((sum, k) => sum + Math.min(1, k.server / k.final), 0) / kinds.length;
|
|
80017
|
+
}
|
|
80018
|
+
var isDeferred = (s) => serverShare(s) <= T.deferredBelow.value;
|
|
80019
|
+
function unjudgeable2(prod, cand) {
|
|
80020
|
+
if (!prod || !cand)
|
|
80021
|
+
return `no probe on ${!prod && !cand ? "either side" : !prod ? "prod" : "cand"}`;
|
|
80022
|
+
if (prod.serverChars === 0 || cand.serverChars === 0)
|
|
80023
|
+
return "no server HTML recorded on a side";
|
|
80024
|
+
if (!cand.sections.some(inViewport))
|
|
80025
|
+
return "no judgeable section in cand's first viewport";
|
|
80026
|
+
return null;
|
|
80027
|
+
}
|
|
80028
|
+
function counterpart(s, others, used) {
|
|
80029
|
+
const free = others.filter((o) => !used.has(o));
|
|
80030
|
+
const hit = free.find((o) => o.keys.some((k) => s.keys.includes(k))) ?? (s.landmark ? free.find((o) => o.landmark === s.landmark) : undefined) ?? null;
|
|
80031
|
+
if (hit)
|
|
80032
|
+
used.add(hit);
|
|
80033
|
+
return hit;
|
|
80034
|
+
}
|
|
80035
|
+
function missing(s) {
|
|
80036
|
+
return kindsOf(s.final, s.server).map((k) => `${k.server} of ${k.final} ${k.label}`).join(", ");
|
|
80037
|
+
}
|
|
80038
|
+
function judgePair2(pair) {
|
|
80039
|
+
const prod = pair.prod.firstViewport;
|
|
80040
|
+
const cand = pair.cand.firstViewport;
|
|
80041
|
+
const candView = cand.sections.filter(inViewport);
|
|
80042
|
+
const wholePageClientSide = isLocalhost(pair.cand.finalUrl) && candView.length > 0 && candView.every(isDeferred);
|
|
80043
|
+
const caveat = wholePageClientSide ? " Measured against a local dev server on which every judged first-viewport section is deferred, i.e. the whole page rendered client-side, which several frameworks do in dev: reconfirm on a production build before treating this as a defect." : "";
|
|
80044
|
+
const out = [];
|
|
80045
|
+
const usedProd = new Set;
|
|
80046
|
+
const names = new Map;
|
|
80047
|
+
const idFor = (kind, name) => {
|
|
80048
|
+
const n = (names.get(`${kind}:${name}`) ?? 0) + 1;
|
|
80049
|
+
names.set(`${kind}:${name}`, n);
|
|
80050
|
+
return `first-viewport:${kind}:${name}${n > 1 ? `#${n}` : ""}:${pair.key}`;
|
|
80051
|
+
};
|
|
80052
|
+
const common = { category: "performance", page: pair.key, check: "first-viewport-ssr" };
|
|
80053
|
+
const where = `[${pair.viewport}] ${pair.cand.url}`;
|
|
80054
|
+
for (const s of candView) {
|
|
80055
|
+
const p = counterpart(s, prod.sections, usedProd);
|
|
80056
|
+
if (!isDeferred(s))
|
|
80057
|
+
continue;
|
|
80058
|
+
const pct = Math.round(s.share * 100);
|
|
80059
|
+
const lack = `${missing(s)} in the server HTML`;
|
|
80060
|
+
const prodState = p && judgeable(p) ? isDeferred(p) ? "deferred" : "rendered" : "unknown";
|
|
80061
|
+
const fix = "Server-render this section (do not wrap it in a lazy/deferred section, or mark it eager) so it is in the first response; if it must stay deferred, give its fallback the section's real size.";
|
|
80062
|
+
const inconclusive = wholePageClientSide ? { inconclusive: true } : {};
|
|
80063
|
+
if (prodState === "rendered") {
|
|
80064
|
+
out.push({
|
|
80065
|
+
...common,
|
|
80066
|
+
...inconclusive,
|
|
80067
|
+
id: idFor("regression", s.name),
|
|
80068
|
+
severity: "high",
|
|
80069
|
+
summary: `cand defers the ${s.name} section in the first viewport that prod server-renders (${lack})`,
|
|
80070
|
+
details: `${where}: ${s.name} covers ${pct}% of the first viewport and reaches the browser as a skeleton until client JS runs, while prod's server HTML already holds it (${missing(p)}).${caveat}`,
|
|
80071
|
+
suggestedFix: fix
|
|
80072
|
+
});
|
|
80073
|
+
} else {
|
|
80074
|
+
const why = prodState === "deferred" ? "prod defers it too, so this is not a regression: prod has the same flaw and the candidate can fix it" : "prod has no first-viewport counterpart to compare with";
|
|
80075
|
+
out.push({
|
|
80076
|
+
...common,
|
|
80077
|
+
...inconclusive,
|
|
80078
|
+
id: idFor("improve", s.name),
|
|
80079
|
+
severity: "medium",
|
|
80080
|
+
summary: `${s.name} is deferred in the first viewport on cand (${lack}); ${prodState === "deferred" ? "prod has the same flaw, the candidate can fix it" : "no prod counterpart to compare"}`,
|
|
80081
|
+
details: `${where}: ${s.name} covers ${pct}% of the first viewport and arrives after client JS runs; ${why}. Reported because content in the first viewport arriving late is a defect on its own. Whether to fix it or keep it as-is is the owner's decision (accept it with an expectedDivergences entry for this id).${caveat}`,
|
|
80082
|
+
suggestedFix: fix
|
|
80083
|
+
});
|
|
80084
|
+
}
|
|
80085
|
+
}
|
|
80086
|
+
const usedCand = new Set;
|
|
80087
|
+
for (const p of prod.sections.filter(inViewport)) {
|
|
80088
|
+
const c = counterpart(p, cand.sections, usedCand);
|
|
80089
|
+
if (!isDeferred(p) || !c || !judgeable(c) || isDeferred(c))
|
|
80090
|
+
continue;
|
|
80091
|
+
out.push({
|
|
80092
|
+
...common,
|
|
80093
|
+
id: idFor("prod-deferred", p.name),
|
|
80094
|
+
severity: "low",
|
|
80095
|
+
inconclusive: true,
|
|
80096
|
+
summary: `prod defers the ${p.name} section in the first viewport (${missing(p)} in the server HTML) and cand server-renders it`,
|
|
80097
|
+
details: `${where}: informational, the candidate is better than prod here.`
|
|
80098
|
+
});
|
|
80099
|
+
}
|
|
80100
|
+
return out;
|
|
80101
|
+
}
|
|
80102
|
+
|
|
79927
80103
|
// src/checks/login-flow.ts
|
|
79928
80104
|
var STEP_LABELS = {
|
|
79929
80105
|
"visit-home": "Visitar home",
|
|
@@ -83830,6 +84006,205 @@ async function acceptCookieBanner(page, opts = {}) {
|
|
|
83830
84006
|
return false;
|
|
83831
84007
|
}
|
|
83832
84008
|
|
|
84009
|
+
// src/engine/first-viewport-probe.ts
|
|
84010
|
+
var FIRST_VIEWPORT_PROBE_SOURCE = `(function (arg) {
|
|
84011
|
+
var vw = window.innerWidth;
|
|
84012
|
+
var vh = window.innerHeight;
|
|
84013
|
+
var SKIP = { SCRIPT: 1, STYLE: 1, NOSCRIPT: 1, TEMPLATE: 1, LINK: 1, META: 1 };
|
|
84014
|
+
var LANDMARK = 'header,[role=banner],main,[role=main],footer,[role=contentinfo],nav,[role=navigation]';
|
|
84015
|
+
var KEY = 'data-manifest-key';
|
|
84016
|
+
|
|
84017
|
+
function landmarkName(el) {
|
|
84018
|
+
var tag = el.tagName.toLowerCase();
|
|
84019
|
+
var role = el.getAttribute('role');
|
|
84020
|
+
if (tag === 'header' || role === 'banner') return 'header';
|
|
84021
|
+
if (tag === 'main' || role === 'main') return 'main';
|
|
84022
|
+
if (tag === 'footer' || role === 'contentinfo') return 'footer';
|
|
84023
|
+
if (tag === 'nav' || role === 'navigation') return 'nav';
|
|
84024
|
+
return null;
|
|
84025
|
+
}
|
|
84026
|
+
function landmarkOf(el) {
|
|
84027
|
+
var self = el.matches(LANDMARK) ? el : el.querySelector(LANDMARK);
|
|
84028
|
+
return self ? landmarkName(self) : null;
|
|
84029
|
+
}
|
|
84030
|
+
// Outermost keyed elements; a landmark only when nothing keyed lives inside it (otherwise the
|
|
84031
|
+
// keyed children are the sections and the landmark is just their container).
|
|
84032
|
+
function collect(doc) {
|
|
84033
|
+
var out = [];
|
|
84034
|
+
(function walk(parent) {
|
|
84035
|
+
for (var c = parent.firstElementChild; c; c = c.nextElementSibling) {
|
|
84036
|
+
if (SKIP[c.tagName]) continue;
|
|
84037
|
+
if (c.hasAttribute(KEY)) { out.push(c); continue; }
|
|
84038
|
+
if (c.matches(LANDMARK)) {
|
|
84039
|
+
if (c.querySelector('[' + KEY + ']')) walk(c); else out.push(c);
|
|
84040
|
+
continue;
|
|
84041
|
+
}
|
|
84042
|
+
walk(c);
|
|
84043
|
+
}
|
|
84044
|
+
})(doc.body || doc.documentElement);
|
|
84045
|
+
return out;
|
|
84046
|
+
}
|
|
84047
|
+
function ownId(el) {
|
|
84048
|
+
var k = el.getAttribute(KEY);
|
|
84049
|
+
return k ? 'k:' + k : 't:' + el.tagName.toLowerCase() + ':' + (el.getAttribute('role') || '');
|
|
84050
|
+
}
|
|
84051
|
+
function innerKeys(el) {
|
|
84052
|
+
var seen = {};
|
|
84053
|
+
var keys = [];
|
|
84054
|
+
var nodes = el.querySelectorAll('[' + KEY + ']');
|
|
84055
|
+
for (var i = 0; i < nodes.length && keys.length < 6; i++) {
|
|
84056
|
+
var k = nodes[i].getAttribute(KEY);
|
|
84057
|
+
if (k && !seen[k]) { seen[k] = 1; keys.push(k); }
|
|
84058
|
+
}
|
|
84059
|
+
return keys;
|
|
84060
|
+
}
|
|
84061
|
+
function keysOf(el) {
|
|
84062
|
+
var inner = innerKeys(el);
|
|
84063
|
+
if (inner.length) return inner;
|
|
84064
|
+
var own = el.getAttribute(KEY);
|
|
84065
|
+
return own ? [own] : [];
|
|
84066
|
+
}
|
|
84067
|
+
function nameOf(el, keys) {
|
|
84068
|
+
if (keys.length) return keys[0].split('/').pop().replace(/\\.(tsx|ts|jsx|js|mjs)$/i, '');
|
|
84069
|
+
return landmarkOf(el) || el.tagName.toLowerCase();
|
|
84070
|
+
}
|
|
84071
|
+
function metrics(el) {
|
|
84072
|
+
var buf = '';
|
|
84073
|
+
var links = 0, images = 0, inputs = 0;
|
|
84074
|
+
(function walk(n) {
|
|
84075
|
+
for (var c = n.firstChild; c; c = c.nextSibling) {
|
|
84076
|
+
if (c.nodeType === 3) { buf += ' ' + c.nodeValue; continue; }
|
|
84077
|
+
if (c.nodeType !== 1 || SKIP[c.tagName]) continue;
|
|
84078
|
+
var t = c.tagName;
|
|
84079
|
+
if (t === 'A' && c.hasAttribute('href')) links++;
|
|
84080
|
+
else if (t === 'IMG' || t === 'VIDEO') images++;
|
|
84081
|
+
else if (t === 'SELECT' || t === 'TEXTAREA' || (t === 'INPUT' && c.getAttribute('type') !== 'hidden')) inputs++;
|
|
84082
|
+
walk(c);
|
|
84083
|
+
}
|
|
84084
|
+
})(el);
|
|
84085
|
+
return { text: buf.replace(/\\s+/g, ' ').trim().length, links: links, images: images, inputs: inputs };
|
|
84086
|
+
}
|
|
84087
|
+
// A modal, drawer, consent bar or chat bubble: a fixed layer that is bottom-anchored or covers
|
|
84088
|
+
// at least half the viewport (a fixed TOP header is neither). It is client-only by nature and
|
|
84089
|
+
// click-blocker-parity's business, not a section whose server rendering the user waits for.
|
|
84090
|
+
function isLayer(el, r, cs) {
|
|
84091
|
+
if (el.tagName === 'DIALOG' || el.getAttribute('role') === 'dialog' || el.getAttribute('aria-modal') === 'true') return true;
|
|
84092
|
+
if (cs.position !== 'fixed') return false;
|
|
84093
|
+
var w = Math.max(0, Math.min(r.right, vw) - Math.max(r.left, 0));
|
|
84094
|
+
var h = Math.max(0, Math.min(r.bottom, vh) - Math.max(r.top, 0));
|
|
84095
|
+
return r.top > vh * 0.5 || (vw * vh > 0 && (w * h) / (vw * vh) >= 0.5);
|
|
84096
|
+
}
|
|
84097
|
+
// A section wrapper can be 0px tall while its content is positioned out of flow (an absolute or
|
|
84098
|
+
// fixed header over the hero: seen on a real storefront, where the keyed header section measured
|
|
84099
|
+
// 0x1440 and the header inside it 134px). With no box of its own, the section is where its
|
|
84100
|
+
// content is: its landmark's box, else the union of its visible descendants' boxes (a menu panel
|
|
84101
|
+
// that is hidden or transparent has a box and must not widen it), layers excluded.
|
|
84102
|
+
function boxOf(el, cs) {
|
|
84103
|
+
var own = el.getBoundingClientRect();
|
|
84104
|
+
if (cs.display !== 'contents' && own.width * own.height > 0) return own;
|
|
84105
|
+
var lm = el.querySelector(LANDMARK);
|
|
84106
|
+
if (lm) {
|
|
84107
|
+
var lr = lm.getBoundingClientRect();
|
|
84108
|
+
if (lr.width * lr.height > 0 && !isLayer(lm, lr, getComputedStyle(lm))) return lr;
|
|
84109
|
+
}
|
|
84110
|
+
var l = 1e9, t = 1e9, r = -1e9, b = -1e9;
|
|
84111
|
+
var nodes = el.querySelectorAll('*');
|
|
84112
|
+
var layers = [];
|
|
84113
|
+
for (var i = 0; i < nodes.length && i < 300; i++) {
|
|
84114
|
+
// Document order: a layer is seen before its children, which are part of it.
|
|
84115
|
+
if (layers.some(function (L) { return L.contains(nodes[i]); })) continue;
|
|
84116
|
+
var cr = nodes[i].getBoundingClientRect();
|
|
84117
|
+
if (cr.width * cr.height <= 0) continue;
|
|
84118
|
+
var ncs = getComputedStyle(nodes[i]);
|
|
84119
|
+
if (isLayer(nodes[i], cr, ncs)) { layers.push(nodes[i]); continue; }
|
|
84120
|
+
if (ncs.visibility === 'hidden' || ncs.opacity === '0') continue;
|
|
84121
|
+
l = Math.min(l, cr.left); t = Math.min(t, cr.top); r = Math.max(r, cr.right); b = Math.max(b, cr.bottom);
|
|
84122
|
+
}
|
|
84123
|
+
return r < l ? own : { left: l, top: t, right: r, bottom: b };
|
|
84124
|
+
}
|
|
84125
|
+
|
|
84126
|
+
var rawDoc = new DOMParser().parseFromString(arg.raw, 'text/html');
|
|
84127
|
+
var rawCands = collect(rawDoc);
|
|
84128
|
+
var rawById = {};
|
|
84129
|
+
rawCands.forEach(function (el) { (rawById[ownId(el)] = rawById[ownId(el)] || []).push(el); });
|
|
84130
|
+
var used = [];
|
|
84131
|
+
var seenOwn = {};
|
|
84132
|
+
|
|
84133
|
+
function serverCounterpart(el, keys) {
|
|
84134
|
+
var id = ownId(el);
|
|
84135
|
+
var n = seenOwn[id] || 0;
|
|
84136
|
+
seenOwn[id] = n + 1;
|
|
84137
|
+
var hit = rawById[id] && rawById[id][n];
|
|
84138
|
+
if (!hit) {
|
|
84139
|
+
hit = rawCands.filter(function (r) {
|
|
84140
|
+
return used.indexOf(r) < 0 && keysOf(r).some(function (k) { return keys.indexOf(k) >= 0; });
|
|
84141
|
+
})[0];
|
|
84142
|
+
}
|
|
84143
|
+
var lm = landmarkOf(el);
|
|
84144
|
+
if (!hit && lm) hit = rawCands.filter(function (r) { return used.indexOf(r) < 0 && landmarkOf(r) === lm; })[0];
|
|
84145
|
+
if (hit) used.push(hit);
|
|
84146
|
+
return hit ? metrics(hit) : null;
|
|
84147
|
+
}
|
|
84148
|
+
|
|
84149
|
+
var sections = [];
|
|
84150
|
+
collect(document).forEach(function (el) {
|
|
84151
|
+
var keys = keysOf(el);
|
|
84152
|
+
// Counted before any exclusion so the n-th-own-key pairing stays aligned with the server HTML.
|
|
84153
|
+
var server = serverCounterpart(el, keys);
|
|
84154
|
+
var cs = getComputedStyle(el);
|
|
84155
|
+
var share = 0;
|
|
84156
|
+
if (cs.display !== 'none' && cs.visibility !== 'hidden') {
|
|
84157
|
+
var r = boxOf(el, cs);
|
|
84158
|
+
if (isLayer(el, r, cs)) return;
|
|
84159
|
+
var w = Math.max(0, Math.min(r.right, vw) - Math.max(r.left, 0));
|
|
84160
|
+
var h = Math.max(0, Math.min(r.bottom, vh) - Math.max(r.top, 0));
|
|
84161
|
+
share = vw * vh > 0 ? Math.round((w * h) / (vw * vh) * 1000) / 1000 : 0;
|
|
84162
|
+
}
|
|
84163
|
+
sections.push({
|
|
84164
|
+
name: nameOf(el, keys),
|
|
84165
|
+
keys: keys,
|
|
84166
|
+
landmark: landmarkOf(el),
|
|
84167
|
+
share: share,
|
|
84168
|
+
final: metrics(el),
|
|
84169
|
+
server: server
|
|
84170
|
+
});
|
|
84171
|
+
});
|
|
84172
|
+
// In-viewport sections first: the cap must never drop the part the check is about.
|
|
84173
|
+
sections = sections
|
|
84174
|
+
.map(function (s, i) { return { s: s, i: i }; })
|
|
84175
|
+
.sort(function (a, b) { return (b.s.share > 0) - (a.s.share > 0) || a.i - b.i; })
|
|
84176
|
+
.map(function (x) { return x.s; })
|
|
84177
|
+
.slice(0, arg.maxSections);
|
|
84178
|
+
return { viewportWidth: vw, viewportHeight: vh, serverChars: arg.raw.length, sections: sections };
|
|
84179
|
+
})`;
|
|
84180
|
+
var MAX_RAW_CHARS = 8000000;
|
|
84181
|
+
function sameDocument(a, b) {
|
|
84182
|
+
try {
|
|
84183
|
+
const x = new URL(a);
|
|
84184
|
+
const y = new URL(b);
|
|
84185
|
+
return x.origin === y.origin && x.pathname === y.pathname && x.search === y.search;
|
|
84186
|
+
} catch {
|
|
84187
|
+
return false;
|
|
84188
|
+
}
|
|
84189
|
+
}
|
|
84190
|
+
async function readFirstViewportProbe(page, response) {
|
|
84191
|
+
try {
|
|
84192
|
+
if (!response || !sameDocument(response.url(), page.url()))
|
|
84193
|
+
return;
|
|
84194
|
+
const raw = await response.text().catch(() => null);
|
|
84195
|
+
if (!raw || raw.length > MAX_RAW_CHARS)
|
|
84196
|
+
return;
|
|
84197
|
+
return await page.evaluate(`${FIRST_VIEWPORT_PROBE_SOURCE}(${JSON.stringify({
|
|
84198
|
+
raw,
|
|
84199
|
+
maxSections: TOLERANCES.firstViewportSsr.maxSections.value
|
|
84200
|
+
})})`).catch(() => {
|
|
84201
|
+
return;
|
|
84202
|
+
}) ?? undefined;
|
|
84203
|
+
} catch {
|
|
84204
|
+
return;
|
|
84205
|
+
}
|
|
84206
|
+
}
|
|
84207
|
+
|
|
83833
84208
|
// src/engine/vitals-warm.ts
|
|
83834
84209
|
var VITALS_WARM_LOADS = 1;
|
|
83835
84210
|
var VITALS_WARM_TIMEOUT_MS = 15000;
|
|
@@ -84415,6 +84790,7 @@ async function capturePage(page, opts) {
|
|
|
84415
84790
|
xRobotsTag,
|
|
84416
84791
|
pairKey: opts.pairKey,
|
|
84417
84792
|
...clickProbe ? { clickProbe } : {},
|
|
84793
|
+
...firstViewport ? { firstViewport } : {},
|
|
84418
84794
|
...response ? { variant: fingerprintVariant(html, response.headers(), cookieNames) } : {}
|
|
84419
84795
|
});
|
|
84420
84796
|
let cookieNames = [];
|
|
@@ -84425,6 +84801,7 @@ async function capturePage(page, opts) {
|
|
|
84425
84801
|
let vitalsStats;
|
|
84426
84802
|
let vitalsFullPage = null;
|
|
84427
84803
|
let clickProbe;
|
|
84804
|
+
let firstViewport;
|
|
84428
84805
|
let html = "";
|
|
84429
84806
|
const readVitals = async () => {
|
|
84430
84807
|
dlog(opts.side, opts.viewport, ` capturePage: vitals evaluate (cap=${Math.min(5000, remaining())}ms)`);
|
|
@@ -84437,6 +84814,10 @@ async function capturePage(page, opts) {
|
|
|
84437
84814
|
readClickProbe(page),
|
|
84438
84815
|
new Promise((resolve) => setTimeout(() => resolve(undefined), Math.min(3000, remaining())))
|
|
84439
84816
|
]) : undefined;
|
|
84817
|
+
const readFirstViewportCapped = async () => response ? await Promise.race([
|
|
84818
|
+
readFirstViewportProbe(page, response),
|
|
84819
|
+
new Promise((resolve) => setTimeout(() => resolve(undefined), Math.min(4000, remaining())))
|
|
84820
|
+
]) : undefined;
|
|
84440
84821
|
let _resolveDisconnect;
|
|
84441
84822
|
const disconnectPromise = new Promise((r) => {
|
|
84442
84823
|
_resolveDisconnect = r;
|
|
@@ -84474,6 +84855,7 @@ async function capturePage(page, opts) {
|
|
|
84474
84855
|
await page.waitForTimeout(Math.min(opts.settleMs ?? 1200, remaining()));
|
|
84475
84856
|
vitals = await readVitals();
|
|
84476
84857
|
clickProbe = await readClickProbeCapped();
|
|
84858
|
+
firstViewport = await readFirstViewportCapped();
|
|
84477
84859
|
} else {
|
|
84478
84860
|
dlog(opts.side, opts.viewport, ` capturePage: waitForLoadState('load') (cap=${Math.min(12000, remaining())}ms)`);
|
|
84479
84861
|
await page.waitForLoadState("load", { timeout: Math.min(12000, remaining()) }).catch(() => {
|
|
@@ -84489,6 +84871,7 @@ async function capturePage(page, opts) {
|
|
|
84489
84871
|
await page.waitForTimeout(Math.min(opts.settleMs ?? 2000, remaining()));
|
|
84490
84872
|
vitals = await readVitals();
|
|
84491
84873
|
clickProbe = await readClickProbeCapped();
|
|
84874
|
+
firstViewport = await readFirstViewportCapped();
|
|
84492
84875
|
if (opts.scrollToLoad !== false && remaining() > 3000) {
|
|
84493
84876
|
const scrollBudget = Math.min(45000, remaining());
|
|
84494
84877
|
dlog(opts.side, opts.viewport, ` capturePage: scrollFullPage start (budget=${scrollBudget}ms, remaining=${remaining()}ms)`);
|
|
@@ -89426,7 +89809,7 @@ async function compareViewport(browser, args) {
|
|
|
89426
89809
|
repeatPath: null
|
|
89427
89810
|
})
|
|
89428
89811
|
]);
|
|
89429
|
-
return
|
|
89812
|
+
return judgePair3({
|
|
89430
89813
|
spec,
|
|
89431
89814
|
paths,
|
|
89432
89815
|
prod: prod.side,
|
|
@@ -89487,7 +89870,7 @@ function artifactPaths(outDir, prefix, label) {
|
|
|
89487
89870
|
candMasked: at("cand-masked")
|
|
89488
89871
|
};
|
|
89489
89872
|
}
|
|
89490
|
-
function
|
|
89873
|
+
function judgePair3(args) {
|
|
89491
89874
|
const { spec, paths, prod, cand } = args;
|
|
89492
89875
|
const base = {
|
|
89493
89876
|
label: spec.label,
|
|
@@ -90239,7 +90622,7 @@ async function visualRegressionKeyframes(ctx) {
|
|
|
90239
90622
|
const prod = prodProbe ?? unprobed("prod");
|
|
90240
90623
|
const cand = candProbe ?? unprobed("cand");
|
|
90241
90624
|
const prefix = `heatmap-${hashSelector(pair.key)}`;
|
|
90242
|
-
const r =
|
|
90625
|
+
const r = judgePair3({
|
|
90243
90626
|
spec: { label: pair.viewport, viewport: pair.viewport, size: null },
|
|
90244
90627
|
paths: artifactPaths(diffDir, prefix, pair.viewport),
|
|
90245
90628
|
prod: prod.side,
|
|
@@ -90580,6 +90963,7 @@ var consoleErrorsBaseline2 = withCapturedPairs(consoleErrorsBaseline);
|
|
|
90580
90963
|
var redirectsParity2 = withCapturedPairs(redirectsParity);
|
|
90581
90964
|
var thirdPartyScriptsParity2 = withCapturedPairs(thirdPartyScriptsParity);
|
|
90582
90965
|
var clickBlockerParity2 = withCapturedPairs(clickBlockerParity);
|
|
90966
|
+
var firstViewportSsr2 = withCapturedPairs(firstViewportSsr);
|
|
90583
90967
|
var imageLoadingHealth2 = withHtmlSnapshot(imageLoadingHealth);
|
|
90584
90968
|
var lazySectionPresence2 = withHtmlSnapshot(lazySectionPresence);
|
|
90585
90969
|
var metaSeoParity2 = withHtmlSnapshot(metaSeoParity);
|
|
@@ -90613,6 +90997,7 @@ var ALL_CHECKS = [
|
|
|
90613
90997
|
notFoundParity2,
|
|
90614
90998
|
cookieCepModalCls2,
|
|
90615
90999
|
clickBlockerParity2,
|
|
91000
|
+
firstViewportSsr2,
|
|
90616
91001
|
pdpGalleryRelated2,
|
|
90617
91002
|
footerLinksHealth2,
|
|
90618
91003
|
loginFlow,
|
|
@@ -90656,6 +91041,7 @@ var ALL_CHECKS_BY_NAME = {
|
|
|
90656
91041
|
"not-found-parity": notFoundParity2,
|
|
90657
91042
|
"cookie-cep-modal-cls": cookieCepModalCls2,
|
|
90658
91043
|
"click-blocker-parity": clickBlockerParity2,
|
|
91044
|
+
"first-viewport-ssr": firstViewportSsr2,
|
|
90659
91045
|
"pdp-gallery-related": pdpGalleryRelated2,
|
|
90660
91046
|
"footer-links-health": footerLinksHealth2,
|
|
90661
91047
|
"login-flow": loginFlow,
|
|
@@ -90803,7 +91189,7 @@ var MODULES = {
|
|
|
90803
91189
|
},
|
|
90804
91190
|
html: {
|
|
90805
91191
|
name: "html",
|
|
90806
|
-
description: "HTML structure — structural diff, lazy sections, image loading health, missing picture dimensions, editorial content structure",
|
|
91192
|
+
description: "HTML structure — structural diff, lazy sections, first-viewport content in the server response, image loading health, missing picture dimensions, editorial content structure",
|
|
90807
91193
|
checks: [
|
|
90808
91194
|
"html-structural-diff",
|
|
90809
91195
|
"lazy-section-presence",
|
|
@@ -90811,6 +91197,7 @@ var MODULES = {
|
|
|
90811
91197
|
"picture-missing-dims",
|
|
90812
91198
|
"font-parity",
|
|
90813
91199
|
"ssr-no-js",
|
|
91200
|
+
"first-viewport-ssr",
|
|
90814
91201
|
"section-order-parity",
|
|
90815
91202
|
"content-structure"
|
|
90816
91203
|
],
|
|
@@ -91002,6 +91389,26 @@ var ClickProbe = z2.object({
|
|
|
91002
91389
|
viewportHeight: z2.number(),
|
|
91003
91390
|
points: z2.array(ClickProbePoint)
|
|
91004
91391
|
});
|
|
91392
|
+
var SectionContent = z2.object({
|
|
91393
|
+
text: z2.number(),
|
|
91394
|
+
links: z2.number(),
|
|
91395
|
+
images: z2.number(),
|
|
91396
|
+
inputs: z2.number()
|
|
91397
|
+
});
|
|
91398
|
+
var FirstViewportSection = z2.object({
|
|
91399
|
+
name: z2.string(),
|
|
91400
|
+
keys: z2.array(z2.string()),
|
|
91401
|
+
landmark: z2.string().nullable(),
|
|
91402
|
+
share: z2.number(),
|
|
91403
|
+
final: SectionContent,
|
|
91404
|
+
server: SectionContent.nullable()
|
|
91405
|
+
});
|
|
91406
|
+
var FirstViewportProbe = z2.object({
|
|
91407
|
+
viewportWidth: z2.number(),
|
|
91408
|
+
viewportHeight: z2.number(),
|
|
91409
|
+
serverChars: z2.number(),
|
|
91410
|
+
sections: z2.array(FirstViewportSection)
|
|
91411
|
+
});
|
|
91005
91412
|
var PageCapture = z2.object({
|
|
91006
91413
|
url: z2.string(),
|
|
91007
91414
|
finalUrl: z2.string(),
|
|
@@ -91027,7 +91434,8 @@ var PageCapture = z2.object({
|
|
|
91027
91434
|
pass: z2.enum(["extra", "visual"]).optional(),
|
|
91028
91435
|
variant: VariantFingerprint.optional(),
|
|
91029
91436
|
retried: z2.boolean().optional(),
|
|
91030
|
-
clickProbe: ClickProbe.optional()
|
|
91437
|
+
clickProbe: ClickProbe.optional(),
|
|
91438
|
+
firstViewport: FirstViewportProbe.optional()
|
|
91031
91439
|
});
|
|
91032
91440
|
var StepCapture = z2.object({
|
|
91033
91441
|
step: z2.number(),
|
|
@@ -122944,11 +123352,11 @@ function L2(pt, en, lang) {
|
|
|
122944
123352
|
const initial = lang === "pt" ? pt : en;
|
|
122945
123353
|
return `<span class="i18n" data-pt="${esc3(pt)}" data-en="${esc3(en)}">${esc3(initial)}</span>`;
|
|
122946
123354
|
}
|
|
122947
|
-
function
|
|
123355
|
+
function T2(text, lang) {
|
|
122948
123356
|
return L2(text.pt, text.en, lang);
|
|
122949
123357
|
}
|
|
122950
123358
|
function tiles(items, lang) {
|
|
122951
|
-
const cells = items.map((t) => `<div class="tile"><div class="tile-val ${TONE_CLASS[t.tone]}">${esc3(t.value)}</div><div class="tile-label">${
|
|
123359
|
+
const cells = items.map((t) => `<div class="tile"><div class="tile-val ${TONE_CLASS[t.tone]}">${esc3(t.value)}</div><div class="tile-label">${T2(t.label, lang)}</div>${t.sub ? `<div class="tile-sub">${T2(t.sub, lang)}</div>` : ""}</div>`).join("");
|
|
122952
123360
|
return `<div class="stat-grid">${cells}</div>`;
|
|
122953
123361
|
}
|
|
122954
123362
|
function page(eyebrow, title, body, note) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/parity",
|
|
3
|
-
"version": "0.35.
|
|
3
|
+
"version": "0.35.32",
|
|
4
4
|
"description": "E2E parity validator for site migrations. Compares prod vs cand and reports UI, functional, SEO, visual, and Web Vitals deltas with a ranked HTML report.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|