truecanvas 0.6.7 → 0.6.8

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.
package/dist/cli.js CHANGED
@@ -146,8 +146,9 @@ async function createSnapshot(ws, shots, canvas, opts = {}) {
146
146
  used.add(slug);
147
147
  fs.writeFileSync(path.join(dir, "frames", `${slug}.html`), await freeze(raw, assets));
148
148
  fs.writeFileSync(path.join(dir, "frames", `${slug}.png`), raw.png);
149
+ if (raw.thumb) fs.writeFileSync(path.join(dir, "frames", `${slug}.thumb.jpg`), raw.thumb);
149
150
  const route = f.page && ws.config.framework === "next" ? routeOf(ws.config, f.page) : void 0;
150
- out.push({ name: f.frameName, x: f.x, y: f.y, width: raw.width, height: f.height ?? raw.height, theme: f.theme, device: f.device, html: `frames/${slug}.html`, image: `frames/${slug}.png`, ...route ? { route } : {} });
151
+ out.push({ name: f.frameName, x: f.x, y: f.y, width: raw.width, height: f.height ?? raw.height, theme: f.theme, device: f.device, html: `frames/${slug}.html`, image: `frames/${slug}.png`, ...raw.thumb ? { thumb: `frames/${slug}.thumb.jpg` } : {}, ...route ? { route } : {} });
151
152
  }
152
153
  const manifest = {
153
154
  format: 1,
@@ -340,7 +341,7 @@ async function publishSnapshot(site, dir, manifest, opts = {}) {
340
341
  const known = new Set((await request(site, "GET", `${base}/assets`)).assets);
341
342
  const files = [];
342
343
  for (const name of fs2.readdirSync(path2.join(dir, "assets"))) if (!known.has(name)) files.push({ local: path2.join(dir, "assets", name), remote: `assets/${name}` });
343
- for (const f of manifest.frames) for (const p of [f.html, f.image]) files.push({ local: path2.join(dir, p), remote: `${manifest.id}/${p}` });
344
+ for (const f of manifest.frames) for (const p of [f.html, f.image, ...f.thumb && can.includes("thumbs") ? [f.thumb] : []]) files.push({ local: path2.join(dir, p), remote: `${manifest.id}/${p}` });
344
345
  const skipped = [];
345
346
  let uploaded = 0;
346
347
  const fitting = files.filter((f) => {
@@ -408,7 +409,7 @@ async function publishSnapshot(site, dir, manifest, opts = {}) {
408
409
  access = after.access ?? access;
409
410
  }
410
411
  const live = opts.live ? "url" in opts.live ? { url: opts.live.url } : { files: true } : void 0;
411
- const done = await request(site, "POST", `${base}/versions`, { id: manifest.id, createdAt: manifest.createdAt, frames: manifest.frames, live });
412
+ const done = await request(site, "POST", `${base}/versions`, { id: manifest.id, createdAt: manifest.createdAt, frames: can.includes("thumbs") ? manifest.frames : manifest.frames.map(({ thumb: _, ...f }) => f), live });
412
413
  const invited = opts.invite?.length ? await inviteTo(site, share.slug, opts.invite) : [];
413
414
  return { url: done.url, version: manifest.id, versions: done.versions, uploaded, skipped, password, live: done.live ?? null, access, invited };
414
415
  }
@@ -1761,7 +1762,8 @@ var Screenshotter = class {
1761
1762
  }
1762
1763
  const png = await page.screenshot({ type: "png", fullPage: true });
1763
1764
  const viewport = page.viewportSize();
1764
- return { url: raw.url, html: raw.html, css: raw.css, canvases, png, width: viewport.width, height: raw.height, requests: [...requests] };
1765
+ const thumb = await page.screenshot({ type: "jpeg", quality: 72, clip: { x: 0, y: 0, width: viewport.width, height: Math.min(raw.height || viewport.height, Math.round(viewport.width * 0.75)) } }).catch(() => void 0);
1766
+ return { url: raw.url, html: raw.html, css: raw.css, canvases, png, thumb, width: viewport.width, height: raw.height, requests: [...requests] };
1765
1767
  });
1766
1768
  }
1767
1769
  };
@@ -22,6 +22,8 @@ interface ShareFrame {
22
22
  /** paths inside the snapshot */
23
23
  html: string;
24
24
  image: string;
25
+ /** a small preview of the frame's top (links page, emails) */
26
+ thumb?: string;
25
27
  /** a frame linked to a page: its URL in the app (e.g. "/pricing"), so the live site can show it */
26
28
  route?: string;
27
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "truecanvas",
3
- "version": "0.6.7",
3
+ "version": "0.6.8",
4
4
  "description": "Design with your real React components: a Figma-like canvas for Next.js and Vite where layers are your .tsx and agents edit through MCP.",
5
5
  "license": "MIT",
6
6
  "type": "module",