Allow this plugin to be used from outside of the Figma context #259
Description
Problem
packages/backend — the actual conversion logic (auto-layout → CSS/gradients/etc. across HTML, Tailwind, Flutter, SwiftUI, Compose) — currently only runs inside a live Figma plugin sandbox. Several core builders read the figma global directly (figma.mixed, figma.getNodeByIdAsync()/exportAsync(), figma.variables.getVariableByIdAsync()), not just the plugin-messaging bridge.
That means the conversion engine can't be reused outside the plugin — e.g. server-side, converting a node tree already fetched via the Figma REST API, with no live document connection available.
Use case
Running this conversion logic headlessly on a server, on top of REST API data, instead of re-implementing equivalent auto-layout/CSS/gradient resolution by hand.
Proposed fix
#258 adds a small injectable seam (setBackendHost() / getBackendHost() in packages/backend/src/host.ts) so a caller can supply a REST-backed (or otherwise non-plugin) implementation of the handful of figma.* calls the conversion path needs. Left unset, it falls back to wrapping the real figma global, so the plugin app's behavior is unchanged.
Activity
bernaferrari commentedon Aug 18, 2026
I surely could do all that. I'm just wondering what you are trying to do.
heinvv commentedon Aug 18, 2026
@bernaferrari I would like to convert Figma to html using the Figma URLs. From the browser.
bernaferrari commentedon Aug 18, 2026
Using rest api?
heinvv commentedon Aug 18, 2026
@bernaferrari Yes, using the Figma rest api.
bernaferrari commentedon Aug 18, 2026
The plugin codebase is messy because Figma team told me the old version was too inneficient and I should use REST api, but there is a bad flaw in REST api for a few months that crashed the plugin, so I kept both and it made the codebase be a mess.
If I merge what you did, will it help you? I probably should remove the old plugin soon, that will make things a bit easier.
heinvv commentedon Aug 18, 2026
I wasn't aware of this.
Let me study this.
heinvv commentedon Aug 18, 2026
Note: this comment was written by Claude Code automatically.