@decocms/parity 0.26.14 → 0.26.16

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 +508 -16
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -41723,8 +41723,13 @@ var ParityRc = z.object({
41723
41723
  addToCartConfirmMs: z.number().optional(),
41724
41724
  cartRevealTimeoutMs: z.number().optional()
41725
41725
  });
41726
+ var ExpectedDivergence = z.object({
41727
+ match: z.string(),
41728
+ note: z.string()
41729
+ });
41726
41730
  var ParityIgnore = z.object({
41727
41731
  ignoreSelectorsVisual: z.array(z.string()).default([]),
41732
+ expectedDivergences: z.array(ExpectedDivergence).optional(),
41728
41733
  ignoreRequestPatterns: z.array(z.string()).default([]),
41729
41734
  ignoreConsolePatterns: z.array(z.string()).default([]),
41730
41735
  ignoreMetaKeys: z.array(z.string()).default([]),
@@ -53253,6 +53258,35 @@ async function visualSemanticDiff(input) {
53253
53258
  }));
53254
53259
  }
53255
53260
 
53261
+ // src/diff/expected-divergence.ts
53262
+ function matchExpectedDivergence(haystacks, expected) {
53263
+ if (expected.length === 0)
53264
+ return null;
53265
+ const text3 = haystacks.filter((h) => Boolean(h)).join(" ").toLowerCase();
53266
+ if (!text3)
53267
+ return null;
53268
+ for (const e of expected) {
53269
+ const needle = e.match.trim().toLowerCase();
53270
+ if (!needle)
53271
+ continue;
53272
+ if (text3.includes(needle))
53273
+ return e;
53274
+ }
53275
+ return null;
53276
+ }
53277
+ function partitionExpectedSections(sections, expected) {
53278
+ const reportable = [];
53279
+ const accepted = [];
53280
+ for (const section of sections) {
53281
+ const hit = matchExpectedDivergence([section], expected);
53282
+ if (hit)
53283
+ accepted.push({ section, note: hit.note });
53284
+ else
53285
+ reportable.push(section);
53286
+ }
53287
+ return { reportable, accepted };
53288
+ }
53289
+
53256
53290
  // src/checks/lib/parity-cache.ts
53257
53291
  import { createHash as createHash2 } from "node:crypto";
53258
53292
  import { existsSync as existsSync7, mkdirSync as mkdirSync7, readFileSync as readFileSync10, writeFileSync as writeFileSync9 } from "node:fs";
@@ -53401,6 +53435,7 @@ async function visualRegressionKeyframes(ctx) {
53401
53435
  const diffDir = join12(ctx.outDir, "screenshots");
53402
53436
  if (!existsSync8(diffDir))
53403
53437
  mkdirSync8(diffDir, { recursive: true });
53438
+ const expectedDivergences = ctx.ignore.expectedDivergences ?? [];
53404
53439
  const useLlm = isLlmAvailable();
53405
53440
  const maxLlmCalls = getMaxLlmCalls();
53406
53441
  let llmCallsUsed = 0;
@@ -53573,16 +53608,30 @@ async function visualRegressionKeyframes(ctx) {
53573
53608
  llmError,
53574
53609
  cachedAt
53575
53610
  });
53576
- if (p.sectionsOnlyInProd.length > 0) {
53611
+ const sectionSplit = partitionExpectedSections(p.sectionsOnlyInProd, expectedDivergences);
53612
+ if (sectionSplit.accepted.length > 0) {
53613
+ issues.push({
53614
+ id: `visual:sections-expected:${p.pair.key}`,
53615
+ severity: "low",
53616
+ category: "visual",
53617
+ page: p.pair.key,
53618
+ check: "visual-regression-keyframes",
53619
+ inconclusive: true,
53620
+ summary: `${sectionSplit.accepted.length} section(s) ausente(s) em cand por decisão: ${sectionSplit.accepted.map((a) => a.section).join(", ")}`,
53621
+ details: sectionSplit.accepted.map((a) => `- ${a.section}: ${a.note}`).join(`
53622
+ `)
53623
+ });
53624
+ }
53625
+ if (sectionSplit.reportable.length > 0) {
53577
53626
  issues.push({
53578
53627
  id: `visual:sections:${p.pair.key}`,
53579
53628
  severity: "high",
53580
53629
  category: "visual",
53581
53630
  page: p.pair.key,
53582
53631
  check: "visual-regression-keyframes",
53583
- summary: `${p.sectionsOnlyInProd.length} section(s) ausente(s) em cand: ${p.sectionsOnlyInProd.join(", ")}`,
53632
+ summary: `${sectionSplit.reportable.length} section(s) ausente(s) em cand: ${sectionSplit.reportable.join(", ")}`,
53584
53633
  details: `Sections detectadas no DOM de prod via data-section, mas ausentes em cand:
53585
- ${p.sectionsOnlyInProd.map((s) => `- ${s}`).join(`
53634
+ ${sectionSplit.reportable.map((s) => `- ${s}`).join(`
53586
53635
  `)}
53587
53636
 
53588
53637
  Provavelmente faltam em registerSections() em src/setup.ts, ou o CMS não está resolvendo essas keys em cand.`,
@@ -53594,16 +53643,20 @@ Provavelmente faltam em registerSections() em src/setup.ts, ou o CMS não está
53594
53643
  });
53595
53644
  }
53596
53645
  for (const [i, d] of differences.entries()) {
53646
+ const accepted = matchExpectedDivergence([d.description, d.region], expectedDivergences);
53597
53647
  issues.push({
53598
53648
  id: `visual:semantic:${p.pair.key}:${i}`,
53599
- severity: severityForDiff(d),
53649
+ severity: accepted ? "low" : severityForDiff(d),
53600
53650
  category: "visual",
53601
53651
  page: p.pair.key,
53602
53652
  check: "visual-regression-keyframes",
53603
- summary: `[${d.region}] ${d.description}`,
53653
+ ...accepted ? { inconclusive: true } : {},
53654
+ summary: `[${d.region}] ${d.description}${accepted ? " (divergência esperada)" : ""}`,
53604
53655
  details: `Tipo: ${d.type}
53605
53656
  Região: ${d.region}
53606
- Severidade: ${d.severity}`,
53657
+ Severidade: ${d.severity}${accepted ? `
53658
+
53659
+ Decisão registrada: ${accepted.note}` : ""}`,
53607
53660
  evidence: [
53608
53661
  { kind: "screenshot", path: p.pair.prod.screenshotPath, label: "prod" },
53609
53662
  { kind: "screenshot", path: p.pair.cand.screenshotPath, label: "cand" },
@@ -67286,10 +67339,426 @@ function promptCommand(runId, opts) {
67286
67339
  }
67287
67340
 
67288
67341
  // src/commands/report.ts
67289
- import { existsSync as existsSync20, readFileSync as readFileSync23 } from "node:fs";
67342
+ import { existsSync as existsSync20, readFileSync as readFileSync23, writeFileSync as writeFileSync26 } from "node:fs";
67343
+ import { join as join31 } from "node:path";
67290
67344
  import chalk23 from "chalk";
67291
67345
  import open2 from "open";
67292
67346
 
67347
+ // src/report/deck-template.ts
67348
+ var DECK_CSS = `
67349
+ /* ── design tokens (identical to report-components.html) ───────────────── */
67350
+ :root{
67351
+ --bg:#ffffff;--ink:#282524;--muted:#78726e;--faint:#a6a09d;
67352
+ --border:rgba(40,37,36,0.09);--card:rgba(40,37,36,0.06);
67353
+ --soft:#8caa25;--forest:#07401a;--warn:#f0b613;--bad:#d43d3d;
67354
+ --lime:#d0ec1a;--lime-tint:#eff6cc;
67355
+ }
67356
+ *{box-sizing:border-box}
67357
+ html,body{height:100%;margin:0;overflow:hidden}
67358
+ body{color:var(--ink);background:var(--bg);
67359
+ font:14px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif;
67360
+ -webkit-font-smoothing:antialiased}
67361
+ .num{font-family:Georgia,"Times New Roman",serif;letter-spacing:-0.02em;
67362
+ font-variant-numeric:tabular-nums}
67363
+ .eyebrow{font-size:11px;font-weight:600;letter-spacing:.08em;text-transform:uppercase;
67364
+ color:var(--soft)}
67365
+ h1,h2,h3{font-weight:400;letter-spacing:-0.02em;margin:0}
67366
+ .annotation{color:var(--muted);font-size:14px;margin:6px 0 0}
67367
+ .dim{color:var(--faint)}
67368
+ .lime-ink{color:var(--forest)}
67369
+ code{background:#f4f2ef;padding:1px 5px;border-radius:5px;font-size:11.5px;color:var(--ink)}
67370
+
67371
+ /* ── deck shell ─────────────────────────────────────────────────────────── */
67372
+ .deck{display:flex;height:100vh;overflow-x:auto;overflow-y:hidden;
67373
+ scroll-snap-type:x mandatory;scroll-behavior:smooth}
67374
+ .deck::-webkit-scrollbar{height:0}
67375
+ .page{flex:0 0 100vw;width:100vw;height:100vh;scroll-snap-align:start;overflow-y:auto;
67376
+ padding:56px 6vw 40px;background:var(--bg)}
67377
+ .page:nth-child(even){background:#fdfdfc}
67378
+ .page-inner{max-width:1180px;margin:0 auto}
67379
+ .page-title{font-size:clamp(1.7rem,3.6vw,2.6rem);margin:6px 0 10px}
67380
+ .sub{font-size:12px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;
67381
+ color:var(--muted);margin:30px 0 10px}
67382
+
67383
+ /* ── top bar ────────────────────────────────────────────────────────────── */
67384
+ .nav{position:fixed;top:0;left:0;right:0;z-index:60;display:flex;align-items:center;gap:14px;
67385
+ padding:10px 6vw;background:rgba(255,255,255,.92);backdrop-filter:blur(8px);
67386
+ border-bottom:1px solid var(--border)}
67387
+ .nav .fav{width:22px;height:22px;border-radius:6px;border:1px solid var(--card);
67388
+ background:#fff;padding:2px;object-fit:contain}
67389
+ .nav b{font-size:13px;font-weight:600}
67390
+ .nav .spacer{flex:1}
67391
+ .dots{display:flex;gap:6px}
67392
+ .dot{width:22px;height:4px;border-radius:999px;background:rgba(40,37,36,.14);border:0;
67393
+ padding:0;cursor:pointer}
67394
+ .dot[aria-current="true"]{background:var(--forest)}
67395
+ .counter{font-size:12px;color:var(--muted);font-variant-numeric:tabular-nums;
67396
+ min-width:44px;text-align:right}
67397
+ .lang-toggle{border:1px solid rgba(40,37,36,0.18);background:#fff;border-radius:999px;
67398
+ padding:5px 12px;font-size:12px;font-weight:600;cursor:pointer;color:var(--ink)}
67399
+ .lang-toggle:hover{background:#faf9f7}
67400
+
67401
+ /* ── cover ──────────────────────────────────────────────────────────────── */
67402
+ .cover{display:flex;align-items:center}
67403
+ .cover-h1{font-size:clamp(2.2rem,6vw,4.2rem);line-height:1.02;margin:16px 0}
67404
+ .cover-lead{font-size:18px;color:var(--muted);max-width:60ch;line-height:1.6}
67405
+ .cover-meta{display:flex;gap:44px;flex-wrap:wrap;margin-top:38px}
67406
+ .cover-meta div{display:flex;flex-direction:column}
67407
+ .cover-meta b{font-family:Georgia,serif;font-size:2.4rem;letter-spacing:-0.02em;font-weight:400}
67408
+ .cover-meta small{color:var(--muted);font-size:12px;margin-top:2px}
67409
+ .hint{margin-top:46px;font-size:13px;color:var(--faint)}
67410
+
67411
+ /* ── tiles ──────────────────────────────────────────────────────────────── */
67412
+ .stat-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:14px}
67413
+ .tile{display:flex;flex-direction:column;gap:6px;padding:20px;border:1px solid var(--card);
67414
+ border-radius:14px;background:#fff}
67415
+ .tile-val{font-family:Georgia,serif;font-size:clamp(1.8rem,4vw,2.6rem);line-height:1;
67416
+ letter-spacing:-0.02em;font-variant-numeric:tabular-nums}
67417
+ .tile-label{font-size:14px}
67418
+ .tile-sub{font-size:12px;color:var(--muted)}
67419
+ .t-good{color:var(--forest)}.t-warn{color:#8a6708}.t-bad{color:var(--bad)}
67420
+
67421
+ /* ── tables ─────────────────────────────────────────────────────────────── */
67422
+ table.grid{width:100%;border-collapse:collapse;font-size:14px;margin-top:10px}
67423
+ table.grid th,table.grid td{text-align:left;padding:9px 10px;
67424
+ border-bottom:1px solid var(--border);vertical-align:top}
67425
+ table.grid thead th{font-size:10px;text-transform:uppercase;letter-spacing:.06em;
67426
+ color:var(--muted);font-weight:600;position:sticky;top:0;background:var(--bg)}
67427
+ table.compact{font-size:12.5px}
67428
+ table.compact td{padding:6px 8px}
67429
+
67430
+ /* ── status pills ───────────────────────────────────────────────────────── */
67431
+ .pill{display:inline-block;font-size:10.5px;font-weight:700;letter-spacing:.03em;
67432
+ padding:2px 8px;border-radius:999px;white-space:nowrap}
67433
+ .pill-good{background:var(--lime-tint);color:var(--forest)}
67434
+ .pill-lime{background:var(--lime);color:var(--forest)}
67435
+ .pill-warn{background:rgba(240,182,19,.16);color:#8a6708}
67436
+ .pill-bad{background:rgba(212,61,61,.1);color:#a5302f}
67437
+
67438
+ /* ── heat map ───────────────────────────────────────────────────────────── */
67439
+ .legend{display:flex;gap:18px;flex-wrap:wrap;margin:6px 0 22px;font-size:12px;
67440
+ color:var(--muted)}
67441
+ .lg{display:flex;align-items:center;gap:7px}
67442
+ .lg .cell{width:14px;height:14px;min-height:0;padding:0;border-radius:4px;display:block}
67443
+ .zone{margin-bottom:20px}
67444
+ .zone-head{display:flex;align-items:baseline;gap:10px;margin-bottom:8px}
67445
+ .zone-head b{font-size:13px}
67446
+ .zone-score{color:var(--faint);font-size:13px;font-family:Georgia,serif}
67447
+ .cells{display:grid;grid-template-columns:repeat(auto-fill,minmax(148px,1fr));gap:7px}
67448
+ .cell{min-height:52px;border-radius:9px;padding:9px 11px;display:flex;align-items:center;
67449
+ font-size:12px;line-height:1.25;border:1px solid transparent}
67450
+ .cell-ok{background:var(--lime-tint);color:var(--forest);border-color:rgba(7,64,26,.10)}
67451
+ .cell-new{background:var(--lime);color:var(--forest);border-color:rgba(7,64,26,.22);
67452
+ font-weight:600}
67453
+ .cell-warn{background:rgba(240,182,19,.18);color:#7d5d07;border-color:rgba(240,182,19,.34)}
67454
+ .cell-gap{background:rgba(212,61,61,.09);color:#9d2d2c;border-color:rgba(212,61,61,.2)}
67455
+
67456
+ /* ── side-by-side screenshot frames ─────────────────────────────────────── */
67457
+ .side-by-side{display:grid;grid-template-columns:1fr 1fr;gap:20px;margin-top:14px}
67458
+ .side-by-side .shot-view{max-height:70vh;overflow-y:auto}
67459
+ /* Phone captures are ~390px wide: kept near that width and taller, so the frame reads
67460
+ as a phone instead of an upscaled half-screen. */
67461
+ .side-by-side.phones{grid-template-columns:repeat(2,minmax(0,340px));
67462
+ justify-content:center;gap:36px}
67463
+ .side-by-side.phones .shot-view{max-height:76vh}
67464
+ .shot{margin:0;position:relative;border-radius:16px;overflow:hidden;background:#f6f4f1;
67465
+ border:1px solid var(--card);
67466
+ box-shadow:0 1px 2px rgba(40,37,36,0.04),0 12px 34px rgba(40,37,36,0.08)}
67467
+ .shot img{display:block;width:100%;height:auto}
67468
+ .shot-view{position:relative}
67469
+ .shot-tag{position:absolute;top:12px;left:12px;z-index:3;color:#fff;font-size:11px;
67470
+ font-weight:700;letter-spacing:0.04em;padding:4px 10px;border-radius:999px}
67471
+ .tag-prod{background:rgba(40,37,36,.6)}
67472
+ .tag-cand{background:var(--forest)}
67473
+ .shot-missing{min-height:320px;display:flex;align-items:center;justify-content:center;
67474
+ color:var(--faint);font-size:13px;text-align:center;padding:24px}
67475
+
67476
+ @media(max-width:900px){.side-by-side{grid-template-columns:1fr}}
67477
+ @media(prefers-reduced-motion:reduce){.deck{scroll-behavior:auto}}
67478
+ `;
67479
+ var DECK_JS = `
67480
+ // ── deck paging ───────────────────────────────────────────────────────────────
67481
+ (function(){
67482
+ var deck=document.querySelector(".deck");
67483
+ if(!deck) return;
67484
+ var pages=[].slice.call(deck.querySelectorAll(".page"));
67485
+ var dotsWrap=document.querySelector(".dots");
67486
+ var counter=document.querySelector(".counter");
67487
+
67488
+ // Build one dot per page so the markup above stays about content, not chrome.
67489
+ var dots=pages.map(function(_,i){
67490
+ var b=document.createElement("button");
67491
+ b.className="dot"; b.type="button"; b.setAttribute("aria-label",String(i+1));
67492
+ b.addEventListener("click",function(){ go(i); });
67493
+ if(dotsWrap) dotsWrap.appendChild(b);
67494
+ return b;
67495
+ });
67496
+
67497
+ // Tracked explicitly: reading scrollLeft mid-smooth-scroll would collapse rapid presses.
67498
+ var idx=0;
67499
+ function paint(){
67500
+ dots.forEach(function(d,j){ d.setAttribute("aria-current",String(j===idx)); });
67501
+ if(counter) counter.textContent=(idx+1)+" / "+pages.length;
67502
+ }
67503
+ function go(i){
67504
+ idx=Math.max(0,Math.min(pages.length-1,i));
67505
+ pages[idx].scrollIntoView({block:"nearest",inline:"start"});
67506
+ paint();
67507
+ }
67508
+
67509
+ // Any scrollable ancestor of the pointer keeps its native scroll — screenshot frames and
67510
+ // long tables both rely on this. Only once nothing under the cursor can scroll further
67511
+ // does the wheel page the deck.
67512
+ function canScroll(el,dy){
67513
+ while(el&&el!==deck){
67514
+ if(el.scrollHeight>el.clientHeight+4){
67515
+ var atTop=el.scrollTop<=0;
67516
+ var atBottom=el.scrollTop+el.clientHeight>=el.scrollHeight-1;
67517
+ if(!((atTop&&dy<0)||(atBottom&&dy>0))) return true;
67518
+ }
67519
+ el=el.parentElement;
67520
+ }
67521
+ return false;
67522
+ }
67523
+
67524
+ // A whole page per gesture: with \`scroll-snap-type: x mandatory\`, nudging scrollLeft by
67525
+ // small wheel deltas gets snapped straight back and the deck never moves.
67526
+ var acc=0,lock=false;
67527
+ deck.addEventListener("wheel",function(ev){
67528
+ if(Math.abs(ev.deltaY)<=Math.abs(ev.deltaX)) return;
67529
+ if(canScroll(ev.target,ev.deltaY)) return;
67530
+ ev.preventDefault();
67531
+ if(lock) return;
67532
+ acc+=ev.deltaY;
67533
+ if(Math.abs(acc)<40) return;
67534
+ var dir=acc>0?1:-1; acc=0;
67535
+ if((dir>0&&idx>=pages.length-1)||(dir<0&&idx<=0)) return;
67536
+ lock=true; go(idx+dir);
67537
+ setTimeout(function(){ lock=false; acc=0; },480);
67538
+ },{passive:false});
67539
+
67540
+ addEventListener("keydown",function(ev){
67541
+ var step={ArrowRight:1,PageDown:1,ArrowLeft:-1,PageUp:-1}[ev.key];
67542
+ if(step){ ev.preventDefault(); go(idx+step); }
67543
+ if(ev.key==="Home"){ ev.preventDefault(); go(0); }
67544
+ if(ev.key==="End"){ ev.preventDefault(); go(pages.length-1); }
67545
+ });
67546
+
67547
+ // Resync after a drag / trackpad swipe, once the snap has settled.
67548
+ var settle;
67549
+ deck.addEventListener("scroll",function(){
67550
+ clearTimeout(settle);
67551
+ settle=setTimeout(function(){
67552
+ idx=Math.round(deck.scrollLeft/window.innerWidth); paint();
67553
+ },120);
67554
+ },{passive:true});
67555
+
67556
+ paint();
67557
+ })();
67558
+
67559
+ // ── PT/EN toggle — same contract as report-components.html ───────────────────
67560
+ (function(){
67561
+ var KEY="report-lang", btn=document.getElementById("langToggle");
67562
+ function apply(lang){
67563
+ document.documentElement.lang=lang;
67564
+ document.querySelectorAll(".i18n").forEach(function(e){
67565
+ if(e.dataset[lang]!=null) e.textContent=e.dataset[lang];
67566
+ });
67567
+ document.querySelectorAll(".i18n-html").forEach(function(e){
67568
+ if(e.dataset[lang]!=null) e.innerHTML=e.dataset[lang];
67569
+ });
67570
+ if(btn) btn.textContent = lang==="pt" ? "EN" : "PT";
67571
+ try{ localStorage.setItem(KEY,lang) }catch(_){}
67572
+ }
67573
+ var saved; try{ saved=localStorage.getItem(KEY) }catch(_){}
67574
+ apply(saved==="pt"||saved==="en"?saved:"en");
67575
+ if(btn) btn.addEventListener("click",function(){
67576
+ apply(document.documentElement.lang==="pt"?"en":"pt");
67577
+ });
67578
+ })();
67579
+ `;
67580
+
67581
+ // src/report/deck-html.ts
67582
+ var TONE_CLASS = {
67583
+ good: "t-good",
67584
+ warn: "t-warn",
67585
+ bad: "t-bad",
67586
+ neutral: ""
67587
+ };
67588
+ function esc3(s) {
67589
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
67590
+ }
67591
+ function L2(pt, en, lang) {
67592
+ const initial = lang === "pt" ? pt : en;
67593
+ return `<span class="i18n" data-pt="${esc3(pt)}" data-en="${esc3(en)}">${esc3(initial)}</span>`;
67594
+ }
67595
+ function tiles(items, lang) {
67596
+ const cells = items.map((t) => `<div class="tile"><div class="tile-val ${TONE_CLASS[t.tone]}">${esc3(t.value)}</div>` + `<div class="tile-label">${esc3(t.label)}</div>` + `<div class="tile-sub">${esc3(t.sub)}</div></div>`).join("");
67597
+ return `<div class="stat-grid">${cells}</div>`;
67598
+ }
67599
+ function page(eyebrow, title, body, note) {
67600
+ return `<section class="page"><div class="page-inner">
67601
+ <div class="eyebrow">${eyebrow}</div>
67602
+ <h2 class="page-title">${title}</h2>
67603
+ ${note ? `<p class="annotation">${note}</p>` : ""}
67604
+ ${body}
67605
+ </div></section>`;
67606
+ }
67607
+ function findingsTable(findings, omitted, lang) {
67608
+ if (findings.length === 0) {
67609
+ return `<p class="annotation">${L2("Nenhum achado ranqueado neste run.", "No ranked findings in this run.", lang)}</p>`;
67610
+ }
67611
+ const rows = findings.map((f) => {
67612
+ const pill = f.severity === "critical" || f.severity === "high" ? f.severity === "critical" ? "pill-bad" : "pill-warn" : "pill-good";
67613
+ const badge = f.inconclusive ? ` <span class="pill pill-warn">${L2("inconclusivo", "inconclusive", lang)}</span>` : "";
67614
+ return `<tr><td><span class="pill ${pill}">${esc3(f.severity)}</span>${badge}</td><td>${esc3(f.category)}</td><td>${esc3(f.summary)}</td></tr>`;
67615
+ }).join("");
67616
+ const tail = omitted > 0 ? `<p class="annotation">${L2(`+${omitted} achado(s) além dos mostrados — veja report.json.`, `+${omitted} more finding(s) beyond those shown — see report.json.`, lang)}</p>` : "";
67617
+ return `<table class="grid compact"><thead><tr><th>Sev</th><th>${L2("Categoria", "Category", lang)}</th><th>${L2("Achado", "Finding", lang)}</th></tr></thead><tbody>${rows}</tbody></table>${tail}`;
67618
+ }
67619
+ function renderDeckHtml(model, lang = "en") {
67620
+ const pages = [];
67621
+ pages.push(`<section class="page cover"><div class="page-inner">
67622
+ <div class="eyebrow">${L2("Relatório de migração", "Migration report", lang)}</div>
67623
+ <h1 class="cover-h1">${esc3(hostOf4(model.candUrl))}<br/><span class="dim">${esc3(hostOf4(model.prodUrl))}</span> → <span class="lime-ink">${esc3(hostOf4(model.candUrl))}</span></h1>
67624
+ <div class="cover-meta">
67625
+ <div><b>${model.score}</b><small>${L2("score parity", "parity score", lang)}</small></div>
67626
+ <div><b>${esc3(model.status)}</b><small>${L2("veredito", "verdict", lang)}</small></div>
67627
+ <div><b>${esc3(model.timestamp.slice(0, 10))}</b><small>${L2("data", "date", lang)}</small></div>
67628
+ </div>
67629
+ <p class="hint">${L2("Use ← → ou role a página — o scroll avança lateralmente.", "Use ← → or scroll — the deck advances sideways.", lang)}</p>
67630
+ </div></section>`);
67631
+ if (model.caveats.length > 0) {
67632
+ const rows = model.caveats.map((c) => `<tr><td><span class="pill ${c.level === "warn" ? "pill-warn" : "pill-good"}">${esc3(c.level)}</span></td><td><b>${esc3(c.summary)}</b></td><td>${esc3(c.detail)}</td></tr>`).join("");
67633
+ pages.push(page(L2("Contexto", "Context", lang), L2("Como ler este run", "How to read this run", lang), `<table class="grid"><tbody>${rows}</tbody></table>`, L2("O que o número <b>não</b> mede. Vem de <code>report.json.caveats</code>.", "What the number does <b>not</b> measure. From <code>report.json.caveats</code>.", lang)));
67634
+ }
67635
+ const moduleRows = model.modules.map((m) => `<tr><td>${esc3(m.module)}</td><td><b class="num">${m.score}</b></td><td><span class="pill pill-${m.tone === "good" ? "good" : m.tone === "warn" ? "warn" : "bad"}">${esc3(m.status)}</span></td></tr>`).join("");
67636
+ pages.push(page(L2("Sumário executivo", "Executive summary", lang), L2("Onde a migração está", "Where the migration stands", lang), tiles(model.headline, lang) + (moduleRows ? `<h3 class="sub">${L2("Score por módulo", "Score per module", lang)}</h3>` + `<table class="grid"><tbody>${moduleRows}</tbody></table>` : "")));
67637
+ pages.push(page(L2("Achados", "Findings", lang), L2("O que a validação encontrou", "What the validation found", lang), findingsTable(model.findings, model.findingsOmitted, lang)));
67638
+ if (model.visual) {
67639
+ pages.push(page(L2("Visual", "Visual", lang), L2("Paridade visual", "Visual parity", lang), tiles([
67640
+ {
67641
+ value: String(model.visual.pagesChecked),
67642
+ label: "páginas comparadas",
67643
+ sub: "",
67644
+ tone: "neutral"
67645
+ },
67646
+ {
67647
+ value: String(model.visual.pagesPassed),
67648
+ label: "sem diferenças",
67649
+ sub: "",
67650
+ tone: "good"
67651
+ },
67652
+ {
67653
+ value: String(model.visual.pagesWithDiffs),
67654
+ label: "com diferenças",
67655
+ sub: "",
67656
+ tone: model.visual.pagesWithDiffs > 0 ? "warn" : "good"
67657
+ }
67658
+ ], lang)));
67659
+ }
67660
+ return `<!doctype html>
67661
+ <html lang="${lang === "pt" ? "pt-BR" : "en"}"><head>
67662
+ <meta charset="utf-8"/>
67663
+ <meta name="viewport" content="width=device-width,initial-scale=1"/>
67664
+ <title>parity deck — ${esc3(model.runId)}</title>
67665
+ <style>${DECK_CSS}</style>
67666
+ </head><body>
67667
+ <div class="nav">
67668
+ <b>parity · ${esc3(hostOf4(model.candUrl))}</b>
67669
+ <span class="spacer"></span>
67670
+ <div class="dots"><!-- filled by DECK_JS, one per page --></div>
67671
+ <span class="counter"></span>
67672
+ <button class="lang-toggle" id="langToggle" type="button">${lang === "pt" ? "EN" : "PT"}</button>
67673
+ </div>
67674
+ <main class="deck">${pages.join("")}</main>
67675
+ <script>${DECK_JS}</script>
67676
+ </body></html>`;
67677
+ }
67678
+ function hostOf4(raw) {
67679
+ try {
67680
+ return new URL(raw).host;
67681
+ } catch {
67682
+ return raw;
67683
+ }
67684
+ }
67685
+
67686
+ // src/report/deck-model.ts
67687
+ var MAX_FINDINGS = 12;
67688
+ function toneForStatus(status) {
67689
+ if (status === "pass")
67690
+ return "good";
67691
+ if (status === "warn")
67692
+ return "warn";
67693
+ return "bad";
67694
+ }
67695
+ function buildDeckModel(run) {
67696
+ const v = run.verdict;
67697
+ const source = run.topIssues.length > 0 ? run.topIssues : run.issues;
67698
+ const ranked = [...source].sort(bySeverity);
67699
+ const findings = ranked.slice(0, MAX_FINDINGS).map((i) => ({
67700
+ severity: i.severity,
67701
+ category: i.category,
67702
+ summary: i.summary,
67703
+ inconclusive: Boolean(i.inconclusive)
67704
+ }));
67705
+ return {
67706
+ prodUrl: run.prodUrl,
67707
+ candUrl: run.candUrl,
67708
+ timestamp: run.timestamp,
67709
+ runId: run.id,
67710
+ score: v.score,
67711
+ status: v.status,
67712
+ caveats: run.caveats ?? [],
67713
+ headline: [
67714
+ {
67715
+ value: `${v.score}/100`,
67716
+ label: "score parity",
67717
+ sub: v.pagesAnalyzed ? `${v.pagesAnalyzed} páginas analisadas` : "",
67718
+ tone: toneForStatus(v.status)
67719
+ },
67720
+ {
67721
+ value: String(v.critical),
67722
+ label: "critical",
67723
+ sub: "bloqueiam launch",
67724
+ tone: v.critical > 0 ? "bad" : "good"
67725
+ },
67726
+ {
67727
+ value: String(v.high),
67728
+ label: "high",
67729
+ sub: "corrigir antes de produção",
67730
+ tone: v.high > 0 ? "warn" : "good"
67731
+ },
67732
+ {
67733
+ value: `${v.checksPassed}/${v.checksRun}`,
67734
+ label: "checks passados",
67735
+ sub: v.checksSkipped > 0 ? `${v.checksSkipped} pulados` : "",
67736
+ tone: v.checksFailed > 0 ? "bad" : "good"
67737
+ }
67738
+ ],
67739
+ modules: (run.moduleVerdicts ?? []).map((m) => ({
67740
+ module: m.module,
67741
+ score: m.score,
67742
+ status: m.status,
67743
+ tone: toneForStatus(m.status)
67744
+ })),
67745
+ findings,
67746
+ findingsOmitted: Math.max(0, ranked.length - findings.length),
67747
+ visual: run.visualDiff ? {
67748
+ pagesChecked: run.visualDiff.pagesChecked,
67749
+ pagesPassed: run.visualDiff.pagesPassed,
67750
+ pagesWithDiffs: run.visualDiff.pagesWithDiffs
67751
+ } : null
67752
+ };
67753
+ }
67754
+ var SEVERITY_ORDER4 = { critical: 0, high: 1, medium: 2, low: 3 };
67755
+ function bySeverity(a, b) {
67756
+ const bySev = SEVERITY_ORDER4[a.severity] - SEVERITY_ORDER4[b.severity];
67757
+ if (bySev !== 0)
67758
+ return bySev;
67759
+ return Number(Boolean(a.inconclusive)) - Number(Boolean(b.inconclusive));
67760
+ }
67761
+
67293
67762
  // src/report/extract-section.ts
67294
67763
  function extractReportSection(input) {
67295
67764
  if (input.kind === "html")
@@ -67430,6 +67899,25 @@ function pathOf6(url) {
67430
67899
  // src/commands/report.ts
67431
67900
  async function reportCommand(runId, opts) {
67432
67901
  const paths = getRunPaths(opts.output, runId);
67902
+ if (opts.deck) {
67903
+ let run;
67904
+ try {
67905
+ run = loadRun(opts.output, runId);
67906
+ } catch (err) {
67907
+ console.error(chalk23.red(`failed to load run: ${err.message}`));
67908
+ return 1;
67909
+ }
67910
+ const html3 = renderDeckHtml(buildDeckModel(run), opts.lang ?? "en");
67911
+ const dest = opts.out ?? join31(paths.runDir, "deck.html");
67912
+ writeFileSync26(dest, html3, "utf8");
67913
+ console.log(`${chalk23.green("✓")} deck → ${dest}`);
67914
+ if (opts.open) {
67915
+ await open2(dest).catch((err) => {
67916
+ console.error(chalk23.red(`failed to open: ${err.message}`));
67917
+ });
67918
+ }
67919
+ return 0;
67920
+ }
67433
67921
  if (opts.section) {
67434
67922
  if (opts.json) {
67435
67923
  try {
@@ -67468,9 +67956,9 @@ async function reportCommand(runId, opts) {
67468
67956
  }
67469
67957
 
67470
67958
  // src/commands/vitals.ts
67471
- import { existsSync as existsSync21, readFileSync as readFileSync24, writeFileSync as writeFileSync26 } from "node:fs";
67959
+ import { existsSync as existsSync21, readFileSync as readFileSync24, writeFileSync as writeFileSync27 } from "node:fs";
67472
67960
  import { availableParallelism } from "node:os";
67473
- import { join as join31 } from "node:path";
67961
+ import { join as join32 } from "node:path";
67474
67962
  import chalk24 from "chalk";
67475
67963
  import ora8 from "ora";
67476
67964
 
@@ -67809,7 +68297,7 @@ async function vitalsCommand(opts) {
67809
68297
  });
67810
68298
  progress.succeed(`${total} capture(s) em ${((Date.now() - t0) / 1000).toFixed(1)}s`);
67811
68299
  if (opts.lighthouse !== false) {
67812
- const lhDir = join31(paths.runDir, "lighthouse");
68300
+ const lhDir = join32(paths.runDir, "lighthouse");
67813
68301
  const lhCap = opts.lighthouseConcurrency ?? Math.max(1, Math.min(2, Math.floor(availableParallelism() / 2)));
67814
68302
  const done = tasks.filter((t) => !!t.capture);
67815
68303
  const lhT0 = Date.now();
@@ -67900,7 +68388,7 @@ async function vitalsCommand(opts) {
67900
68388
  writeRunReportJson(paths.runDir, run);
67901
68389
  const html3 = renderHtmlReport(run, paths.runDir);
67902
68390
  writeRunReportHtml(paths.runDir, html3);
67903
- writeFileSync26(join31(paths.runDir, "vitals.json"), `${JSON.stringify({
68391
+ writeFileSync27(join32(paths.runDir, "vitals.json"), `${JSON.stringify({
67904
68392
  schemaVersion: "0.1",
67905
68393
  prodUrl: opts.prod,
67906
68394
  candUrl: opts.cand,
@@ -67937,10 +68425,10 @@ async function vitalsCommand(opts) {
67937
68425
  async function captureVitalsPage(browser, viewport, side, url, screenshotsDir, runs) {
67938
68426
  const ctx = await newContext(browser, { viewport, cohortCookieValue: "control" });
67939
68427
  await installVitalsCollector(ctx);
67940
- const page = await ctx.newPage();
68428
+ const page2 = await ctx.newPage();
67941
68429
  try {
67942
68430
  const safeName2 = url.replace(/^https?:\/\//, "").replace(/[^a-z0-9_-]+/gi, "_").slice(0, 80);
67943
- return await capturePage(page, {
68431
+ return await capturePage(page2, {
67944
68432
  url,
67945
68433
  side,
67946
68434
  viewport,
@@ -67953,7 +68441,7 @@ async function captureVitalsPage(browser, viewport, side, url, screenshotsDir, r
67953
68441
  runs
67954
68442
  });
67955
68443
  } finally {
67956
- await page.close().catch(() => {
68444
+ await page2.close().catch(() => {
67957
68445
  return;
67958
68446
  });
67959
68447
  await ctx.close().catch(() => {
@@ -68126,11 +68614,15 @@ program.command("plan").description("Inspect/update the migration-plan.json comp
68126
68614
  program.command("serve").argument("<runId>", "Run ID to serve").description("Spawns a local HTTP server that serves the report and proxies external iframes (strips X-Frame-Options/CSP), making the Side-by-side tab functional for any site.").option("--output <dir>", "Output directory where runs live", "./parity-output").option("--port <n>", "Fixed port (default: auto-pick free port)", (v) => Number(v)).option("--no-open", "Don't open the browser automatically").action(async (runId, opts) => {
68127
68615
  process.exit(await serveCommand(runId, opts));
68128
68616
  });
68129
- program.command("report").argument("<runId>", "Run ID to open").description("Open the HTML report for a run in the default browser. With --section, extract a single tab to stdout instead — useful for agents that need just the SEO/Network/Vitals slice without parsing the whole report. Issue #74.").option("--output <dir>", "Output directory", "./parity-output").option("--section <name>", "Extract one tab to stdout instead of opening the report. Valid names: summary, visualdiff, seo, sidebyside, issues, vitals, cache, checks, prompt, pages, console, network, diff.").option("--json", "Pair with --section to emit a normalized JSON projection of the section (from report.json) instead of the raw HTML slice.").action(async (runId, opts) => {
68617
+ program.command("report").argument("<runId>", "Run ID to open").description("Open the HTML report for a run in the default browser. With --section, extract a single tab to stdout instead — useful for agents that need just the SEO/Network/Vitals slice without parsing the whole report. Issue #74.").option("--output <dir>", "Output directory", "./parity-output").option("--section <name>", "Extract one tab to stdout instead of opening the report. Valid names: summary, visualdiff, seo, sidebyside, issues, vitals, cache, checks, prompt, pages, console, network, diff.").option("--json", "Pair with --section to emit a normalized JSON projection of the section (from report.json) instead of the raw HTML slice.").option("--deck", "Render the presentation deck instead: one topic per full-viewport page, advanced sideways, in a single self-contained HTML file. For showing the result to someone rather than debugging it. Issue #290.", false).option("--out <path>", "Where to write the deck (default: deck.html in the run dir)").option("--lang <pt|en>", "Initial deck language; the in-page toggle still switches live", "en").option("--open", "Open the rendered deck in the browser", false).action(async (runId, opts) => {
68130
68618
  process.exit(await reportCommand(runId, {
68131
68619
  output: opts.output,
68132
68620
  section: opts.section,
68133
- json: opts.json
68621
+ json: opts.json,
68622
+ deck: Boolean(opts.deck),
68623
+ out: opts.out,
68624
+ lang: opts.lang === "pt" ? "pt" : "en",
68625
+ open: Boolean(opts.open)
68134
68626
  }));
68135
68627
  });
68136
68628
  program.command("compare").argument("<runId>", "Run ID to compare").requiredOption("--against <name>", "Baseline name to compare against").option("--output <dir>", "Output directory", "./parity-output").description("Compare a run against a baseline").action((runId, opts) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/parity",
3
- "version": "0.26.14",
3
+ "version": "0.26.16",
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",