@decocms/parity 0.33.38 → 0.33.40
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/dist/cli.js +97 -91
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -39037,6 +39037,49 @@ function parseIntOrNull(v) {
|
|
|
39037
39037
|
return Number.isFinite(n) ? n : null;
|
|
39038
39038
|
}
|
|
39039
39039
|
var SKELETON_SELECTOR = "[aria-busy='true'],[data-skeleton],[data-loading='true'],.skeleton,[class*='skeleton' i],[class*='Skeleton'],[class*='shimmer' i],.animate-pulse,.placeholder-shimmer,.react-loading-skeleton";
|
|
39040
|
+
async function settlePage(page, opts = {}) {
|
|
39041
|
+
const {
|
|
39042
|
+
waitMs = 0,
|
|
39043
|
+
fonts = true,
|
|
39044
|
+
layoutStable = true,
|
|
39045
|
+
stabilize = true,
|
|
39046
|
+
scroll = true,
|
|
39047
|
+
scrollBudgetMs = 30000,
|
|
39048
|
+
skeletons = scroll
|
|
39049
|
+
} = opts;
|
|
39050
|
+
const out = {};
|
|
39051
|
+
if (waitMs > 0)
|
|
39052
|
+
await page.waitForTimeout(waitMs);
|
|
39053
|
+
if (fonts)
|
|
39054
|
+
await reloadIfOptionalFonts(page, waitMs);
|
|
39055
|
+
if (layoutStable)
|
|
39056
|
+
out.settle = await waitForLayoutStable(page);
|
|
39057
|
+
if (stabilize) {
|
|
39058
|
+
await Promise.race([
|
|
39059
|
+
stabilizeCarousels(page).catch(() => {
|
|
39060
|
+
return;
|
|
39061
|
+
}),
|
|
39062
|
+
new Promise((r) => setTimeout(r, 3000))
|
|
39063
|
+
]);
|
|
39064
|
+
}
|
|
39065
|
+
if (scroll) {
|
|
39066
|
+
await Promise.race([
|
|
39067
|
+
scrollFullPage(page, scrollBudgetMs).catch(() => {
|
|
39068
|
+
return;
|
|
39069
|
+
}),
|
|
39070
|
+
new Promise((r) => setTimeout(r, scrollBudgetMs + 2000))
|
|
39071
|
+
]);
|
|
39072
|
+
}
|
|
39073
|
+
if (skeletons) {
|
|
39074
|
+
await Promise.race([
|
|
39075
|
+
waitForSkeletonsToResolve(page, 5000).catch(() => {
|
|
39076
|
+
return;
|
|
39077
|
+
}),
|
|
39078
|
+
new Promise((r) => setTimeout(r, 5000))
|
|
39079
|
+
]);
|
|
39080
|
+
}
|
|
39081
|
+
return out;
|
|
39082
|
+
}
|
|
39040
39083
|
async function waitForSkeletonsToResolve(page, maxMs = 1e4) {
|
|
39041
39084
|
const start = Date.now();
|
|
39042
39085
|
while (Date.now() - start < maxMs) {
|
|
@@ -64594,7 +64637,7 @@ function diffBoxTrees(prod, cand, opts = {}) {
|
|
|
64594
64637
|
onlyInProd: onlyInProd.map(brief("prod")),
|
|
64595
64638
|
onlyInCand: onlyInCand.map(brief("cand")),
|
|
64596
64639
|
deltas: deltas.slice(0, maxDeltas),
|
|
64597
|
-
truncated: opts.truncated ?? false
|
|
64640
|
+
truncated: (opts.truncated ?? false) || deltas.length > maxDeltas
|
|
64598
64641
|
};
|
|
64599
64642
|
}
|
|
64600
64643
|
function isBoxTreeInconclusive(diff) {
|
|
@@ -64969,31 +65012,11 @@ async function gatherSide(browser, opts) {
|
|
|
64969
65012
|
await page.waitForLoadState("networkidle", { timeout: 8000 }).catch(() => {
|
|
64970
65013
|
return;
|
|
64971
65014
|
});
|
|
64972
|
-
|
|
64973
|
-
|
|
64974
|
-
|
|
64975
|
-
|
|
64976
|
-
|
|
64977
|
-
stabilizeCarousels(page).catch(() => {
|
|
64978
|
-
return;
|
|
64979
|
-
}),
|
|
64980
|
-
new Promise((resolve) => setTimeout(resolve, 3000))
|
|
64981
|
-
]);
|
|
64982
|
-
if (opts.wantScreenshot) {
|
|
64983
|
-
const scrollBudget = 30000;
|
|
64984
|
-
await Promise.race([
|
|
64985
|
-
scrollFullPage(page, scrollBudget).catch(() => {
|
|
64986
|
-
return;
|
|
64987
|
-
}),
|
|
64988
|
-
new Promise((resolve) => setTimeout(resolve, scrollBudget + 2000))
|
|
64989
|
-
]);
|
|
64990
|
-
await Promise.race([
|
|
64991
|
-
waitForSkeletonsToResolve(page, 5000).catch(() => {
|
|
64992
|
-
return;
|
|
64993
|
-
}),
|
|
64994
|
-
new Promise((resolve) => setTimeout(resolve, 5000))
|
|
64995
|
-
]);
|
|
64996
|
-
}
|
|
65015
|
+
const settled = await settlePage(page, {
|
|
65016
|
+
waitMs: opts.waitMs,
|
|
65017
|
+
scroll: opts.wantScreenshot
|
|
65018
|
+
});
|
|
65019
|
+
result.settle = settled.settle;
|
|
64997
65020
|
const artifacts = await captureSectionArtifacts(page, {
|
|
64998
65021
|
selector: opts.selector,
|
|
64999
65022
|
wantHtml: opts.wantHtml,
|
|
@@ -68436,18 +68459,7 @@ async function migrateCommand(opts) {
|
|
|
68436
68459
|
await page.waitForLoadState("networkidle", { timeout: 8000 }).catch(() => {
|
|
68437
68460
|
return;
|
|
68438
68461
|
});
|
|
68439
|
-
await
|
|
68440
|
-
return;
|
|
68441
|
-
}), sleep3(3000)]);
|
|
68442
|
-
await Promise.race([scrollFullPage(page, 30000).catch(() => {
|
|
68443
|
-
return;
|
|
68444
|
-
}), sleep3(32000)]);
|
|
68445
|
-
await Promise.race([
|
|
68446
|
-
waitForSkeletonsToResolve(page, 5000).catch(() => {
|
|
68447
|
-
return;
|
|
68448
|
-
}),
|
|
68449
|
-
sleep3(5000)
|
|
68450
|
-
]);
|
|
68462
|
+
await settlePage(page, { fonts: false, layoutStable: false });
|
|
68451
68463
|
samples.push(await scrapeThemeSamples(page));
|
|
68452
68464
|
const shot = resolve6(runDir, "screenshots", `${vp}.png`);
|
|
68453
68465
|
await page.screenshot({ path: shot, fullPage: true, animations: "disabled", timeout: 15000 }).then(() => screenshots.push({ viewport: vp, path: `screenshots/${vp}.png` })).catch(() => {
|
|
@@ -68669,18 +68681,7 @@ async function capturePages(browser, viewport, resolvedPages, theme, cfg) {
|
|
|
68669
68681
|
await page.waitForLoadState("networkidle", { timeout: 8000 }).catch(() => {
|
|
68670
68682
|
return;
|
|
68671
68683
|
});
|
|
68672
|
-
await
|
|
68673
|
-
return;
|
|
68674
|
-
}), sleep3(3000)]);
|
|
68675
|
-
await Promise.race([scrollFullPage(page, 30000).catch(() => {
|
|
68676
|
-
return;
|
|
68677
|
-
}), sleep3(32000)]);
|
|
68678
|
-
await Promise.race([
|
|
68679
|
-
waitForSkeletonsToResolve(page, 5000).catch(() => {
|
|
68680
|
-
return;
|
|
68681
|
-
}),
|
|
68682
|
-
sleep3(5000)
|
|
68683
|
-
]);
|
|
68684
|
+
await settlePage(page, { fonts: false, layoutStable: false });
|
|
68684
68685
|
let detected = await detectComponents(page, { llm: cfg.llm });
|
|
68685
68686
|
if (cfg.allowlist)
|
|
68686
68687
|
detected = detected.filter((c) => matchesAllowlist2(c.role, cfg.allowlist));
|
|
@@ -68931,9 +68932,6 @@ function isValidUrl4(s) {
|
|
|
68931
68932
|
return false;
|
|
68932
68933
|
}
|
|
68933
68934
|
}
|
|
68934
|
-
function sleep3(ms) {
|
|
68935
|
-
return new Promise((resolveTimeout) => setTimeout(resolveTimeout, ms));
|
|
68936
|
-
}
|
|
68937
68935
|
|
|
68938
68936
|
// src/commands/plan.ts
|
|
68939
68937
|
import { readFileSync as readFileSync27 } from "node:fs";
|
|
@@ -74626,8 +74624,12 @@ function parseViewports2(raw) {
|
|
|
74626
74624
|
const entries = (raw.trim() === "all" ? ALL_VIEWPORTS : raw).split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
74627
74625
|
if (entries.length === 0)
|
|
74628
74626
|
return "--viewports is empty";
|
|
74627
|
+
const seen = new Set;
|
|
74629
74628
|
const specs = [];
|
|
74630
74629
|
for (const entry of entries) {
|
|
74630
|
+
if (seen.has(entry))
|
|
74631
|
+
return `viewport '${entry}' appears twice in --viewports`;
|
|
74632
|
+
seen.add(entry);
|
|
74631
74633
|
const named = parseViewport3(entry);
|
|
74632
74634
|
if (named) {
|
|
74633
74635
|
specs.push({ label: entry, viewport: named, size: null });
|
|
@@ -74654,9 +74656,10 @@ function aggregateVerdict(results) {
|
|
|
74654
74656
|
const differing = results.filter((r) => r.verdict === "differs");
|
|
74655
74657
|
if (differing.length > 0) {
|
|
74656
74658
|
const total = differing.reduce((sum, r) => sum + (r.diffPixels ?? 0), 0);
|
|
74659
|
+
const count = total > 0 ? ` (${total} pixels in total)` : "";
|
|
74657
74660
|
return {
|
|
74658
74661
|
verdict: "differs",
|
|
74659
|
-
reason: `${differing.length}/${results.length} viewports differ
|
|
74662
|
+
reason: `${differing.length}/${results.length} viewports differ${count}: ${differing.map((r) => r.label).join(", ")}`
|
|
74660
74663
|
};
|
|
74661
74664
|
}
|
|
74662
74665
|
const unread = results.filter((r) => r.verdict === "inconclusive");
|
|
@@ -74668,6 +74671,7 @@ function aggregateVerdict(results) {
|
|
|
74668
74671
|
}
|
|
74669
74672
|
return { verdict: "identical" };
|
|
74670
74673
|
}
|
|
74674
|
+
var MIN_COMPARABLE_PIXELS = 100;
|
|
74671
74675
|
var EXIT_IDENTICAL = 0;
|
|
74672
74676
|
var EXIT_DIFFERS = 1;
|
|
74673
74677
|
var EXIT_INCONCLUSIVE = 2;
|
|
@@ -74936,6 +74940,17 @@ function judgePair(args) {
|
|
|
74936
74940
|
reason: `different dimensions (prod ${fmtSize(diff.prodSize)}, cand ${fmtSize(diff.candSize)}) — the comparison would only look at the intersection`
|
|
74937
74941
|
};
|
|
74938
74942
|
}
|
|
74943
|
+
const comparedPixels = diff.width * diff.height;
|
|
74944
|
+
if (comparedPixels < MIN_COMPARABLE_PIXELS) {
|
|
74945
|
+
return {
|
|
74946
|
+
...base,
|
|
74947
|
+
size,
|
|
74948
|
+
noiseFloorPixels,
|
|
74949
|
+
maskedCoverage,
|
|
74950
|
+
verdict: "inconclusive",
|
|
74951
|
+
reason: `only ${comparedPixels} pixels were compared (${diff.width}×${diff.height}) — the selector resolves to something too small to be a verdict about the page`
|
|
74952
|
+
};
|
|
74953
|
+
}
|
|
74939
74954
|
const analysis = analyzeHeatmapRegions(paths.diff, { minComponentPixels: 1 });
|
|
74940
74955
|
return {
|
|
74941
74956
|
...base,
|
|
@@ -74957,7 +74972,10 @@ function explainHotspots(hotspots, prod, cand, paths, prodBoxTree, candBoxTree)
|
|
|
74957
74972
|
return [];
|
|
74958
74973
|
const p = prodBoxTree;
|
|
74959
74974
|
const c = candBoxTree;
|
|
74960
|
-
const paired = p?.found && c?.found ? diffBoxTrees(p.nodes, c.nodes, {
|
|
74975
|
+
const paired = p?.found && c?.found ? diffBoxTrees(p.nodes, c.nodes, {
|
|
74976
|
+
truncated: p.truncated || c.truncated,
|
|
74977
|
+
tolerancePx: 0
|
|
74978
|
+
}) : null;
|
|
74961
74979
|
return attributeHotspots({
|
|
74962
74980
|
hotspots,
|
|
74963
74981
|
nodes: p?.found ? p.nodes : [],
|
|
@@ -75016,31 +75034,10 @@ async function captureSide(browser, args) {
|
|
|
75016
75034
|
await page.waitForLoadState("networkidle", { timeout: 8000 }).catch(() => {
|
|
75017
75035
|
return;
|
|
75018
75036
|
});
|
|
75019
|
-
|
|
75020
|
-
|
|
75021
|
-
|
|
75022
|
-
|
|
75023
|
-
await Promise.race([
|
|
75024
|
-
stabilizeCarousels(page).catch(() => {
|
|
75025
|
-
return;
|
|
75026
|
-
}),
|
|
75027
|
-
new Promise((r) => setTimeout(r, 3000))
|
|
75028
|
-
]);
|
|
75029
|
-
if (!await isAlreadyOnScreen(page, args.selector)) {
|
|
75030
|
-
const scrollBudget = 30000;
|
|
75031
|
-
await Promise.race([
|
|
75032
|
-
scrollFullPage(page, scrollBudget).catch(() => {
|
|
75033
|
-
return;
|
|
75034
|
-
}),
|
|
75035
|
-
new Promise((r) => setTimeout(r, scrollBudget + 2000))
|
|
75036
|
-
]);
|
|
75037
|
-
await Promise.race([
|
|
75038
|
-
waitForSkeletonsToResolve(page, 5000).catch(() => {
|
|
75039
|
-
return;
|
|
75040
|
-
}),
|
|
75041
|
-
new Promise((r) => setTimeout(r, 5000))
|
|
75042
|
-
]);
|
|
75043
|
-
}
|
|
75037
|
+
await settlePage(page, {
|
|
75038
|
+
waitMs: args.waitMs,
|
|
75039
|
+
scroll: !await isAlreadyOnScreen(page, args.selector)
|
|
75040
|
+
});
|
|
75044
75041
|
side.devicePixelRatio = await page.evaluate(() => window.devicePixelRatio);
|
|
75045
75042
|
side.fontsStatus = await page.evaluate(() => document.fonts?.status ?? "unknown");
|
|
75046
75043
|
if (args.selector) {
|
|
@@ -75056,9 +75053,14 @@ async function captureSide(browser, args) {
|
|
|
75056
75053
|
side.screenshot = args.outPath;
|
|
75057
75054
|
} else {
|
|
75058
75055
|
await page.screenshot({ path: args.outPath, fullPage: true, animations: "disabled" });
|
|
75056
|
+
const clipped = await wasClipped(page, args.outPath);
|
|
75057
|
+
if (clipped) {
|
|
75058
|
+
side.error = clipped;
|
|
75059
|
+
return { side, repeatScreenshot, repeatError: clipped, boxTree };
|
|
75060
|
+
}
|
|
75059
75061
|
side.screenshot = args.outPath;
|
|
75060
75062
|
}
|
|
75061
|
-
boxTree = await readBoxTree(page, args.selector ?? "body").catch(() => {
|
|
75063
|
+
boxTree = await readBoxTree(page, args.selector ?? "body", args.selector ? {} : { maxNodes: 4000, maxDepth: 25 }).catch(() => {
|
|
75062
75064
|
return;
|
|
75063
75065
|
});
|
|
75064
75066
|
side.imageHosts = await readImageHosts(page, args.selector);
|
|
@@ -75088,6 +75090,19 @@ async function captureSide(browser, args) {
|
|
|
75088
75090
|
}
|
|
75089
75091
|
return { side, repeatScreenshot, repeatError, boxTree };
|
|
75090
75092
|
}
|
|
75093
|
+
async function wasClipped(page, pngPath) {
|
|
75094
|
+
try {
|
|
75095
|
+
const expected = await page.evaluate(() => document.documentElement.scrollHeight * window.devicePixelRatio);
|
|
75096
|
+
const actual = readPngSize(pngPath)?.height;
|
|
75097
|
+
if (!actual || !expected)
|
|
75098
|
+
return null;
|
|
75099
|
+
if (actual >= expected - 4)
|
|
75100
|
+
return null;
|
|
75101
|
+
return `the full-page capture stopped at ${actual}px of ${Math.round(expected)}px — the page is taller than the screenshot surface, so its lower part was never compared`;
|
|
75102
|
+
} catch {
|
|
75103
|
+
return null;
|
|
75104
|
+
}
|
|
75105
|
+
}
|
|
75091
75106
|
async function isAlreadyOnScreen(page, selector) {
|
|
75092
75107
|
if (!selector)
|
|
75093
75108
|
return false;
|
|
@@ -75319,16 +75334,7 @@ async function gatherStates(browser, opts) {
|
|
|
75319
75334
|
await page.waitForLoadState("networkidle", { timeout: 8000 }).catch(() => {
|
|
75320
75335
|
return;
|
|
75321
75336
|
});
|
|
75322
|
-
|
|
75323
|
-
await page.waitForTimeout(opts.waitMs);
|
|
75324
|
-
await reloadIfOptionalFonts(page, opts.waitMs);
|
|
75325
|
-
out.settle = await waitForLayoutStable(page);
|
|
75326
|
-
await Promise.race([
|
|
75327
|
-
stabilizeCarousels(page).catch(() => {
|
|
75328
|
-
return;
|
|
75329
|
-
}),
|
|
75330
|
-
new Promise((r) => setTimeout(r, 3000))
|
|
75331
|
-
]);
|
|
75337
|
+
out.settle = (await settlePage(page, { waitMs: opts.waitMs, scroll: false })).settle;
|
|
75332
75338
|
out.motion = await readMotion(page, opts.selector);
|
|
75333
75339
|
const base = await readBoxTree(page, opts.selector);
|
|
75334
75340
|
if (!base.found) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/parity",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.40",
|
|
4
4
|
"description": "E2E parity validator for site migrations. Compares prod vs cand and reports UI, functional, SEO, visual, and Web Vitals deltas with an LLM-ranked HTML report.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|