Skip to content

feat: wireframe designer, Satori rendering, and Copy to Figma#24

Open
trmquang93 wants to merge 2 commits intomainfrom
feat/satori-wireframe-figma-export
Open

feat: wireframe designer, Satori rendering, and Copy to Figma#24
trmquang93 wants to merge 2 commits intomainfrom
feat/satori-wireframe-figma-export

Conversation

@trmquang93
Copy link
Copy Markdown
Collaborator

Summary

  • Satori rendering — replaces Puppeteer in the MCP server with Satori (Vercel's HTML-to-SVG engine). No Chrome binary required; renders ~50ms vs ~2s. MCP screens now produce clean native SVG alongside the PNG, stored as screen.svgContent.
  • Built-in wireframe designer — new W toolbar button opens a full-screen SVG canvas editor. Drag components (rect, button, input, nav-bar, tab-bar, etc.) from a palette, edit properties in the right panel, and click Done to render a PNG. Interactive components auto-generate hotspots.
  • Copy to Figma — right-click any MCP screen or wireframe → Copy for Figma to clipboard-copy the SVG, or Download SVG. Paste in Figma to get editable vector layers.

Changes

  • mcp-server: SatoriRenderer replaces HtmlRenderer; bundles Inter font; @resvg/resvg-js marked external in esbuild config; font assets copied to dist/assets/ at build time
  • src/constants.js: FILE_VERSION 12 → 13; adds WIREFRAME_GRID_SIZE, WIREFRAME_VIEWPORT_WIDTH/HEIGHT
  • src/hooks/useWireframeEditor.js: component CRUD, undo/redo (ref-based), grid snap
  • src/components/wireframe/: WireframeEditor, ComponentPalette, PropertyPanel
  • src/utils/wireframeToSvg.js, wireframeRenderer.js, wireframeDefaults.js: SVG generation and PNG rendering
  • src/utils/copyToFigma.js: clipboard copy + SVG file download
  • src/utils/importFlow.js: backfills svgContent, sourceHtml, wireframe for v1–12 files
  • src/pages/docs/userGuide.md: new Wireframe Designer and Copy to Figma sections

Test plan

  • npm test — 358 tests pass
  • npm run build — clean production build
  • MCP: cd mcp-server && node --input-type=module test with SatoriRenderer renders PNG + SVG
  • MCP bundle: npm run build in mcp-server/ produces dist/index.js + dist/assets/ fonts
  • Open existing v12 .drawd file — loads without errors, new fields default to null
  • Click Draw Wireframe → place components → resize → edit text/fill → click Done → screen shows PNG
  • Re-open wireframe editor — components preserved
  • Right-click MCP screen with svgContent → Copy for Figma → paste in Figma shows editable vectors
  • Right-click wireframe screen → Copy for Figma → paste in Figma shows editable vectors

Replace Puppeteer with Satori (Vercel) in the MCP server for HTML-to-PNG
rendering. Satori produces clean native SVG alongside the PNG, eliminating
the Chrome binary requirement and reducing render time from ~2s to ~50ms.

Add a built-in wireframe designer that lets users sketch screens directly
in Drawd using a drag-and-drop component palette (rect, button, input,
nav-bar, tab-bar, and more). Wireframes render to PNG via the browser canvas
and store their component schema for re-editing.

Both MCP screens (via Satori) and wireframe screens export to Figma as
editable SVG vector layers via right-click → Copy for Figma or Download SVG.

Details:
- mcp-server: SatoriRenderer replaces HtmlRenderer; returns svgString +
  pngBuffer; bundles Inter font; esbuild marks @resvg/resvg-js external
- File version bumped 12 → 13; screens gain svgContent, sourceHtml, wireframe
- useWireframeEditor hook: full undo/redo, grid snapping, component CRUD
- WireframeEditor: SVG canvas with drag/resize, keyboard shortcuts, auto-
  hotspot generation from interactive components
- copyToFigma utility: clipboard SVG copy + SVG file download
- Backward compat: importFlow.js backfills new fields for v1–12 files
- Docs: updated user guide with wireframe designer and Figma export sections
Satori requires every element with multiple children to have an explicit
display property — default block/inline layout does not exist. Add
injectMissingDisplay() to auto-inject display:flex;flex-direction:column
on div/section/header/footer/main/nav elements whose style lacks a
display declaration.

Also improve create_screen and update_screen_image tool descriptions to
clearly document Satori's rendering constraints for AI agent callers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant