Figtree

Download Figtree.zip

get_sessionYour Figma files, and the session's URL

Description

The user's Figma files in this session, as {key, name, connected}, and the session's "url". connected: the file's plugin answered just now. If the file you need is not connected, search "connect" says what to ask the user. Under the url, for every file of the session: - /files/<path>: the session's storage (5 GB, kept 6 hours). Store: curl -T <file> "<url>/files/". GET reads, DELETE removes. In code a stored file is its URL. Make names unique: one stored again replaces the other. - /render?node=<id>: the node as an image. - /fill?node=<id>: the image the node is filled with. search "urls" has the parameters.

Spec

No parameters.

executePlugin API code in a file: every read and write

Description

Runs JavaScript in a Figma file: the body of an async function with the Figma Plugin API as `figma`, and `args` and `console`. `return` what you want to know. A node comes back as {id, type, name, x, y, width, height}; image bytes (node.exportAsync) as an image. All or nothing: if the code throws, everything it did is undone. A call still running after 45 s is cancelled and undone: retry with quicker code. Not sure of the API? `search` it instead of trying.

Spec

codestring, not empty
The function body.
scriptstring, matching ^[\w./-]{1,400}$
In place of code: the path of a file in the session's storage.
argsany JSON
Any JSON, as `args`.
filestring
Key or name of the Figma file. Needed when several are connected.
dryRunboolean
Run it, return the result, undo everything.
timeoutMsinteger, 100 to 45000
Less than the 45 s a call has.
maxInlineCharsinteger, 0 to 2000000
A longer result (default 40000) is stored as a file and its URL returned.