@decocms/parity 0.33.60 → 0.33.61

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 +64 -14
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -46644,6 +46644,24 @@ function median(values) {
46644
46644
  const mid = Math.floor(clean.length / 2);
46645
46645
  return clean.length % 2 ? clean[mid] : (clean[mid - 1] + clean[mid]) / 2;
46646
46646
  }
46647
+ function spreadOf(values) {
46648
+ const clean = values.filter((v) => Number.isFinite(v));
46649
+ if (clean.length === 0)
46650
+ return;
46651
+ return { minMs: Math.min(...clean), maxMs: Math.max(...clean), samples: clean.length };
46652
+ }
46653
+ function noiseWarning(prod, cand) {
46654
+ if (!prod?.ok || !cand?.ok || !prod.spread || !cand.spread)
46655
+ return null;
46656
+ if (prod.spread.samples < 2 || cand.spread.samples < 2)
46657
+ return null;
46658
+ const prodNoise = prod.spread.maxMs - prod.spread.minMs;
46659
+ const candNoise = cand.spread.maxMs - cand.spread.minMs;
46660
+ const deltaMs = Math.abs(cand.ms - prod.ms);
46661
+ const side = prodNoise >= candNoise ? "prod" : "cand";
46662
+ const noiseMs = Math.max(prodNoise, candNoise);
46663
+ return deltaMs <= noiseMs ? { side, noiseMs, deltaMs } : null;
46664
+ }
46647
46665
  function cssAttrEscape(s) {
46648
46666
  return s.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
46649
46667
  }
@@ -46979,7 +46997,7 @@ async function clickShelfProduct(page, ctx) {
46979
46997
  prefetched: nav.prefetched
46980
46998
  } : null;
46981
46999
  }
46982
- async function onePass(page, ctx, targets, paginations, measure) {
47000
+ async function onePass(page, ctx, targets, paginations, measure, paginationCapMs = 5000) {
46983
47001
  const shot = async (label, fullPage) => {
46984
47002
  if (!measure)
46985
47003
  return "";
@@ -47035,7 +47053,7 @@ async function onePass(page, ctx, targets, paginations, measure) {
47035
47053
  await page.evaluate(() => window.scrollTo(0, document.documentElement.scrollHeight)).catch(() => {
47036
47054
  return;
47037
47055
  });
47038
- const after = await waitForCardGrowth(page, before, 5000);
47056
+ const after = await waitForCardGrowth(page, before, paginationCapMs);
47039
47057
  if (after <= before) {
47040
47058
  pagination.push({
47041
47059
  step: `pagination-${i + 1}`,
@@ -47580,12 +47598,12 @@ async function runSideBenchmark(opts) {
47580
47598
  if (targets) {
47581
47599
  for (let r = 0;r < opts.warmupRuns; r++) {
47582
47600
  emit(`[${opts.viewport}/${opts.side}] aquecendo (borda + navegador) — passe ${r + 1}/${opts.warmupRuns}`);
47583
- await onePass(page, flowCtx, targets, opts.paginations, false);
47601
+ await onePass(page, flowCtx, targets, opts.paginations, false, opts.paginationCapMs);
47584
47602
  }
47585
47603
  const runs = Math.max(1, opts.measuredRuns);
47586
47604
  for (let r = 0;r < runs; r++) {
47587
47605
  emit(`[${opts.viewport}/${opts.side}] medindo navegação — passe ${r + 1}/${runs}`);
47588
- const res = await onePass(page, flowCtx, targets, opts.paginations, true);
47606
+ const res = await onePass(page, flowCtx, targets, opts.paginations, true, opts.paginationCapMs);
47589
47607
  measured.push(res);
47590
47608
  Object.assign(screenshots, res.screenshots);
47591
47609
  }
@@ -47649,6 +47667,7 @@ function aggregatePhase(step, samples) {
47649
47667
  return {
47650
47668
  step,
47651
47669
  ms: median(samples.map((s) => s.ms)),
47670
+ spread: spreadOf(samples.map((s) => s.ms)),
47652
47671
  url: samples[0]?.url,
47653
47672
  ok: samples.length > 0 && samples.every((s) => s.ok),
47654
47673
  note: (samples.find((s) => !s.ok) ?? samples.find((s) => s.note))?.note,
@@ -47662,6 +47681,7 @@ function aggregatePaginationTotal(measured) {
47662
47681
  return {
47663
47682
  step: "pagination",
47664
47683
  ms: median(perPass),
47684
+ spread: spreadOf(perPass),
47665
47685
  ok: measured.length > 0 && measured.every((m) => m.pagination.every((p) => p.ok)),
47666
47686
  note: `${measured[0]?.pagination.length ?? 0} scroll(s)`
47667
47687
  };
@@ -47674,6 +47694,7 @@ function aggregatePaginationSteps(measured) {
47674
47694
  out.push({
47675
47695
  step: `pagination-${i + 1}`,
47676
47696
  ms: median(atI.map((p) => p.ms)),
47697
+ spread: spreadOf(atI.map((p) => p.ms)),
47677
47698
  ok: atI.length > 0 && atI.every((p) => p.ok),
47678
47699
  note: (atI.find((p) => !p.ok) ?? atI[atI.length - 1])?.note
47679
47700
  });
@@ -48578,6 +48599,11 @@ function L(pt, en, lang) {
48578
48599
  function fmtMs(ms) {
48579
48600
  return ms >= 1000 ? `${(ms / 1000).toFixed(2)}s` : `${Math.round(ms)}ms`;
48580
48601
  }
48602
+ function fmtRange(s) {
48603
+ if (!s?.spread || s.spread.samples < 2)
48604
+ return "";
48605
+ return `${fmtMs(s.spread.minMs)}–${fmtMs(s.spread.maxMs)}`;
48606
+ }
48581
48607
  function domainOf(url) {
48582
48608
  try {
48583
48609
  return new URL(url).hostname.replace(/^www\./, "");
@@ -48652,7 +48678,8 @@ function renderStep(step, prod, cand, lang) {
48652
48678
  const c = candStep?.ms ?? 0;
48653
48679
  const max = Math.max(p, c, 1);
48654
48680
  const label = STEP_LABELS[step.step] ?? { pt: step.step, en: step.step };
48655
- const tone = deltaTone(p, c);
48681
+ const noise = noiseWarning(prodStep, candStep);
48682
+ const tone = noise ? DECK.muted : deltaTone(p, c);
48656
48683
  const shotKey = STEP_SHOT[step.step];
48657
48684
  const scroll = true;
48658
48685
  const naNote = candStep?.ms === 0 ? candStep.note : undefined;
@@ -48663,12 +48690,15 @@ function renderStep(step, prod, cand, lang) {
48663
48690
  <div class="step-note">${L(naNote, naNote, lang)}</div>
48664
48691
  </section>`;
48665
48692
  }
48666
- const bar = (ms, who, color) => `
48693
+ const bar = (ms, who, color, s) => {
48694
+ const r = fmtRange(s);
48695
+ return `
48667
48696
  <div class="bar-row">
48668
48697
  <span class="bar-who">${who}</span>
48669
48698
  <div class="bar-track"><div class="bar-fill" style="width:${ms / max * 100}%;background:${color}"></div></div>
48670
- <span class="bar-val" style="color:${color}">${fmtMs(ms)}</span>
48699
+ <span class="bar-val" style="color:${color}">${fmtMs(ms)}${r ? `<span class="bar-range">${r}</span>` : ""}</span>
48671
48700
  </div>`;
48701
+ };
48672
48702
  const subSteps = (() => {
48673
48703
  if (step.step !== "pagination")
48674
48704
  return "";
@@ -48702,6 +48732,8 @@ function renderStep(step, prod, cand, lang) {
48702
48732
  candStep?.prefetched === false ? "TanStack" : ""
48703
48733
  ].filter(Boolean).join(" + ");
48704
48734
  const coldNote = coldSides ? `<div class="step-note">${L(`Sem prefetch (${coldSides}): nenhum request Sec-Purpose: prefetch antes do clique — tempo de navegação fria.`, `No prefetch (${coldSides}): no Sec-Purpose: prefetch request before the click — cold navigation time.`, lang)}</div>` : "";
48735
+ const noiseWho = noise?.side === "cand" ? "TanStack" : "Fresh";
48736
+ const noiseNote = noise ? `<div class="step-note step-note-noise">~ ${L(`${noiseWho} variou ${fmtMs(noise.noiseMs)} entre as passadas; uma diferença de ${fmtMs(noise.deltaMs)} está dentro desse ruído — não dá para atribuir.`, `${noiseWho} varied by ${fmtMs(noise.noiseMs)} across passes; a ${fmtMs(noise.deltaMs)} difference is inside that noise — it cannot be attributed.`, lang)}</div>` : "";
48705
48737
  return `
48706
48738
  <section class="step${failed ? " step-failed" : ""}">
48707
48739
  <div class="step-head">
@@ -48709,12 +48741,13 @@ function renderStep(step, prod, cand, lang) {
48709
48741
  ${delta}
48710
48742
  </div>
48711
48743
  <div class="step-bars">
48712
- ${bar(p, "Fresh", prodFailed ? DECK.bad : DECK.faint)}
48713
- ${bar(c, "TanStack", candFailed ? DECK.bad : DECK.soft)}
48744
+ ${bar(p, "Fresh", prodFailed ? DECK.bad : DECK.faint, prodStep)}
48745
+ ${bar(c, "TanStack", candFailed ? DECK.bad : DECK.soft, candStep)}
48714
48746
  ${subSteps}
48715
48747
  </div>
48716
48748
  ${failed ? `<div class="step-note step-note-err">⚠ ${L(failNote, failNote, lang)}</div>` : candStep?.note ? `<div class="step-note">${L(candStep.note, candStep.note, lang)}</div>` : ""}
48717
48749
  ${coldNote}
48750
+ ${noiseNote}
48718
48751
  <div class="step-shots">
48719
48752
  ${figure(shotKey ? prod.screenshots[shotKey] : undefined, "Fresh", prodFailed ? DECK.bad : DECK.faint, prodStep?.url, scroll)}
48720
48753
  ${figure(shotKey ? cand.screenshots[shotKey] : undefined, "TanStack", candFailed ? DECK.bad : DECK.soft, candStep?.url, scroll)}
@@ -48770,7 +48803,7 @@ function renderViewport(report, viewport, lang) {
48770
48803
  const ps = prod.steps.find((s) => s.step === cs.step);
48771
48804
  const p = ps?.ms ?? 0;
48772
48805
  const label = STEP_LABELS[cs.step] ?? { pt: cs.step, en: cs.step };
48773
- const tone = deltaTone(p, cs.ms);
48806
+ const tone = noiseWarning(ps, cs) ? DECK.muted : deltaTone(p, cs.ms);
48774
48807
  return `<div class="tile">
48775
48808
  <span class="tile-val" style="color:${tone}">${fmtMs(cs.ms)}</span>
48776
48809
  <span class="tile-label">${L(label.pt, label.en, lang)}</span>
@@ -48796,6 +48829,7 @@ function renderViewport(report, viewport, lang) {
48796
48829
 
48797
48830
  <div class="eyebrow section-eyebrow">${L("OS CINCO PASSOS, LADO A LADO", "THE FIVE STEPS, SIDE BY SIDE", lang)}</div>
48798
48831
  <div class="stat-grid">${statTiles}</div>
48832
+ <p class="annotation">${report.measuredRuns < 2 ? L("⚠ 1 passada medida por lado: sem dispersão, nenhuma diferença pode ser separada do ruído.", "⚠ 1 measured pass per side: no spread, so no difference can be told apart from noise.", lang) : L("Faixas = mín–máx entre as passadas medidas. Só compare números deste mesmo relatório: entre execuções diferentes o Fresh chega a variar 2×.", "Ranges = min–max across the measured passes. Only compare numbers within this report: between separate runs Fresh varies by up to 2×.", lang)}</p>
48799
48833
 
48800
48834
  <div class="steps">${steps}</div>
48801
48835
 
@@ -48839,7 +48873,7 @@ function methodologyModal(report, lang) {
48839
48873
  </ul>
48840
48874
  <p>O hover (que dispara o prefetch do SPA) é aplicado igual nos dois sites e fica FORA do tempo — medimos só o clique→conteúdo.</p>
48841
48875
  <h3>4. Média</h3>
48842
- <p>Cada número é a <b>mediana de ${report.measuredRuns} medição(ões)</b> por lado, para cortar variância. O HAR completo da sessão fica salvo como artefato forense.</p>`;
48876
+ <p>Cada número é a <b>mediana de ${report.measuredRuns} medição(ões)</b> por lado, para cortar variância; a faixa mín–máx aparece ao lado. Quando a diferença entre os lados cabe dentro da variação de um deles, o passo fica cinza e é marcado como ruído. Os dois sites são medidos <b>ao mesmo tempo</b>, então oscilações de rede afetam ambos — mas números de execuções diferentes não são comparáveis entre si. O HAR completo da sessão fica salvo como artefato forense.</p>`;
48843
48877
  const en = `
48844
48878
  <h3>1. Scout (once)</h3>
48845
48879
  <p>An explorer validates, in the browser, a category (PLP) and a product (PDP) that <b>work on BOTH sites</b> — they render a real product, no error page. The SAME pages are used on both sides.</p>
@@ -48856,7 +48890,7 @@ function methodologyModal(report, lang) {
48856
48890
  </ul>
48857
48891
  <p>The hover (which triggers the SPA prefetch) is applied identically on both sides and kept OUT of the timing — we measure only click→content.</p>
48858
48892
  <h3>4. Median</h3>
48859
- <p>Each number is the <b>median of ${report.measuredRuns} measurement(s)</b> per side, to cut variance. The full session HAR is saved as a forensic artifact.</p>`;
48893
+ <p>Each number is the <b>median of ${report.measuredRuns} measurement(s)</b> per side, to cut variance; the min–max range is shown next to it. When the difference between the sides fits inside either side's own variation, the step is greyed out and marked as noise. Both sites are measured <b>at the same time</b>, so network swings hit both — but numbers from separate runs are not comparable. The full session HAR is saved as a forensic artifact.</p>`;
48860
48894
  return `<div class="modal-back" id="infoModal">
48861
48895
  <div class="modal">
48862
48896
  <button class="mclose" id="infoClose" type="button" aria-label="fechar">×</button>
@@ -48993,6 +49027,8 @@ ${report.favicon ? `<link rel="icon" href="${esc(report.favicon)}"/>` : ""}
48993
49027
  /* failures */
48994
49028
  .step-failed{border-color:rgba(212,61,61,0.35);box-shadow:0 0 0 1px rgba(212,61,61,0.12) inset}
48995
49029
  .step-note-err{background:rgba(212,61,61,0.06);border-color:rgba(212,61,61,0.25);color:#a5302f}
49030
+ .bar-range{display:block;font-size:11px;font-weight:400;color:var(--faint)}
49031
+ .step-note-noise{color:var(--muted);font-style:italic}
48996
49032
  .warn-banner{margin:18px 0 4px;padding:14px 18px;border-radius:14px;background:rgba(212,61,61,0.07);
48997
49033
  border:1px solid rgba(212,61,61,0.3);color:#a5302f;font-size:14px;line-height:1.55}
48998
49034
  .warn-banner b{color:#8f2624}
@@ -49133,6 +49169,7 @@ async function benchmarkCommand(opts) {
49133
49169
  const warmupRuns = num(opts.warmupRuns, 2);
49134
49170
  const measuredRuns = Math.max(1, num(opts.measuredRuns, 3));
49135
49171
  const paginations = num(opts.paginations, 3);
49172
+ const paginationCapMs = num(opts.paginationCapMs ?? 5000, 5000) || 5000;
49136
49173
  const runVitals = opts.vitals !== false;
49137
49174
  const lang = opts.lang === "en" ? "en" : "pt";
49138
49175
  const rc = loadParityRc();
@@ -49194,6 +49231,7 @@ async function benchmarkCommand(opts) {
49194
49231
  warmupRuns,
49195
49232
  measuredRuns,
49196
49233
  paginations,
49234
+ paginationCapMs,
49197
49235
  runVitals,
49198
49236
  onEvent
49199
49237
  });
@@ -49288,6 +49326,11 @@ async function benchmarkCommand(opts) {
49288
49326
  function fmt(ms) {
49289
49327
  return ms >= 1000 ? `${(ms / 1000).toFixed(2)}s` : `${Math.round(ms)}ms`;
49290
49328
  }
49329
+ function range(s) {
49330
+ if (!s?.spread || s.spread.samples < 2)
49331
+ return "";
49332
+ return chalk5.dim(` (${fmt(s.spread.minMs)}–${fmt(s.spread.maxMs)})`);
49333
+ }
49291
49334
  function printSummary2(report) {
49292
49335
  for (const viewport of report.viewports) {
49293
49336
  const prod = report.sides.find((s) => s.viewport === viewport && s.side === "prod");
@@ -49303,9 +49346,16 @@ function printSummary2(report) {
49303
49346
  const ps = prod.steps.find((s) => s.step === cs.step);
49304
49347
  const flag = ps?.ok === false || cs.ok === false ? chalk5.red(` ✗ ERRO: ${cs.ok === false ? "cand" : "prod"} ${cs.note ?? ""}`) : "";
49305
49348
  const cold = [ps?.prefetched === false ? "prod" : "", cs.prefetched === false ? "cand" : ""].filter(Boolean).join("+");
49306
- console.log(` ${cs.step.padEnd(16)} prod ${fmt(ps?.ms ?? 0).padStart(8)} cand ${fmt(cs.ms).padStart(8)}${flag}${cold ? chalk5.dim(` sem prefetch: ${cold}`) : ""}`);
49349
+ const noise = noiseWarning(ps, cs);
49350
+ console.log(` ${cs.step.padEnd(16)} prod ${fmt(ps?.ms ?? 0).padStart(8)}${range(ps)} cand ${fmt(cs.ms).padStart(8)}${range(cs)}${flag}${cold ? chalk5.dim(` sem prefetch: ${cold}`) : ""}`);
49351
+ if (noise) {
49352
+ console.log(chalk5.yellow(` ~ ${noise.side} variou ${fmt(noise.noiseMs)} entre passes; a diferença de ${fmt(noise.deltaMs)} está dentro desse ruído — não é resultado`));
49353
+ }
49307
49354
  }
49308
49355
  }
49356
+ console.log("");
49357
+ console.log(chalk5.dim(report.measuredRuns < 2 ? " ⚠ 1 passe medido por lado: sem dispersão, nenhum delta pode ser separado do ruído. Use --measured-runs ≥ 3." : " faixa = min–max entre os passes medidos. Números de runs diferentes não são comparáveis (o prod deriva até 2x entre runs)."));
49358
+ console.log(chalk5.dim(" Para medir uma mudança do candidato: --prod <cand-antes> --cand <cand-depois> no MESMO run."));
49309
49359
  const failed = report.sides.flatMap((s) => s.steps.filter((st) => st.ok === false).map((st) => `${s.side}/${st.step}`));
49310
49360
  if (failed.length > 0) {
49311
49361
  console.log("");
@@ -78559,7 +78609,7 @@ program.command("benchmark").description([
78559
78609
  "a HAR, measures Web Vitals with Lighthouse, and emits ONE self-contained HTML report",
78560
78610
  "(PT/EN toggle) you can share with a client."
78561
78611
  ].join(`
78562
- `)).requiredOption("--prod <url>", "Production URL (Fresh — the 'before')").requiredOption("--cand <url>", "Candidate URL (TanStack — the 'after')").option("--viewports <list>", "mobile,desktop (pick one or both)", "mobile,desktop").option("--warmup-runs <n>", "Journey passes to warm caches before measuring", "2").option("--measured-runs <n>", "Measured passes per side (median, kills variance)", "3").option("--paginations <n>", "How many times to scroll/paginate the PLP", "3").option("--plp <path>", "Pin the PLP path (skip auto-discovery), e.g. /roupas — useful to force a clothing category with real color variants").option("--journey <type>", "Journey shape: commerce (home→PLP→PDP→variant) | content (home→page A→page B, for blog/custom sites with no PLP/PDP). Auto-detected from the platform when omitted. Issue #251.").option("--cep <cep>", "CEP (kept for overlay/region dismissal parity)", "01310-100").option("--output <dir>", "Output directory for runs/<id>/", "./parity-output").option("--no-vitals", "Skip the Lighthouse web-vitals pass (faster iteration)").option("--no-auto-selectors", "Skip LLM-based selector discovery").option("--lang <pt|en>", "Default report language (toggle switches live)", "pt").option("--open", "Open the HTML report when done", false).option("--pt", "Tell the LLM to respond in Brazilian Portuguese. Issue #67.").action(async (opts) => {
78612
+ `)).requiredOption("--prod <url>", "Production URL (Fresh — the 'before')").requiredOption("--cand <url>", "Candidate URL (TanStack — the 'after')").option("--viewports <list>", "mobile,desktop (pick one or both)", "mobile,desktop").option("--warmup-runs <n>", "Journey passes to warm caches before measuring", "2").option("--measured-runs <n>", "Measured passes per side (median, kills variance)", "3").option("--paginations <n>", "How many times to scroll/paginate the PLP", "3").option("--pagination-cap-ms <n>", "How long one scroll waits for new cards; slower loads are truncated to this (#274)", "5000").option("--plp <path>", "Pin the PLP path (skip auto-discovery), e.g. /roupas — useful to force a clothing category with real color variants").option("--journey <type>", "Journey shape: commerce (home→PLP→PDP→variant) | content (home→page A→page B, for blog/custom sites with no PLP/PDP). Auto-detected from the platform when omitted. Issue #251.").option("--cep <cep>", "CEP (kept for overlay/region dismissal parity)", "01310-100").option("--output <dir>", "Output directory for runs/<id>/", "./parity-output").option("--no-vitals", "Skip the Lighthouse web-vitals pass (faster iteration)").option("--no-auto-selectors", "Skip LLM-based selector discovery").option("--lang <pt|en>", "Default report language (toggle switches live)", "pt").option("--open", "Open the HTML report when done", false).option("--pt", "Tell the LLM to respond in Brazilian Portuguese. Issue #67.").action(async (opts) => {
78563
78613
  if (opts.pt) {
78564
78614
  await Promise.resolve().then(() => init_client());
78565
78615
  setLlmLanguage("pt");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/parity",
3
- "version": "0.33.60",
3
+ "version": "0.33.61",
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",