@decocms/parity 0.33.39 → 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.
Files changed (2) hide show
  1. package/dist/cli.js +42 -4
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -64637,7 +64637,7 @@ function diffBoxTrees(prod, cand, opts = {}) {
64637
64637
  onlyInProd: onlyInProd.map(brief("prod")),
64638
64638
  onlyInCand: onlyInCand.map(brief("cand")),
64639
64639
  deltas: deltas.slice(0, maxDeltas),
64640
- truncated: opts.truncated ?? false
64640
+ truncated: (opts.truncated ?? false) || deltas.length > maxDeltas
64641
64641
  };
64642
64642
  }
64643
64643
  function isBoxTreeInconclusive(diff) {
@@ -74624,8 +74624,12 @@ function parseViewports2(raw) {
74624
74624
  const entries = (raw.trim() === "all" ? ALL_VIEWPORTS : raw).split(",").map((s) => s.trim()).filter((s) => s.length > 0);
74625
74625
  if (entries.length === 0)
74626
74626
  return "--viewports is empty";
74627
+ const seen = new Set;
74627
74628
  const specs = [];
74628
74629
  for (const entry of entries) {
74630
+ if (seen.has(entry))
74631
+ return `viewport '${entry}' appears twice in --viewports`;
74632
+ seen.add(entry);
74629
74633
  const named = parseViewport3(entry);
74630
74634
  if (named) {
74631
74635
  specs.push({ label: entry, viewport: named, size: null });
@@ -74652,9 +74656,10 @@ function aggregateVerdict(results) {
74652
74656
  const differing = results.filter((r) => r.verdict === "differs");
74653
74657
  if (differing.length > 0) {
74654
74658
  const total = differing.reduce((sum, r) => sum + (r.diffPixels ?? 0), 0);
74659
+ const count = total > 0 ? ` (${total} pixels in total)` : "";
74655
74660
  return {
74656
74661
  verdict: "differs",
74657
- reason: `${differing.length}/${results.length} viewports differ (${total} pixels in total): ${differing.map((r) => r.label).join(", ")}`
74662
+ reason: `${differing.length}/${results.length} viewports differ${count}: ${differing.map((r) => r.label).join(", ")}`
74658
74663
  };
74659
74664
  }
74660
74665
  const unread = results.filter((r) => r.verdict === "inconclusive");
@@ -74666,6 +74671,7 @@ function aggregateVerdict(results) {
74666
74671
  }
74667
74672
  return { verdict: "identical" };
74668
74673
  }
74674
+ var MIN_COMPARABLE_PIXELS = 100;
74669
74675
  var EXIT_IDENTICAL = 0;
74670
74676
  var EXIT_DIFFERS = 1;
74671
74677
  var EXIT_INCONCLUSIVE = 2;
@@ -74934,6 +74940,17 @@ function judgePair(args) {
74934
74940
  reason: `different dimensions (prod ${fmtSize(diff.prodSize)}, cand ${fmtSize(diff.candSize)}) — the comparison would only look at the intersection`
74935
74941
  };
74936
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
+ }
74937
74954
  const analysis = analyzeHeatmapRegions(paths.diff, { minComponentPixels: 1 });
74938
74955
  return {
74939
74956
  ...base,
@@ -74955,7 +74972,10 @@ function explainHotspots(hotspots, prod, cand, paths, prodBoxTree, candBoxTree)
74955
74972
  return [];
74956
74973
  const p = prodBoxTree;
74957
74974
  const c = candBoxTree;
74958
- const paired = p?.found && c?.found ? diffBoxTrees(p.nodes, c.nodes, { truncated: p.truncated || c.truncated }) : null;
74975
+ const paired = p?.found && c?.found ? diffBoxTrees(p.nodes, c.nodes, {
74976
+ truncated: p.truncated || c.truncated,
74977
+ tolerancePx: 0
74978
+ }) : null;
74959
74979
  return attributeHotspots({
74960
74980
  hotspots,
74961
74981
  nodes: p?.found ? p.nodes : [],
@@ -75033,9 +75053,14 @@ async function captureSide(browser, args) {
75033
75053
  side.screenshot = args.outPath;
75034
75054
  } else {
75035
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
+ }
75036
75061
  side.screenshot = args.outPath;
75037
75062
  }
75038
- boxTree = await readBoxTree(page, args.selector ?? "body").catch(() => {
75063
+ boxTree = await readBoxTree(page, args.selector ?? "body", args.selector ? {} : { maxNodes: 4000, maxDepth: 25 }).catch(() => {
75039
75064
  return;
75040
75065
  });
75041
75066
  side.imageHosts = await readImageHosts(page, args.selector);
@@ -75065,6 +75090,19 @@ async function captureSide(browser, args) {
75065
75090
  }
75066
75091
  return { side, repeatScreenshot, repeatError, boxTree };
75067
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
+ }
75068
75106
  async function isAlreadyOnScreen(page, selector) {
75069
75107
  if (!selector)
75070
75108
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/parity",
3
- "version": "0.33.39",
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",