@decocms/parity 0.18.0 → 0.20.0

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 (3) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/cli.js +542 -69
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.20.0] — 2026-08-17
11
+
12
+ ### Added
13
+
14
+ * **`parity migrate` now captures the VTEX CMS content + all its images.** Each block's `props` (the merchant's registered content — banner images, texts, links, shelf config) is kept in `blocks.json`; content-image references (site-relative `/arquivos/ids/…`, `/img/…`) are resolved to absolute URLs, and the images — from block props **and** the Apollo `__STATE__` (product/catalog imagery) — are downloaded to `assets/content/` with a `content-assets.json` url→file map (up to 150/run). (#209, #211)
15
+ * **Quality pass:** robust logo capture (screenshots the element, so sprite `<use>` logos aren't blank), web-font download from `@font-face` (`assets/fonts/`), scroll-before-screenshot (lazy footers render), and a self-contained **`report.html`** (every image inlined) to share as a single link. (#209)
16
+
17
+ ### Fixed
18
+
19
+ * **Header/footer are now detected on sites without semantic tags** (e.g. VTEX IO, which renders both as plain `<div>`s) via a geometry/anchor fallback that only fires when no `<header>`/`<footer>` matched. Shared by `extract` + `migrate`. (#212)
20
+ * **Theme election cleanups:** primary skips translucent overlays and considers opaque colors across all usages; breakpoints kept by frequency (real tiers, not 100+ media-query one-offs); background falls back to the most frequent opaque color; implausible motion durations dropped. (#209)
21
+ * Ignore `parity-migrate/` / `parity-extract/` output dirs so scraped store data can't be committed. (#210)
22
+
23
+ ## [0.19.0] — 2026-08-17
24
+
25
+ ### Added
26
+
27
+ * **`parity migrate` HTML visual report + `--open`.** A self-contained `index.html` (theme color swatches + tokens, per-viewport screenshots, brand assets, component table, VTEX IO → FastStore block map) written alongside `index.md`; `--open` launches it in the browser (same `open` package `parity run`/`audit` use). (#207)
28
+
29
+ ### Fixed
30
+
31
+ * **`migrate` theme primary election skips translucent overlays.** Primary/secondary are now elected from the most frequent non-neutral, **opaque** color across all usages (text/border/bg + interactive) instead of interactive backgrounds only — a translucent hover overlay could otherwise win (e.g. Electrolux came out `rgba(123,138,156,0.24)` instead of the brand navy). (#206)
32
+
10
33
  ## [0.18.0] — 2026-08-17
11
34
 
12
35
  ### Added
package/dist/cli.js CHANGED
@@ -56006,6 +56006,48 @@ function collectCandidatesInPage() {
56006
56006
  }
56007
56007
  }
56008
56008
  }
56009
+ const docHeight = Math.max(document.documentElement.scrollHeight, document.body?.scrollHeight ?? 0);
56010
+ function widest(els) {
56011
+ let best = null;
56012
+ let bestArea = 0;
56013
+ for (const el of els) {
56014
+ const r = rectOf(el);
56015
+ if (r.width < viewportWidth * 0.85)
56016
+ continue;
56017
+ const area = r.width * r.height;
56018
+ if (area > bestArea && area > 0) {
56019
+ best = el;
56020
+ bestArea = area;
56021
+ }
56022
+ }
56023
+ return best;
56024
+ }
56025
+ if (!out.some((c) => c.role === "header")) {
56026
+ let header = null;
56027
+ const anchor = document.querySelector("nav, [class*='logo' i], [class*='search' i]");
56028
+ let el = anchor;
56029
+ while (el?.parentElement) {
56030
+ const r = rectOf(el.parentElement);
56031
+ if (r.y <= 5 && r.width >= viewportWidth * 0.85 && r.height < window.innerHeight * 1.5) {
56032
+ header = el.parentElement;
56033
+ }
56034
+ el = el.parentElement;
56035
+ }
56036
+ header ??= widest(Array.from(document.querySelectorAll("[class*='header' i]")).filter((e) => rectOf(e).y < 200));
56037
+ if (header)
56038
+ push("header", header);
56039
+ }
56040
+ if (!out.some((c) => c.role === "footer")) {
56041
+ const footer = widest(Array.from(document.querySelectorAll("[class*='footer' i]")).filter((e) => {
56042
+ const r = rectOf(e);
56043
+ return r.y + r.height > docHeight - window.innerHeight && e.querySelectorAll("a").length >= 4;
56044
+ })) ?? widest(Array.from(document.querySelectorAll("div, section")).filter((e) => {
56045
+ const r = rectOf(e);
56046
+ return r.y + r.height > docHeight - window.innerHeight * 0.6 && r.y > docHeight * 0.5 && e.querySelectorAll("a").length >= 6;
56047
+ }));
56048
+ if (footer)
56049
+ push("footer", footer);
56050
+ }
56009
56051
  return out;
56010
56052
  }
56011
56053
 
@@ -58417,9 +58459,10 @@ function listCommand(output) {
58417
58459
  }
58418
58460
 
58419
58461
  // src/commands/migrate.ts
58420
- import { existsSync as existsSync11, mkdirSync as mkdirSync14, readFileSync as readFileSync13, writeFileSync as writeFileSync19 } from "node:fs";
58462
+ import { existsSync as existsSync11, mkdirSync as mkdirSync15, readFileSync as readFileSync14, writeFileSync as writeFileSync21 } from "node:fs";
58421
58463
  import { resolve as resolve3 } from "node:path";
58422
58464
  import chalk16 from "chalk";
58465
+ import open from "open";
58423
58466
 
58424
58467
  // src/migrate/pdp-discovery.ts
58425
58468
  var PLATFORM_PATTERNS = {
@@ -58567,7 +58610,31 @@ async function collectSiteAssets(page) {
58567
58610
  const appleTouchIcon = linkHref("link[rel='apple-touch-icon']");
58568
58611
  const manifest = linkHref("link[rel='manifest']");
58569
58612
  const ogImage = abs(document.querySelector("meta[property='og:image']")?.getAttribute("content"));
58570
- const fonts = Array.from(document.querySelectorAll("link[rel='preload'][as='font']")).map((l) => abs(l.getAttribute("href"))).filter((u) => Boolean(u));
58613
+ const fontUrls = new Set;
58614
+ for (const l of Array.from(document.querySelectorAll("link[rel='preload'][as='font']"))) {
58615
+ const u = abs(l.getAttribute("href"));
58616
+ if (u)
58617
+ fontUrls.add(u);
58618
+ }
58619
+ for (const sheet of Array.from(document.styleSheets)) {
58620
+ let rules;
58621
+ try {
58622
+ rules = sheet.cssRules;
58623
+ } catch {
58624
+ continue;
58625
+ }
58626
+ for (const rule of Array.from(rules)) {
58627
+ if (rule.constructor.name !== "CSSFontFaceRule")
58628
+ continue;
58629
+ const src = rule.style.getPropertyValue("src");
58630
+ for (const m of src.matchAll(/url\((['"]?)([^'")]+)\1\)/gi)) {
58631
+ const u = abs(m[2]);
58632
+ if (u && /\.(woff2?|ttf|otf)(\?|$)/i.test(u))
58633
+ fontUrls.add(u);
58634
+ }
58635
+ }
58636
+ }
58637
+ const fonts = [...fontUrls].slice(0, 20);
58571
58638
  const header = document.querySelector("header, [role='banner']") || document.body;
58572
58639
  let logo = null;
58573
58640
  if (header) {
@@ -58577,6 +58644,7 @@ async function collectSiteAssets(page) {
58577
58644
  });
58578
58645
  const el = hinted ?? header.querySelector("a[href='/'] img, a[href='/'] svg") ?? header.querySelector("img, svg");
58579
58646
  if (el) {
58647
+ el.setAttribute("data-parity-logo", "1");
58580
58648
  if (el.tagName.toLowerCase() === "img") {
58581
58649
  const url = abs(el.getAttribute("src"));
58582
58650
  if (url)
@@ -58684,6 +58752,17 @@ async function downloadSiteAssets(raw, runDir, fetchBytes) {
58684
58752
  raw.appleTouchIcon ? downloadTo(raw.appleTouchIcon, dir, "apple-touch-icon", fetchBytes) : Promise.resolve(null),
58685
58753
  raw.ogImage ? downloadTo(raw.ogImage, dir, "og-image", fetchBytes) : Promise.resolve(null)
58686
58754
  ]);
58755
+ const fontsDir = join17(dir, "fonts");
58756
+ mkdirSync12(fontsDir, { recursive: true });
58757
+ const fontFiles = [];
58758
+ for (const [i, url] of raw.fonts.entries()) {
58759
+ const got = await fetchBytes(url);
58760
+ if (!got)
58761
+ continue;
58762
+ const base = safeFontName(url, i);
58763
+ writeFileSync16(join17(fontsDir, base), got.buf);
58764
+ fontFiles.push(`assets/fonts/${base}`);
58765
+ }
58687
58766
  return {
58688
58767
  logo,
58689
58768
  logoSource,
@@ -58693,9 +58772,21 @@ async function downloadSiteAssets(raw, runDir, fetchBytes) {
58693
58772
  ogImage,
58694
58773
  manifest: raw.manifest,
58695
58774
  fonts: raw.fonts,
58775
+ fontFiles,
58696
58776
  icons: raw.icons
58697
58777
  };
58698
58778
  }
58779
+ function safeFontName(url, i) {
58780
+ try {
58781
+ const base = new URL(url).pathname.split("/").pop() ?? "";
58782
+ if (/^[\w.-]+\.(woff2?|ttf|otf)$/i.test(base))
58783
+ return base;
58784
+ const ext = base.match(/\.(woff2?|ttf|otf)$/i)?.[0] ?? ".woff2";
58785
+ return `font-${i}${ext}`;
58786
+ } catch {
58787
+ return `font-${i}.woff2`;
58788
+ }
58789
+ }
58699
58790
 
58700
58791
  // src/migrate/browser-fetch.ts
58701
58792
  async function browserFetchText(page, url) {
@@ -59037,8 +59128,138 @@ var jsonExporter2 = {
59037
59128
  };
59038
59129
 
59039
59130
  // src/migrate/exporters/markdown.ts
59131
+ import { mkdirSync as mkdirSync14, writeFileSync as writeFileSync19 } from "node:fs";
59132
+ import { join as join20 } from "node:path";
59133
+
59134
+ // src/migrate/vtex/content-assets.ts
59040
59135
  import { mkdirSync as mkdirSync13, writeFileSync as writeFileSync18 } from "node:fs";
59041
59136
  import { join as join19 } from "node:path";
59137
+ var MAX_IMAGES = 150;
59138
+ var IMG_EXT = /\.(jpe?g|png|webp|gif|svg|avif)(\?|#|$)/i;
59139
+ var VTEX_ASSET = /vtexassets\.com|vteximg\.com\.br|\/arquivos\/(ids|assets)\//i;
59140
+ function isImageUrl(s) {
59141
+ if (typeof s !== "string")
59142
+ return false;
59143
+ const v = s.trim();
59144
+ if (!/^(https?:)?\/\//i.test(v))
59145
+ return false;
59146
+ return IMG_EXT.test(v) || VTEX_ASSET.test(v);
59147
+ }
59148
+ function isImageRef(s) {
59149
+ if (typeof s !== "string")
59150
+ return false;
59151
+ const v = s.trim();
59152
+ if (isImageUrl(v))
59153
+ return true;
59154
+ return v.startsWith("/") && !v.startsWith("//") && (IMG_EXT.test(v) || VTEX_ASSET.test(v) || v.startsWith("/img/"));
59155
+ }
59156
+ function resolveRef(ref, baseUrl) {
59157
+ const v = ref.trim();
59158
+ try {
59159
+ if (v.startsWith("//"))
59160
+ return `https:${v}`;
59161
+ return new URL(v, baseUrl).toString();
59162
+ } catch {
59163
+ return null;
59164
+ }
59165
+ }
59166
+ function collectImageRefs(blocks, baseUrl) {
59167
+ const out = {};
59168
+ const walk = (v) => {
59169
+ if (typeof v === "string") {
59170
+ const s = v.trim();
59171
+ if (isImageRef(s) && !(s in out)) {
59172
+ const abs = resolveRef(s, baseUrl);
59173
+ if (abs)
59174
+ out[s] = abs;
59175
+ }
59176
+ } else if (Array.isArray(v)) {
59177
+ for (const x of v)
59178
+ walk(x);
59179
+ } else if (v && typeof v === "object") {
59180
+ for (const x of Object.values(v))
59181
+ walk(x);
59182
+ }
59183
+ };
59184
+ for (const b of blocks)
59185
+ if (b.props)
59186
+ walk(b.props);
59187
+ return out;
59188
+ }
59189
+ function countContentImages(blocks) {
59190
+ const urls = new Set;
59191
+ const walk = (v) => {
59192
+ if (typeof v === "string") {
59193
+ if (isImageUrl(v.trim()))
59194
+ urls.add(v.trim());
59195
+ } else if (Array.isArray(v)) {
59196
+ for (const x of v)
59197
+ walk(x);
59198
+ } else if (v && typeof v === "object") {
59199
+ for (const x of Object.values(v))
59200
+ walk(x);
59201
+ }
59202
+ };
59203
+ for (const b of blocks)
59204
+ if (b.props)
59205
+ walk(b.props);
59206
+ return urls.size;
59207
+ }
59208
+ function rewriteBlockUrls(blocks, urlToPath) {
59209
+ const replace = (v) => {
59210
+ if (typeof v === "string")
59211
+ return urlToPath[v.trim()] ?? v;
59212
+ if (Array.isArray(v))
59213
+ return v.map(replace);
59214
+ if (v && typeof v === "object") {
59215
+ const out = {};
59216
+ for (const [k, val2] of Object.entries(v))
59217
+ out[k] = replace(val2);
59218
+ return out;
59219
+ }
59220
+ return v;
59221
+ };
59222
+ return blocks.map((b) => ({
59223
+ ...b,
59224
+ props: b.props ? replace(b.props) : b.props
59225
+ }));
59226
+ }
59227
+ function contentImageName(url, index2, used) {
59228
+ let base = "img";
59229
+ try {
59230
+ base = new URL(url, "https://x").pathname.split("/").filter(Boolean).pop() ?? "img";
59231
+ } catch {}
59232
+ base = base.split("?")[0].replace(/[^\w.-]/g, "_").slice(-60) || "img";
59233
+ if (!/\.(jpe?g|png|webp|gif|svg|avif)$/i.test(base))
59234
+ base += ".img";
59235
+ let name = base;
59236
+ if (used.has(name))
59237
+ name = `${index2}-${base}`;
59238
+ used.add(name);
59239
+ return name;
59240
+ }
59241
+ async function downloadContentImages(urls, runDir, fetchBytes) {
59242
+ const map2 = {};
59243
+ if (urls.length === 0)
59244
+ return { map: map2, downloaded: 0, skipped: 0 };
59245
+ const dir = join19(runDir, "assets", "content");
59246
+ mkdirSync13(dir, { recursive: true });
59247
+ const used = new Set;
59248
+ const take = urls.slice(0, MAX_IMAGES);
59249
+ let downloaded = 0;
59250
+ for (const [i, url] of take.entries()) {
59251
+ const got = await fetchBytes(url.startsWith("//") ? `https:${url}` : url);
59252
+ if (!got)
59253
+ continue;
59254
+ const name = contentImageName(url, i, used);
59255
+ writeFileSync18(join19(dir, name), got.buf);
59256
+ map2[url] = `assets/content/${name}`;
59257
+ downloaded++;
59258
+ }
59259
+ return { map: map2, downloaded, skipped: Math.max(0, urls.length - take.length) };
59260
+ }
59261
+
59262
+ // src/migrate/exporters/markdown.ts
59042
59263
  var markdownExporter2 = {
59043
59264
  name: "markdown",
59044
59265
  async export(bundle, outDir) {
@@ -59046,16 +59267,16 @@ var markdownExporter2 = {
59046
59267
  const notes = [];
59047
59268
  bundle.components.forEach((component, i) => {
59048
59269
  const dirName = dirNames[i];
59049
- const componentDir = join19(outDir, "components", dirName);
59050
- mkdirSync13(componentDir, { recursive: true });
59270
+ const componentDir = join20(outDir, "components", dirName);
59271
+ mkdirSync14(componentDir, { recursive: true });
59051
59272
  const compact = compactComponentHtml(component.html);
59052
59273
  if (compact.collapsed > 0)
59053
59274
  notes.push(`\`${dirName}\`: collapsed ${compact.collapsed} repeated child element(s)`);
59054
59275
  if (compact.truncated)
59055
59276
  notes.push(`\`${dirName}\`: HTML truncated to fit the per-component token ceiling`);
59056
- writeFileSync18(join19(componentDir, "README.md"), renderComponentReadme2(bundle.url, component, compact.html), "utf8");
59277
+ writeFileSync19(join20(componentDir, "README.md"), renderComponentReadme2(bundle.url, component, compact.html), "utf8");
59057
59278
  });
59058
- writeFileSync18(join19(outDir, "index.md"), renderIndex2(bundle, dirNames, notes), "utf8");
59279
+ writeFileSync19(join20(outDir, "index.md"), renderIndex2(bundle, dirNames, notes), "utf8");
59059
59280
  }
59060
59281
  };
59061
59282
  function renderIndex2(bundle, dirNames, notes) {
@@ -59088,7 +59309,7 @@ function renderIndex2(bundle, dirNames, notes) {
59088
59309
  if (bundle.vtex) {
59089
59310
  md("## VTEX IO → FastStore blocks");
59090
59311
  md("");
59091
- md(`_${bundle.vtex.blocks.length} block instances from the store runtime. \`custom-component\` = build from captured DOM/CSS; see component-map.json._`);
59312
+ md(`_${bundle.vtex.blocks.length} block instances · ${bundle.vtex.blocks.filter((x) => x.props).length} carry CMS content (props), ${countContentImages(bundle.vtex.blocks)} content images downloaded to \`assets/content/\` (URLs rewritten in \`blocks.json\`). \`confidence\` (0–1) = mapper certainty; \`custom-component\` = build from captured DOM/CSS._`);
59092
59313
  md("");
59093
59314
  md("| VTEX block | → FastStore | confidence | count |");
59094
59315
  md("|---|---|---|---|");
@@ -59146,7 +59367,7 @@ function renderAssets(md, assets) {
59146
59367
  md(`- **Apple touch icon**: ${assets.appleTouchIcon ? `\`${assets.appleTouchIcon}\`` : "—"}`);
59147
59368
  md(`- **OG image**: ${assets.ogImage ? `\`${assets.ogImage}\`` : "—"}`);
59148
59369
  md(`- **Web app manifest**: ${assets.manifest ? assets.manifest : "—"}`);
59149
- md(`- **Web fonts**: ${listOrNone2(assets.fonts)}`);
59370
+ md(`- **Web fonts**: ${assets.fontFiles.length}/${assets.fonts.length} downloaded${assets.fontFiles.length ? ` → ${listOrNone2(assets.fontFiles)}` : ""}`);
59150
59371
  md("");
59151
59372
  if (assets.icons.length) {
59152
59373
  md(`## Icons (${assets.icons.length})`);
@@ -59225,6 +59446,165 @@ function escapePipes2(s) {
59225
59446
  return s.replace(/\|/g, "\\|");
59226
59447
  }
59227
59448
 
59449
+ // src/migrate/exporters/html.ts
59450
+ import { readFileSync as readFileSync13, writeFileSync as writeFileSync20 } from "node:fs";
59451
+ import { join as join21 } from "node:path";
59452
+ var htmlExporter = {
59453
+ name: "html",
59454
+ async export(bundle, outDir) {
59455
+ writeFileSync20(join21(outDir, "index.html"), renderHtml(bundle, (p) => p ?? null), "utf8");
59456
+ const inline = (p) => p ? dataUri(join21(outDir, p)) ?? p : null;
59457
+ writeFileSync20(join21(outDir, "report.html"), renderHtml(bundle, inline), "utf8");
59458
+ }
59459
+ };
59460
+ var MIME = {
59461
+ ".png": "image/png",
59462
+ ".jpg": "image/jpeg",
59463
+ ".jpeg": "image/jpeg",
59464
+ ".webp": "image/webp",
59465
+ ".gif": "image/gif",
59466
+ ".svg": "image/svg+xml",
59467
+ ".ico": "image/x-icon"
59468
+ };
59469
+ function dataUri(absPath) {
59470
+ try {
59471
+ const ext = absPath.slice(absPath.lastIndexOf(".")).toLowerCase();
59472
+ const mime = MIME[ext];
59473
+ if (!mime)
59474
+ return null;
59475
+ return `data:${mime};base64,${readFileSync13(absPath).toString("base64")}`;
59476
+ } catch {
59477
+ return null;
59478
+ }
59479
+ }
59480
+ function esc(s) {
59481
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
59482
+ }
59483
+ function swatch(label, value) {
59484
+ if (!value)
59485
+ return `<div class="sw"><div class="chip empty"></div><b>${label}</b><span>—</span></div>`;
59486
+ return `<div class="sw"><div class="chip" style="background:${esc(value)}"></div><b>${label}</b><span>${esc(value)}</span></div>`;
59487
+ }
59488
+ function chips(items) {
59489
+ return items.length ? items.map((i) => `<code>${esc(i)}</code>`).join(" ") : "<em>none</em>";
59490
+ }
59491
+ function renderHtml(b, embed) {
59492
+ const t = b.theme;
59493
+ const shots = (b.screenshots ?? []).map((s) => {
59494
+ const src = embed(s.path);
59495
+ return src ? `<figure><figcaption>${esc(s.viewport)}</figcaption><img src="${esc(src)}" alt="${esc(s.viewport)}"></figure>` : "";
59496
+ }).join("");
59497
+ const componentRows = b.components.map((c, i) => {
59498
+ const keys = [...new Set(c.interactions.map((x) => x.e2eKey).filter(Boolean))];
59499
+ const folder = componentDirName(c.role, i + 1);
59500
+ return `<tr><td>${esc(c.scope)}</td><td><code>${esc(c.role)}</code>${c.repeated && c.repeated > 1 ? ` <span class="badge">×${c.repeated}</span>` : ""}</td><td>${c.tailwind.length}</td><td>${c.interactions.length}</td><td>${keys.length ? keys.map((k) => `<code>${esc(String(k))}</code>`).join(" ") : "—"}</td><td><a href="components/${esc(folder)}/README.md">${esc(folder)}</a></td></tr>`;
59501
+ }).join("");
59502
+ const vtexRows = b.vtex ? b.vtex.map.slice(0, 80).map((m) => `<tr><td><code>${esc(m.vtex)}</code></td><td>${m.faststore ? `<code>${esc(m.faststore)}</code>` : "<em>custom-component</em>"}</td><td>${m.confidence || "—"}</td><td>${m.count}</td></tr>`).join("") : "";
59503
+ const iconRows = t && b.assets.icons.length ? b.assets.icons.slice(0, 40).map((ic) => `<tr><td>${esc(ic.kind)}</td><td><code>${esc(ic.id)}</code></td><td>${ic.count}</td></tr>`).join("") : "";
59504
+ return `<!doctype html>
59505
+ <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
59506
+ <title>parity migrate — ${esc(b.url)}</title>
59507
+ <style>
59508
+ :root { --bg:#0d1117; --card:#161b22; --line:#30363d; --fg:#e6edf3; --dim:#8b949e; --accent:#2f81f7; }
59509
+ * { box-sizing:border-box; }
59510
+ body { margin:0; background:var(--bg); color:var(--fg); font:14px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif; }
59511
+ header { padding:24px 32px; border-bottom:1px solid var(--line); }
59512
+ h1 { margin:0 0 6px; font-size:20px; }
59513
+ h2 { font-size:15px; text-transform:uppercase; letter-spacing:.04em; color:var(--dim); margin:0 0 12px; }
59514
+ .meta { color:var(--dim); font-size:13px; }
59515
+ .meta code { color:var(--fg); }
59516
+ main { padding:24px 32px; max-width:1100px; margin:0 auto; display:grid; gap:24px; }
59517
+ .card { background:var(--card); border:1px solid var(--line); border-radius:10px; padding:20px; }
59518
+ .swatches { display:flex; gap:20px; flex-wrap:wrap; }
59519
+ .sw { display:flex; flex-direction:column; gap:4px; }
59520
+ .sw b { font-size:12px; } .sw span { color:var(--dim); font-size:12px; font-family:monospace; }
59521
+ .chip { width:64px; height:64px; border-radius:8px; border:1px solid var(--line); }
59522
+ .chip.empty { background:repeating-linear-gradient(45deg,#222,#222 6px,#333 6px,#333 12px); }
59523
+ figure { margin:0; } figure img { max-width:100%; border:1px solid var(--line); border-radius:8px; display:block; }
59524
+ figcaption { color:var(--dim); font-size:12px; margin-bottom:6px; text-transform:capitalize; }
59525
+ .shots { display:grid; grid-template-columns:repeat(auto-fit,minmax(280px,1fr)); gap:16px; }
59526
+ table { width:100%; border-collapse:collapse; font-size:13px; }
59527
+ th,td { text-align:left; padding:6px 10px; border-bottom:1px solid var(--line); vertical-align:top; }
59528
+ th { color:var(--dim); font-weight:600; }
59529
+ code { background:#0b0f14; padding:1px 5px; border-radius:4px; font-size:12px; }
59530
+ a { color:var(--accent); text-decoration:none; } a:hover { text-decoration:underline; }
59531
+ .badge { background:#1f6feb33; color:#79c0ff; padding:0 6px; border-radius:10px; font-size:11px; }
59532
+ .assets { display:flex; gap:24px; align-items:center; flex-wrap:wrap; }
59533
+ .assets img { max-height:48px; max-width:200px; background:#fff; padding:6px; border-radius:6px; }
59534
+ ul.kv { list-style:none; padding:0; margin:0; display:grid; gap:6px; }
59535
+ .links a { margin-right:16px; }
59536
+ .dim { color:var(--dim); }
59537
+ </style></head>
59538
+ <body>
59539
+ <header>
59540
+ <h1>parity migrate — ${esc(b.url)}</h1>
59541
+ <div class="meta">
59542
+ <code>${esc(b.platform)}</code>${b.target ? ` → <code>${esc(b.target)}</code>` : ""}
59543
+ · viewports: <code>${esc((b.viewports ?? [b.viewport]).join(", "))}</code>
59544
+ · pages: ${b.pages.map((p) => `<code>${esc(p.kind)}</code>`).join(" ") || "—"}
59545
+ · <span class="dim">${esc(b.timestamp)}</span>
59546
+ </div>
59547
+ </header>
59548
+ <main>
59549
+
59550
+ <section class="card">
59551
+ <h2>Theme</h2>
59552
+ <div class="swatches">
59553
+ ${swatch("primary", t.colors.primary)}
59554
+ ${swatch("secondary", t.colors.secondary)}
59555
+ ${swatch("background", t.colors.background)}
59556
+ ${swatch("text", t.colors.text)}
59557
+ </div>
59558
+ <ul class="kv" style="margin-top:16px">
59559
+ <li><b>Fonts:</b> ${chips(t.typography.fontFamilies)}</li>
59560
+ <li><b>Font sizes:</b> ${chips(t.typography.sizeScale)}</li>
59561
+ <li><b>Spacing:</b> ${chips(t.spacingScale)}</li>
59562
+ <li><b>Radii:</b> ${chips(t.radii)}</li>
59563
+ <li><b>Breakpoints:</b> ${chips(t.breakpoints)}</li>
59564
+ <li><b>Motion:</b> ${chips([...t.motion.durations, ...t.motion.easings])}</li>
59565
+ </ul>
59566
+ </section>
59567
+
59568
+ ${shots ? `<section class="card"><h2>Screenshots by viewport</h2><div class="shots">${shots}</div></section>` : ""}
59569
+
59570
+ <section class="card">
59571
+ <h2>Brand assets</h2>
59572
+ <div class="assets">
59573
+ ${(() => {
59574
+ const s = embed(b.assets.logo);
59575
+ return s ? `<div><div class="dim">logo</div><img src="${esc(s)}" alt="logo"></div>` : '<span class="dim">no logo</span>';
59576
+ })()}
59577
+ ${(() => {
59578
+ const s = embed(b.assets.favicon);
59579
+ return s ? `<div><div class="dim">favicon</div><img src="${esc(s)}" alt="favicon" style="max-height:32px"></div>` : "";
59580
+ })()}
59581
+ <div class="dim">${b.assets.icons.length} icons · ${b.assets.fontFiles.length}/${b.assets.fonts.length} web fonts downloaded${b.assets.fontFiles.length ? " → assets/fonts/" : ""}</div>
59582
+ </div>
59583
+ ${iconRows ? `<table style="margin-top:16px"><tr><th>kind</th><th>id</th><th>count</th></tr>${iconRows}</table>` : ""}
59584
+ </section>
59585
+
59586
+ ${b.vtex ? `<section class="card"><h2>VTEX IO → FastStore blocks</h2><p class="dim">${b.vtex.blocks.length} block instances from the store runtime · ${b.vtex.blocks.filter((x) => x.props).length} carry CMS content (props), ${countContentImages(b.vtex.blocks)} content images downloaded to <code>assets/content/</code> (URLs rewritten in <code>blocks.json</code>). <b>confidence</b> = how sure the deterministic mapper is (0–1).</p><table><tr><th>VTEX block</th><th>→ FastStore</th><th>confidence</th><th>count</th></tr>${vtexRows}</table></section>` : ""}
59587
+
59588
+ <section class="card">
59589
+ <h2>Components (${b.components.length})</h2>
59590
+ <table>
59591
+ <tr><th>scope</th><th>role</th><th>tw</th><th>interactions</th><th>e2e keys</th><th>folder</th></tr>
59592
+ ${componentRows}
59593
+ </table>
59594
+ </section>
59595
+
59596
+ <section class="card links">
59597
+ <h2>Files</h2>
59598
+ <a href="MIGRATION_PROMPT.md">MIGRATION_PROMPT.md</a>
59599
+ <a href="index.md">index.md</a>
59600
+ ${b.target === "faststore" ? '<a href="custom-theme.scss">custom-theme.scss</a>' : ""}
59601
+ ${b.vtex ? '<a href="component-map.json">component-map.json</a> <a href="blocks.json">blocks.json</a>' : ""}
59602
+ <a href="manifest.json">manifest.json (full)</a>
59603
+ </section>
59604
+
59605
+ </main></body></html>`;
59606
+ }
59607
+
59228
59608
  // src/migrate/prompt.ts
59229
59609
  function buildMigrationPrompt(bundle, playbook) {
59230
59610
  const lines = [];
@@ -59470,10 +59850,28 @@ function mergeRawThemeSamples(list) {
59470
59850
  motionEasings: concat("motionEasings")
59471
59851
  };
59472
59852
  }
59853
+ function plausibleDuration(d) {
59854
+ const v = d.trim();
59855
+ if (!v || v === "0s" || v === "0ms")
59856
+ return false;
59857
+ const n = Number.parseFloat(v);
59858
+ if (Number.isNaN(n))
59859
+ return false;
59860
+ const seconds = v.endsWith("ms") ? n / 1000 : n;
59861
+ return seconds > 0 && seconds <= 10;
59862
+ }
59863
+ function isOpaque(color) {
59864
+ const c = parseRgb(color);
59865
+ return !c || c.a >= 0.5;
59866
+ }
59473
59867
  function aggregateTheme(raw) {
59474
59868
  const paletteRanked = rank([...raw.colors, ...raw.backgrounds]);
59475
- const interactiveRanked = rank(raw.interactiveBackgrounds);
59476
- const chromatic = [...interactiveRanked.keys()].filter((c) => !isNeutral(c));
59869
+ const chromaticRanked = rank([
59870
+ ...raw.colors,
59871
+ ...raw.backgrounds,
59872
+ ...raw.interactiveBackgrounds
59873
+ ]);
59874
+ const chromatic = [...chromaticRanked.keys()].filter((c) => !isNeutral(c) && isOpaque(c));
59477
59875
  const primary = chromatic[0] ?? null;
59478
59876
  const secondary = chromatic.find((c) => c !== primary) ?? null;
59479
59877
  const tokens = {};
@@ -59481,8 +59879,10 @@ function aggregateTheme(raw) {
59481
59879
  tokens.primary = primary;
59482
59880
  if (secondary)
59483
59881
  tokens.secondary = secondary;
59484
- if (raw.bodyBackground && !TRANSPARENT.has(raw.bodyBackground.trim()))
59485
- tokens.background = raw.bodyBackground.trim();
59882
+ const bodyBg = raw.bodyBackground.trim();
59883
+ const background = bodyBg && !TRANSPARENT.has(bodyBg) && isOpaque(bodyBg) ? bodyBg : [...rank(raw.backgrounds).keys()].find((c) => isOpaque(c)) ?? null;
59884
+ if (background)
59885
+ tokens.background = background;
59486
59886
  if (raw.bodyText)
59487
59887
  tokens.text = raw.bodyText.trim();
59488
59888
  const palette = [...paletteRanked.entries()].map(([value, count]) => ({
@@ -59505,9 +59905,9 @@ function aggregateTheme(raw) {
59505
59905
  spacingScale: sortByPx(raw.spacings),
59506
59906
  radii: sortByPx(raw.radii).filter((r) => r !== "0px"),
59507
59907
  shadows: [...new Set(raw.shadows.map((s) => s.trim()))].filter((s) => s && s !== "none"),
59508
- breakpoints: sortByPx(raw.breakpoints),
59908
+ breakpoints: sortByPx([...rank(raw.breakpoints).keys()].slice(0, 14)),
59509
59909
  motion: {
59510
- durations: [...new Set(raw.motionDurations.map((d) => d.trim()))].filter((d) => d && d !== "0s" && d !== "0ms"),
59910
+ durations: [...new Set(raw.motionDurations.map((d) => d.trim()))].filter(plausibleDuration),
59511
59911
  easings: [...new Set(raw.motionEasings.map((e) => e.trim()))].filter((e) => e && e !== "ease" && e !== "linear")
59512
59912
  },
59513
59913
  tokens
@@ -59657,6 +60057,26 @@ function parentTreePath(treePath) {
59657
60057
  const i = treePath.lastIndexOf("/");
59658
60058
  return i > 0 ? treePath.slice(0, i) : null;
59659
60059
  }
60060
+ async function readVtexStateImages(page) {
60061
+ try {
60062
+ return await page.evaluate(() => {
60063
+ const w = window;
60064
+ const st = w.__STATE__ ?? w.__APOLLO_STATE__;
60065
+ if (!st)
60066
+ return [];
60067
+ let s;
60068
+ try {
60069
+ s = JSON.stringify(st);
60070
+ } catch {
60071
+ return [];
60072
+ }
60073
+ const re = /https?:\/\/[^"'\\ ]*(?:vtexassets\.com|vteximg\.com\.br)[^"'\\ ]*\.(?:jpe?g|png|webp|gif|avif)/gi;
60074
+ return [...new Set(s.match(re) ?? [])].slice(0, 300);
60075
+ });
60076
+ } catch {
60077
+ return [];
60078
+ }
60079
+ }
59660
60080
  async function readVtexBlockTree(page) {
59661
60081
  let paths;
59662
60082
  try {
@@ -59664,10 +60084,21 @@ async function readVtexBlockTree(page) {
59664
60084
  const rt = window.__RUNTIME__;
59665
60085
  if (!rt || !rt.extensions || typeof rt.extensions !== "object")
59666
60086
  return null;
59667
- return Object.entries(rt.extensions).map(([treePath, ext]) => ({
59668
- treePath,
59669
- component: ext && typeof ext === "object" && "component" in ext ? ext.component ?? null : null
59670
- }));
60087
+ return Object.entries(rt.extensions).map(([treePath, ext]) => {
60088
+ const e = ext && typeof ext === "object" ? ext : {};
60089
+ let props = null;
60090
+ if (e.props && typeof e.props === "object") {
60091
+ try {
60092
+ const clean = JSON.parse(JSON.stringify(e.props));
60093
+ for (const k of ["children", "__context", "context"])
60094
+ delete clean[k];
60095
+ props = Object.keys(clean).length ? clean : null;
60096
+ } catch {
60097
+ props = null;
60098
+ }
60099
+ }
60100
+ return { treePath, component: e.component ?? null, props };
60101
+ });
59671
60102
  });
59672
60103
  } catch {
59673
60104
  return null;
@@ -59678,7 +60109,8 @@ async function readVtexBlockTree(page) {
59678
60109
  treePath: p.treePath,
59679
60110
  blockName: blockNameFromTreePath(p.treePath),
59680
60111
  component: p.component,
59681
- parent: parentTreePath(p.treePath)
60112
+ parent: parentTreePath(p.treePath),
60113
+ props: p.props
59682
60114
  })).filter((b) => b.blockName.length > 0 && !b.blockName.startsWith("$"));
59683
60115
  }
59684
60116
 
@@ -59851,7 +60283,7 @@ async function migrateCommand(opts) {
59851
60283
  const allowlist = parseAllowlist2(opts.components);
59852
60284
  const host = safeHost5(opts.url);
59853
60285
  const runDir = resolve3(opts.outDir, host);
59854
- mkdirSync14(runDir, { recursive: true });
60286
+ mkdirSync15(runDir, { recursive: true });
59855
60287
  const browser = await launchBrowser({ headless: true });
59856
60288
  try {
59857
60289
  const themePath = resolve3(runDir, "theme.json");
@@ -59873,7 +60305,7 @@ async function migrateCommand(opts) {
59873
60305
  console.log(chalk16.dim(" phase 1 theme+assets: cached"));
59874
60306
  } else {
59875
60307
  console.log(chalk16.dim(` phase 1 theme+assets: scraping (${viewports.join(", ")})…`));
59876
- mkdirSync14(resolve3(runDir, "screenshots"), { recursive: true });
60308
+ mkdirSync15(resolve3(runDir, "screenshots"), { recursive: true });
59877
60309
  const samples = [];
59878
60310
  screenshots = [];
59879
60311
  let platformSeen = null;
@@ -59886,6 +60318,18 @@ async function migrateCommand(opts) {
59886
60318
  await page.waitForLoadState("networkidle", { timeout: 8000 }).catch(() => {
59887
60319
  return;
59888
60320
  });
60321
+ await Promise.race([stabilizeCarousels(page).catch(() => {
60322
+ return;
60323
+ }), sleep2(3000)]);
60324
+ await Promise.race([scrollFullPage(page, 30000).catch(() => {
60325
+ return;
60326
+ }), sleep2(32000)]);
60327
+ await Promise.race([
60328
+ waitForSkeletonsToResolve(page, 5000).catch(() => {
60329
+ return;
60330
+ }),
60331
+ sleep2(5000)
60332
+ ]);
59889
60333
  samples.push(await scrapeThemeSamples(page));
59890
60334
  const shot = resolve3(runDir, "screenshots", `${vp}.png`);
59891
60335
  await page.screenshot({ path: shot, fullPage: true, animations: "disabled", timeout: 15000 }).then(() => screenshots.push({ viewport: vp, path: `screenshots/${vp}.png` })).catch(() => {
@@ -59896,7 +60340,27 @@ async function migrateCommand(opts) {
59896
60340
  const rawAssets = await collectSiteAssets(page);
59897
60341
  const fetchBytes = async (url) => await browserFetchBytes(page, url) ?? await nodeFetchBytes(url);
59898
60342
  assetsResolved = await downloadSiteAssets(rawAssets, runDir, fetchBytes);
60343
+ if (rawAssets.logo) {
60344
+ const logoPng = resolve3(runDir, "assets", "logo.png");
60345
+ const ok = await page.locator("[data-parity-logo]").first().screenshot({ path: logoPng, timeout: 8000 }).then(() => true).catch(() => false);
60346
+ if (ok) {
60347
+ assetsResolved.logo = "assets/logo.png";
60348
+ assetsResolved.logoSource = assetsResolved.logoSource ?? "screenshot";
60349
+ }
60350
+ }
59899
60351
  vtexBlocks = await readVtexBlockTree(page);
60352
+ if (vtexBlocks) {
60353
+ const refMap = collectImageRefs(vtexBlocks, opts.url);
60354
+ vtexBlocks = rewriteBlockUrls(vtexBlocks, refMap);
60355
+ const stateImages = await readVtexStateImages(page);
60356
+ const absUrls = [...new Set([...Object.values(refMap), ...stateImages])];
60357
+ const { map: map2, downloaded, skipped } = await downloadContentImages(absUrls, runDir, fetchBytes);
60358
+ if (Object.keys(map2).length)
60359
+ writeFileSync21(resolve3(runDir, "content-assets.json"), `${JSON.stringify(map2, null, 2)}
60360
+ `, "utf8");
60361
+ if (absUrls.length)
60362
+ console.log(chalk16.dim(` vtex content: ${absUrls.length} image URLs (${Object.keys(refMap).length} CMS + ${stateImages.length} catalog) · ${downloaded} downloaded${skipped ? ` (${skipped} over cap skipped)` : ""}`));
60363
+ }
59900
60364
  }
59901
60365
  } finally {
59902
60366
  await page.close().catch(() => {
@@ -59910,12 +60374,12 @@ async function migrateCommand(opts) {
59910
60374
  theme = aggregateTheme(mergeRawThemeSamples(samples));
59911
60375
  platform = platformSeen ?? "custom";
59912
60376
  assets = assetsResolved;
59913
- writeFileSync19(themePath, `${JSON.stringify(theme, null, 2)}
60377
+ writeFileSync21(themePath, `${JSON.stringify(theme, null, 2)}
59914
60378
  `, "utf8");
59915
- writeFileSync19(assetsPath, `${JSON.stringify({ platform, assets, screenshots }, null, 2)}
60379
+ writeFileSync21(assetsPath, `${JSON.stringify({ platform, assets, screenshots }, null, 2)}
59916
60380
  `, "utf8");
59917
60381
  if (vtexBlocks) {
59918
- writeFileSync19(blocksPath, `${JSON.stringify(vtexBlocks, null, 2)}
60382
+ writeFileSync21(blocksPath, `${JSON.stringify(vtexBlocks, null, 2)}
59919
60383
  `, "utf8");
59920
60384
  console.log(chalk16.dim(` vtex io: ${vtexBlocks.length} blocks read from runtime`));
59921
60385
  }
@@ -59947,7 +60411,7 @@ async function migrateCommand(opts) {
59947
60411
  });
59948
60412
  }
59949
60413
  const classified = sitemapUrls.slice(0, 500).map((u) => ({ url: u, kind: kindOf(u) }));
59950
- writeFileSync19(sitemapPath, `${JSON.stringify({ pages: resolvedPages, sitemapUrls: classified }, null, 2)}
60414
+ writeFileSync21(sitemapPath, `${JSON.stringify({ pages: resolvedPages, sitemapUrls: classified }, null, 2)}
59951
60415
  `, "utf8");
59952
60416
  }
59953
60417
  if (resolvedPages.length === 0) {
@@ -59969,7 +60433,7 @@ async function migrateCommand(opts) {
59969
60433
  llm: !opts.noLlm,
59970
60434
  runDir
59971
60435
  }));
59972
- writeFileSync19(capturePath, `${JSON.stringify({ pages, components }, null, 2)}
60436
+ writeFileSync21(capturePath, `${JSON.stringify({ pages, components }, null, 2)}
59973
60437
  `, "utf8");
59974
60438
  }
59975
60439
  const bundle = {
@@ -59990,13 +60454,14 @@ async function migrateCommand(opts) {
59990
60454
  await jsonExporter2.export(bundle, runDir);
59991
60455
  if (format === "md" || format === "both") {
59992
60456
  await markdownExporter2.export(bundle, runDir);
59993
- writeFileSync19(resolve3(runDir, "MIGRATION_PROMPT.md"), buildMigrationPrompt(bundle, playbook), "utf8");
60457
+ await htmlExporter.export(bundle, runDir);
60458
+ writeFileSync21(resolve3(runDir, "MIGRATION_PROMPT.md"), buildMigrationPrompt(bundle, playbook), "utf8");
59994
60459
  }
59995
60460
  if (opts.target === "faststore") {
59996
- writeFileSync19(resolve3(runDir, "custom-theme.scss"), buildFastStoreTheme(theme), "utf8");
60461
+ writeFileSync21(resolve3(runDir, "custom-theme.scss"), buildFastStoreTheme(theme), "utf8");
59997
60462
  }
59998
60463
  if (bundle.vtex) {
59999
- writeFileSync19(resolve3(runDir, "component-map.json"), `${JSON.stringify(bundle.vtex.map, null, 2)}
60464
+ writeFileSync21(resolve3(runDir, "component-map.json"), `${JSON.stringify(bundle.vtex.map, null, 2)}
60000
60465
  `, "utf8");
60001
60466
  }
60002
60467
  if (opts.json) {
@@ -60004,6 +60469,11 @@ async function migrateCommand(opts) {
60004
60469
  return 0;
60005
60470
  }
60006
60471
  printResults4(runDir, bundle);
60472
+ if (opts.open && format !== "json") {
60473
+ await open(resolve3(runDir, "report.html")).catch(() => {
60474
+ return;
60475
+ });
60476
+ }
60007
60477
  return 0;
60008
60478
  } finally {
60009
60479
  await browser.close().catch(() => {
@@ -60173,10 +60643,12 @@ function printResults4(runDir, bundle) {
60173
60643
  console.log(chalk16.dim(` platform: ${bundle.platform}${bundle.target ? ` → ${bundle.target}` : ""}`));
60174
60644
  console.log(chalk16.dim(` viewports:${(bundle.viewports ?? [bundle.viewport]).join(", ")}`));
60175
60645
  console.log(chalk16.dim(` theme: primary=${bundle.theme.colors.primary ?? "—"} text=${bundle.theme.colors.text ?? "—"}`));
60176
- console.log(chalk16.dim(` assets: logo=${bundle.assets.logo ? "✓" : "✗"} favicon=${bundle.assets.favicon ? "✓" : "✗"} icons=${bundle.assets.icons.length}`));
60646
+ console.log(chalk16.dim(` assets: logo=${bundle.assets.logo ? "✓" : "✗"} favicon=${bundle.assets.favicon ? "✓" : "✗"} icons=${bundle.assets.icons.length} fonts=${bundle.assets.fontFiles.length}`));
60177
60647
  if (bundle.vtex) {
60178
60648
  const mapped = bundle.vtex.map.filter((m) => m.strategy === "mapped").length;
60179
- console.log(chalk16.dim(` vtex io: ${bundle.vtex.blocks.length} blocks · ${mapped}/${bundle.vtex.map.length} block types mapped to FastStore`));
60649
+ const withContent = bundle.vtex.blocks.filter((x) => x.props).length;
60650
+ const contentImgs = countContentImages(bundle.vtex.blocks);
60651
+ console.log(chalk16.dim(` vtex io: ${bundle.vtex.blocks.length} blocks (${withContent} with CMS content, ${contentImgs} content images local) · ${mapped}/${bundle.vtex.map.length} mapped`));
60180
60652
  }
60181
60653
  console.log(chalk16.dim(` pages: ${bundle.pages.map((p) => p.kind).join(", ") || "—"}`));
60182
60654
  console.log(chalk16.dim(` out: ${runDir}`));
@@ -60189,7 +60661,7 @@ function printResults4(runDir, bundle) {
60189
60661
  }
60190
60662
  function readJson(path) {
60191
60663
  try {
60192
- return JSON.parse(readFileSync13(path, "utf8"));
60664
+ return JSON.parse(readFileSync14(path, "utf8"));
60193
60665
  } catch {
60194
60666
  return null;
60195
60667
  }
@@ -60235,13 +60707,13 @@ function sleep2(ms) {
60235
60707
  }
60236
60708
 
60237
60709
  // src/commands/pr.ts
60238
- import { existsSync as existsSync15, readFileSync as readFileSync16, writeFileSync as writeFileSync20 } from "node:fs";
60239
- import { join as join22 } from "node:path";
60710
+ import { existsSync as existsSync15, readFileSync as readFileSync17, writeFileSync as writeFileSync22 } from "node:fs";
60711
+ import { join as join24 } from "node:path";
60240
60712
  import chalk19 from "chalk";
60241
60713
 
60242
60714
  // src/commands/run.ts
60243
- import { existsSync as existsSync14, readFileSync as readFileSync15, unlinkSync as unlinkSync3 } from "node:fs";
60244
- import { join as join21 } from "node:path";
60715
+ import { existsSync as existsSync14, readFileSync as readFileSync16, unlinkSync as unlinkSync3 } from "node:fs";
60716
+ import { join as join23 } from "node:path";
60245
60717
  import chalk18 from "chalk";
60246
60718
  import ora6 from "ora";
60247
60719
 
@@ -60721,10 +61193,10 @@ import { existsSync as existsSync13 } from "node:fs";
60721
61193
  import chalk17 from "chalk";
60722
61194
 
60723
61195
  // src/server/proxy-server.ts
60724
- import { existsSync as existsSync12, readFileSync as readFileSync14, statSync } from "node:fs";
61196
+ import { existsSync as existsSync12, readFileSync as readFileSync15, statSync } from "node:fs";
60725
61197
  import { createServer } from "node:http";
60726
- import { extname, join as join20, normalize as normalize3, resolve as resolve4, sep } from "node:path";
60727
- var MIME = {
61198
+ import { extname, join as join22, normalize as normalize3, resolve as resolve4, sep } from "node:path";
61199
+ var MIME2 = {
60728
61200
  ".html": "text/html; charset=utf-8",
60729
61201
  ".css": "text/css; charset=utf-8",
60730
61202
  ".js": "application/javascript; charset=utf-8",
@@ -60817,13 +61289,13 @@ async function handleRequest(req, res, runDir) {
60817
61289
  return serveStatic(res, runDir, path);
60818
61290
  }
60819
61291
  function serveReportHtml(res, runDir) {
60820
- const filePath = join20(runDir, "report.html");
61292
+ const filePath = join22(runDir, "report.html");
60821
61293
  if (!existsSync12(filePath)) {
60822
61294
  res.statusCode = 404;
60823
61295
  res.end("report.html not found");
60824
61296
  return;
60825
61297
  }
60826
- const html3 = readFileSync14(filePath, "utf8");
61298
+ const html3 = readFileSync15(filePath, "utf8");
60827
61299
  const inject = `<script>window.__parity_proxy = "/proxy?url=";</script>`;
60828
61300
  const out = html3.includes("</head>") ? html3.replace("</head>", `${inject}</head>`) : `${inject}${html3}`;
60829
61301
  res.statusCode = 200;
@@ -60852,9 +61324,9 @@ function serveStatic(res, runDir, path) {
60852
61324
  }
60853
61325
  const ext = extname(filePath).toLowerCase();
60854
61326
  res.statusCode = 200;
60855
- res.setHeader("content-type", MIME[ext] ?? "application/octet-stream");
61327
+ res.setHeader("content-type", MIME2[ext] ?? "application/octet-stream");
60856
61328
  res.setHeader("cache-control", "no-store");
60857
- res.end(readFileSync14(filePath));
61329
+ res.end(readFileSync15(filePath));
60858
61330
  }
60859
61331
  async function proxyRequest(req, res, targetUrl, opts = {}) {
60860
61332
  let target;
@@ -60964,8 +61436,8 @@ async function serveRunAndBlock(runDir, opts = {}) {
60964
61436
  console.log(chalk17.dim(` Ctrl+C pra parar (2x pra forçar saída).
60965
61437
  `));
60966
61438
  if (opts.open !== false) {
60967
- const { default: open } = await import("open");
60968
- await open(handle.url).catch(() => {
61439
+ const { default: open2 } = await import("open");
61440
+ await open2(handle.url).catch(() => {
60969
61441
  return;
60970
61442
  });
60971
61443
  }
@@ -61214,7 +61686,7 @@ async function runCommand(rawOpts) {
61214
61686
  }
61215
61687
  const ignore = loadParityIgnore();
61216
61688
  if (opts.clearCache) {
61217
- const cacheFile = join21(opts.output, "cache", "verdicts.json");
61689
+ const cacheFile = join23(opts.output, "cache", "verdicts.json");
61218
61690
  if (existsSync14(cacheFile)) {
61219
61691
  try {
61220
61692
  unlinkSync3(cacheFile);
@@ -61411,8 +61883,8 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
61411
61883
  const traceEnabled = process.env.PARITY_TRACE === "1";
61412
61884
  const runOneSide = async (viewport, side) => {
61413
61885
  const baseUrl = side === "prod" ? opts.prod : opts.cand;
61414
- const harPath = join21(paths.harDir, `${viewport}-${side}.har`);
61415
- const tracePath = traceEnabled ? join21(paths.tracesDir, `${viewport}-${side}.zip`) : null;
61886
+ const harPath = join23(paths.harDir, `${viewport}-${side}.har`);
61887
+ const tracePath = traceEnabled ? join23(paths.tracesDir, `${viewport}-${side}.zip`) : null;
61416
61888
  const ctx = await newContext(browser, {
61417
61889
  viewport,
61418
61890
  harPath,
@@ -61728,7 +62200,7 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
61728
62200
  setSpinnerLabel("Rodando checks…");
61729
62201
  spinner.start();
61730
62202
  const checksHb = attachSpinnerHeartbeat(spinner, { baseText: "Rodando checks…" });
61731
- const cacheDir = join21(opts.output, "cache");
62203
+ const cacheDir = join23(opts.output, "cache");
61732
62204
  const checkCtx = {
61733
62205
  prodPages: allPageCaptures.filter((p) => p.side === "prod"),
61734
62206
  candPages: allPageCaptures.filter((p) => p.side === "cand"),
@@ -61913,7 +62385,7 @@ function resolveExplicitPages(pagesFile, pagesList) {
61913
62385
  if (!existsSync14(pagesFile)) {
61914
62386
  throw new Error(`--pages-file não encontrado: ${pagesFile}`);
61915
62387
  }
61916
- const raw = readFileSync15(pagesFile, "utf-8");
62388
+ const raw = readFileSync16(pagesFile, "utf-8");
61917
62389
  const lines = raw.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("#"));
61918
62390
  return lines.map(normalizePath);
61919
62391
  }
@@ -62135,15 +62607,15 @@ async function prCommand(opts) {
62135
62607
  return runCode || 1;
62136
62608
  }
62137
62609
  const latest = runs[0];
62138
- const reportJsonPath = join22(opts.output, "runs", latest.id, "report.json");
62610
+ const reportJsonPath = join24(opts.output, "runs", latest.id, "report.json");
62139
62611
  if (!existsSync15(reportJsonPath)) {
62140
62612
  console.error(chalk19.red(`report.json not found at ${reportJsonPath}`));
62141
62613
  return runCode || 1;
62142
62614
  }
62143
- const run = JSON.parse(readFileSync16(reportJsonPath, "utf8"));
62615
+ const run = JSON.parse(readFileSync17(reportJsonPath, "utf8"));
62144
62616
  const markdown = buildPrComment(run, opts);
62145
62617
  if (opts.out) {
62146
- writeFileSync20(opts.out, markdown, "utf8");
62618
+ writeFileSync22(opts.out, markdown, "utf8");
62147
62619
  console.log(chalk19.dim(` wrote PR comment: ${opts.out}`));
62148
62620
  } else {
62149
62621
  process.stdout.write(`
@@ -62152,7 +62624,7 @@ ${markdown}
62152
62624
  }
62153
62625
  if (opts.github && process.env.GITHUB_STEP_SUMMARY) {
62154
62626
  try {
62155
- writeFileSync20(process.env.GITHUB_STEP_SUMMARY, markdown, { flag: "a" });
62627
+ writeFileSync22(process.env.GITHUB_STEP_SUMMARY, markdown, { flag: "a" });
62156
62628
  } catch (err) {
62157
62629
  console.error(chalk19.yellow(`failed to write GITHUB_STEP_SUMMARY: ${err.message}`));
62158
62630
  }
@@ -62213,7 +62685,7 @@ function buildPrComment(run, opts) {
62213
62685
  }
62214
62686
 
62215
62687
  // src/commands/prompt.ts
62216
- import { existsSync as existsSync16, writeFileSync as writeFileSync21 } from "node:fs";
62688
+ import { existsSync as existsSync16, writeFileSync as writeFileSync23 } from "node:fs";
62217
62689
  import chalk20 from "chalk";
62218
62690
  function promptCommand(runId, opts) {
62219
62691
  let run;
@@ -62228,7 +62700,7 @@ function promptCommand(runId, opts) {
62228
62700
  limit: opts.limit
62229
62701
  });
62230
62702
  if (opts.out) {
62231
- writeFileSync21(opts.out, md, "utf8");
62703
+ writeFileSync23(opts.out, md, "utf8");
62232
62704
  console.log(chalk20.green(`✔ prompt salvo em ${opts.out}`));
62233
62705
  if (existsSync16(opts.out)) {
62234
62706
  const sizeKb = (md.length / 1024).toFixed(1);
@@ -62241,9 +62713,9 @@ function promptCommand(runId, opts) {
62241
62713
  }
62242
62714
 
62243
62715
  // src/commands/report.ts
62244
- import { existsSync as existsSync17, readFileSync as readFileSync17 } from "node:fs";
62716
+ import { existsSync as existsSync17, readFileSync as readFileSync18 } from "node:fs";
62245
62717
  import chalk21 from "chalk";
62246
- import open from "open";
62718
+ import open2 from "open";
62247
62719
 
62248
62720
  // src/report/extract-section.ts
62249
62721
  function extractReportSection(input) {
@@ -62406,7 +62878,7 @@ async function reportCommand(runId, opts) {
62406
62878
  console.error(chalk21.red(`report.html not found at ${paths.reportHtml}`));
62407
62879
  return 1;
62408
62880
  }
62409
- const html3 = readFileSync17(paths.reportHtml, "utf8");
62881
+ const html3 = readFileSync18(paths.reportHtml, "utf8");
62410
62882
  const slice2 = extractReportSection({ kind: "html", section: opts.section, html: html3 });
62411
62883
  if (slice2 === null) {
62412
62884
  console.error(chalk21.red(`section "${opts.section}" not present in this report`));
@@ -62416,15 +62888,15 @@ async function reportCommand(runId, opts) {
62416
62888
  return 0;
62417
62889
  }
62418
62890
  console.log(chalk21.dim(`opening ${paths.reportHtml}`));
62419
- await open(paths.reportHtml).catch((err) => {
62891
+ await open2(paths.reportHtml).catch((err) => {
62420
62892
  console.error(chalk21.red(`failed to open: ${err.message}`));
62421
62893
  });
62422
62894
  return 0;
62423
62895
  }
62424
62896
 
62425
62897
  // src/commands/vitals.ts
62426
- import { existsSync as existsSync18, readFileSync as readFileSync18, writeFileSync as writeFileSync22 } from "node:fs";
62427
- import { join as join23 } from "node:path";
62898
+ import { existsSync as existsSync18, readFileSync as readFileSync19, writeFileSync as writeFileSync24 } from "node:fs";
62899
+ import { join as join25 } from "node:path";
62428
62900
  import chalk22 from "chalk";
62429
62901
  import ora7 from "ora";
62430
62902
  async function vitalsCommand(opts) {
@@ -62532,7 +63004,7 @@ async function vitalsCommand(opts) {
62532
63004
  writeRunReportJson(paths.runDir, run);
62533
63005
  const html3 = renderHtmlReport(run, paths.runDir);
62534
63006
  writeRunReportHtml(paths.runDir, html3);
62535
- writeFileSync22(join23(paths.runDir, "vitals.json"), `${JSON.stringify({
63007
+ writeFileSync24(join25(paths.runDir, "vitals.json"), `${JSON.stringify({
62536
63008
  schemaVersion: "0.1",
62537
63009
  prodUrl: opts.prod,
62538
63010
  candUrl: opts.cand,
@@ -62547,8 +63019,8 @@ async function vitalsCommand(opts) {
62547
63019
  console.log(chalk22.dim(` \uD83D\uDCA1 use 'parity serve ${runId}' pra preview iframe`));
62548
63020
  console.log("");
62549
63021
  if (opts.open) {
62550
- const { default: open2 } = await import("open");
62551
- await open2(paths.reportHtml).catch(() => {
63022
+ const { default: open3 } = await import("open");
63023
+ await open3(paths.reportHtml).catch(() => {
62552
63024
  return;
62553
63025
  });
62554
63026
  }
@@ -62632,7 +63104,7 @@ function parseUrlList(input) {
62632
63104
  if (input.startsWith("file:") || input.endsWith(".txt") || input.endsWith(".list")) {
62633
63105
  const path = input.replace(/^file:\/\//, "");
62634
63106
  if (existsSync18(path)) {
62635
- return readFileSync18(path, "utf8").split(/\r?\n/).map((s) => s.trim()).filter((s) => s && !s.startsWith("#")).map((s) => s.startsWith("/") ? s : `/${s}`);
63107
+ return readFileSync19(path, "utf8").split(/\r?\n/).map((s) => s.trim()).filter((s) => s && !s.startsWith("#")).map((s) => s.startsWith("/") ? s : `/${s}`);
62636
63108
  }
62637
63109
  }
62638
63110
  return input.split(",").map((s) => s.trim()).filter(Boolean).map((s) => s.startsWith("/") || s.startsWith("http") ? s : `/${s}`);
@@ -62656,7 +63128,7 @@ function printSummary6(vitals, cache) {
62656
63128
  }
62657
63129
 
62658
63130
  // src/util/version.ts
62659
- import { readFileSync as readFileSync19 } from "node:fs";
63131
+ import { readFileSync as readFileSync20 } from "node:fs";
62660
63132
  import { dirname as dirname5, resolve as resolve5 } from "node:path";
62661
63133
  import { fileURLToPath } from "node:url";
62662
63134
  function getPackageVersion() {
@@ -62665,7 +63137,7 @@ function getPackageVersion() {
62665
63137
  for (const up of ["..", "../..", "../../.."]) {
62666
63138
  try {
62667
63139
  const pkgPath = resolve5(here, up, "package.json");
62668
- const raw = readFileSync19(pkgPath, "utf8");
63140
+ const raw = readFileSync20(pkgPath, "utf8");
62669
63141
  const parsed = JSON.parse(raw);
62670
63142
  if (parsed.name === "@decocms/parity" && typeof parsed.version === "string") {
62671
63143
  return parsed.version;
@@ -62850,7 +63322,7 @@ program.command("extract").description("Single-site AI-ready component extractio
62850
63322
  json: opts.json
62851
63323
  }));
62852
63324
  });
62853
- program.command("migrate").description("Single-site, phased migration capture (theme → sitemap → components). No prod×cand comparison — produces a target-agnostic, token-lean bundle + prompt for a migration agent: site theme (colors/typography/spacing as Tailwind tokens), classified pages, and per-component detail (suggested Tailwind classes, interaction hints, e2e selectors). Works whether or not the source code exists. Pass --target faststore to append a target playbook. Resumable: re-runs skip a completed phase unless --refresh.").requiredOption("--url <url>", "Site to migrate from").option("--pages <list>", 'Comma-separated pages: literal paths/URLs, and/or "category-auto"/"pdp-auto". Default: "/,category-auto,pdp-auto" (home + a PLP + a PDP).').option("--components <list>", "Comma-separated role allowlist, e.g. header,footer,nav,shelf,minicart. Default: all detected.").option("--target <name>", "Target playbook to append to the prompt (e.g. faststore)").option("--viewport <viewport>", "Primary viewport for component capture: mobile | desktop | tablet", "mobile").option("--viewports <list>", "Comma-separated viewports for theme + site screenshots (e.g. mobile,desktop). Default: --viewport only.").option("--format <fmt>", "md | json | both", "both").option("--out <dir>", "Output directory (stable per host, for resume)", "./parity-migrate").option("--refresh", "Re-run all phases even if cached artifacts exist", false).option("--no-llm", "Skip the optional LLM component-relabeling pass (heuristic detection always runs regardless).").option("--json", "Emit one-line JSON instead of pretty text", false).action(async (opts) => {
63325
+ program.command("migrate").description("Single-site, phased migration capture (theme → sitemap → components). No prod×cand comparison — produces a target-agnostic, token-lean bundle + prompt for a migration agent: site theme (colors/typography/spacing as Tailwind tokens), classified pages, and per-component detail (suggested Tailwind classes, interaction hints, e2e selectors). Works whether or not the source code exists. Pass --target faststore to append a target playbook. Resumable: re-runs skip a completed phase unless --refresh.").requiredOption("--url <url>", "Site to migrate from").option("--pages <list>", 'Comma-separated pages: literal paths/URLs, and/or "category-auto"/"pdp-auto". Default: "/,category-auto,pdp-auto" (home + a PLP + a PDP).').option("--components <list>", "Comma-separated role allowlist, e.g. header,footer,nav,shelf,minicart. Default: all detected.").option("--target <name>", "Target playbook to append to the prompt (e.g. faststore)").option("--viewport <viewport>", "Primary viewport for component capture: mobile | desktop | tablet", "mobile").option("--viewports <list>", "Comma-separated viewports for theme + site screenshots (e.g. mobile,desktop). Default: --viewport only.").option("--format <fmt>", "md | json | both", "both").option("--out <dir>", "Output directory (stable per host, for resume)", "./parity-migrate").option("--refresh", "Re-run all phases even if cached artifacts exist", false).option("--open", "Open the generated index.html visual report in the browser", false).option("--no-llm", "Skip the optional LLM component-relabeling pass (heuristic detection always runs regardless).").option("--json", "Emit one-line JSON instead of pretty text", false).action(async (opts) => {
62854
63326
  process.exit(await migrateCommand({
62855
63327
  url: opts.url,
62856
63328
  pages: opts.pages,
@@ -62861,6 +63333,7 @@ program.command("migrate").description("Single-site, phased migration capture (t
62861
63333
  format: opts.format,
62862
63334
  outDir: opts.out,
62863
63335
  refresh: opts.refresh,
63336
+ open: opts.open,
62864
63337
  noLlm: !opts.llm,
62865
63338
  json: opts.json
62866
63339
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/parity",
3
- "version": "0.18.0",
3
+ "version": "0.20.0",
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",