Skip to content

Allow this plugin to be used from outside of the Figma context #259

Description

@heinvv

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions