@decocms/parity 0.35.1 → 0.35.2

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 +28 -4
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -60676,12 +60676,12 @@ Consider to rely on 'then' or 'done' mode instead.`);
60676
60676
  if (!win.navigator || _typeof(win.navigator) !== "object") {
60677
60677
  return {};
60678
60678
  }
60679
- var { navigator, innerHeight, innerWidth } = win;
60679
+ var { navigator, innerHeight: innerHeight2, innerWidth: innerWidth2 } = win;
60680
60680
  var _ref90 = getOrientation(win) || {}, { angle, type: type2 } = _ref90;
60681
60681
  return {
60682
60682
  userAgent: navigator.userAgent,
60683
- windowWidth: innerWidth,
60684
- windowHeight: innerHeight,
60683
+ windowWidth: innerWidth2,
60684
+ windowHeight: innerHeight2,
60685
60685
  orientationAngle: angle,
60686
60686
  orientationType: type2
60687
60687
  };
@@ -119876,6 +119876,25 @@ async function scoreFrames(page, base, frames) {
119876
119876
  return out;
119877
119877
  }, { base, frames });
119878
119878
  }
119879
+ function visibleImagesInPage() {
119880
+ const vw = innerWidth;
119881
+ const vh = innerHeight;
119882
+ return [...document.querySelectorAll("img")].filter((img) => {
119883
+ const r = img.getBoundingClientRect();
119884
+ if (r.width < 120)
119885
+ return false;
119886
+ const x = r.left + r.width / 2;
119887
+ const y = r.top + r.height / 2;
119888
+ if (x < 0 || x >= vw || y < 0 || y >= vh)
119889
+ return false;
119890
+ const top = document.elementFromPoint(x, y);
119891
+ return !!top && (top === img || img.contains(top) || top.contains(img));
119892
+ }).sort((a, b) => {
119893
+ const ra = a.getBoundingClientRect();
119894
+ const rb = b.getBoundingClientRect();
119895
+ return rb.width * rb.height - ra.width * ra.height;
119896
+ }).slice(0, 3).map((img) => (img.currentSrc || img.src).split("/").pop()?.split("?")[0] ?? "");
119897
+ }
119879
119898
  var SKELETON = "[class*='skeleton' i], .animate-pulse, [aria-busy='true'], .loading";
119880
119899
  async function rerenderCommand(opts) {
119881
119900
  if (!opts.selector && !opts.text) {
@@ -119956,6 +119975,7 @@ async function rerenderCommand(opts) {
119956
119975
  await cdp.send("Page.startScreencast", { format: "jpeg", quality: 50, everyNthFrame: 1 });
119957
119976
  await page.waitForTimeout(400);
119958
119977
  const target = (opts.selector ? page.locator(opts.selector) : page.getByText(opts.text, { exact: true })).filter({ visible: true }).first();
119978
+ const imagesBefore = await page.evaluate(visibleImagesInPage).catch(() => []);
119959
119979
  t0 = Date.now();
119960
119980
  const clicked = await target.click({ timeout: 5000 }).then(() => true).catch(() => false);
119961
119981
  if (!clicked) {
@@ -119967,6 +119987,7 @@ async function rerenderCommand(opts) {
119967
119987
  return;
119968
119988
  });
119969
119989
  page.off("request", onReq);
119990
+ const imagesAfter = await page.evaluate(visibleImagesInPage).catch(() => []);
119970
119991
  const dom = await page.evaluate(() => {
119971
119992
  const w = window;
119972
119993
  const before = w.__before;
@@ -120001,7 +120022,8 @@ async function rerenderCommand(opts) {
120001
120022
  skeletons: Object.entries(dom.skeletons).map(([region, count]) => ({ region, count })),
120002
120023
  flashes,
120003
120024
  settledAt,
120004
- frames: post.length
120025
+ frames: post.length,
120026
+ visibleImages: { before: imagesBefore, after: imagesAfter }
120005
120027
  };
120006
120028
  if (opts.sheet && base) {
120007
120029
  const pick = new Set([0]);
@@ -120053,6 +120075,8 @@ async function rerenderCommand(opts) {
120053
120075
  console.log(` ${r.remounted ? chalk41.red("REMOUNTED") : "changed "} ${r.region.padEnd(48)} +${r.added}/-${r.removed} attrs ${r.attrs} text ${r.text}`);
120054
120076
  for (const s of report.skeletons)
120055
120077
  console.log(chalk41.yellow(` skeletons ×${s.count} in ${s.region}`));
120078
+ const [b0, a0] = [report.visibleImages.before[0], report.visibleImages.after[0]];
120079
+ console.log(b0 === a0 ? ` main visible image unchanged: ${a0 ?? "none"}` : ` main visible image: ${b0 ?? "none"} → ${a0 ?? "none"}`);
120056
120080
  for (const f of flashes)
120057
120081
  console.log(chalk41.red(` white flash +${f.from}–${f.to}ms (peak ${f.peakWhite.toFixed(0)}% white)`));
120058
120082
  console.log(chalk41.dim(` settled at +${settledAt ?? "?"}ms · ${post.length} frames${opts.sheet ? ` · sheet ${opts.sheet}` : ""}`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/parity",
3
- "version": "0.35.1",
3
+ "version": "0.35.2",
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",