OpenFini

Docs / Guides

Figma plugins in the Proto Studio

The Proto Studio (Labs) runs Figma plugins on a Proto design: the plugin's manifest.json, its main code and its UI are loaded as they are, and the figma global the code talks to is implemented on top of the Proto model and its operations (ADR 0034, amendment B). Many plugins that create, rename, restyle or inspect layers work unchanged; plugins that depend on Figma-only data (libraries, users, vector networks, FigJam) do not. This page says what works.

For users#

Plugins menu of the Proto Studio:

  • Plugins… lists the installed plugins with a button per command (a manifest's menu), network access status, Revoke Network Access and Remove, and the install buttons.
  • Install Plugin from Folder… (the folder with manifest.json, typically the plugin's development folder with its built code.js and ui.html) and Install Plugin from ZIP…. A dialog shows the name, the network access the plugin asks for and what OpenFini does not support before anything is installed.
  • Run Last Plugin, Stop Plugin, and Run Plugin from Folder (Development)…, which runs a folder without installing it (and also allows the manifest's devAllowedDomains).

Every batch of changes a plugin makes is one undo step named Plugin: <name>: everything a plugin does in one go (until it waits for something, or calls figma.commitUndo()) is undone with one Undo. Installed plugins and their clientStorage (5 MB per plugin) are stored in the browser profile on this device.

Safety#

  • The plugin's main code runs in a dedicated worker inside a sandboxed frame (opaque origin, no access to the app, its files, storage or cookies). Before the plugin runs, XMLHttpRequest, WebSocket, EventSource, importScripts, indexedDB, caches and nested workers are removed; the frame's Content-Security-Policy allows no network at all.
  • Network access is off unless the manifest asks for it in networkAccess.allowedDomains and you allow it when the plugin first runs. Then fetch in the main code is answered by OpenFini for URLs that match the allowed domains only (scheme, *. subdomains, port and path prefixes as in Figma's manifest format; no credentials or cookies are sent), and the UI frame's connect-src lists exactly those domains. "none" or a missing networkAccess means no network.
  • The plugin's UI is a second sandboxed frame (opaque origin) in a small window. Messages pass only as pluginMessage between the UI and the plugin, as in Figma.
  • Every change goes through the Proto engine, which validates it: a plugin can only do what the operation layer allows (layers, pages, components, variables, styles, images), and a refused batch changes nothing.

Compatibility notes#

  • Ids are Proto ids (n…, p…), not Figma's 1:2 form; plugins that only pass ids around are unaffected.
  • Coordinates: x, y are relative to the parent as in Figma. Layers in auto layout report their measured position. rotation is counter-clockwise in degrees as in Figma (Proto stores clockwise rotation).
  • Sizes: width and height of hug and fill layers are the measured sizes from the canvas.
  • Text: writing characters, fontSize, fontName, spacing, case or decoration needs await figma.loadFontAsync(font) first, exactly like Figma (the same error otherwise). Fonts are the browser's; loadFontAsync does not download anything. Range functions (setRangeFontSize, …) work on the whole text only.
  • Instances expose their main component, variant values and properties, but not their inner layers as nodes (instance.children is empty).
  • Undo: figma.commitUndo() closes the current undo step; figma.triggerUndo() is not available.
  • UI: inline <script> blocks of the plugin's UI work (they are delivered as data: URLs); inline event handler attributes (onclick="…") do not, because the app's policy forbids inline handlers. Bundled UIs (React, Svelte, plain DOM with addEventListener) are unaffected.

API coverage#

Supported: works as documented by Figma. Partial: works with the limits noted. Missing: throws a clear error (figma.<name> is not supported in OpenFini) or returns an empty value.

AreaAPIStatusNotes
Globalsfigma.root, figma.currentPage (get, set), setCurrentPageAsync, loadAllPagesAsyncSupported
figma.editorType, apiVersion, command, pluginId, mixed, modeSupportededitorType is "figma"
figma.on / once / off: selectionchange, currentpagechange, close, runSupported
documentchangePartialfires with an empty documentChanges list
figma.notifySupportedbutton option ignored
figma.closePlugin, figma.commitUndoSupported
figma.triggerUndo, saveVersionHistoryAsync, currentUser, activeUsers, payments, timer, codegen, textreviewMissingcurrentUser is null, activeUsers []
figma.base64Encode / base64Decode, figma.util.rgb / rgba / solidPaintSupported
NodesgetNodeById, getNodeByIdAsyncSupported
children, parent, appendChild, insertChild, remove, clone, removedSupported
findAll, findOne, findChildren, findChild, findAllWithCriteria({ types })Supported
getPluginData / setPluginData / getPluginDataKeysSupportedstored in the layer's code.plugin field
getSharedPluginData / setSharedPluginDataMissing
CreatingcreateFrame, createRectangle, createEllipse, createLine, createText, createComponent, createVector, createPageSupported
createComponentFromNode, combineAsVariants, component.createInstance, groupSupported
createImagePartialbytes become a design image; getSizeAsync returns 0 × 0
createBooleanOperation, union, subtract, intersect, exclude, flatten, createNodeFromSvg, createSlice, createStar, createPolygonMissing
Geometryx, y, width, height, resize, resizeWithoutConstraints, rescale, rotation, relativeTransformSupportedtransforms carry translation only
absoluteTransform, absoluteBoundingBoxPartialfrom the canvas measurement; no rotation
constraintsSupported
Appearancename, visible, locked, opacity, blendModeSupported
fills (solid, linear / radial / angular gradients, images), strokes (solid), strokeWeight, strokeAlign, dashPatternSupporteddiamond gradients are radial; gradient strokes are missing
effects (drop and inner shadow, layer and background blur), cornerRadius, per-corner radii, clipsContentSupported
fillStyleId, effectStyleId, textStyleId (and the set…Async forms)Supported
Auto layoutlayoutMode (NONE, HORIZONTAL, VERTICAL), itemSpacing, counterAxisSpacing, padding*, primaryAxisAlignItems, counterAxisAlignItems, layoutWrap, primaryAxisSizingMode, counterAxisSizingModeSupportedGRID is reported, not settable
layoutSizingHorizontal / Vertical, layoutPositioning, layoutGrow, layoutAlignSupported
Textcharacters, fontSize, fontName, textAlignHorizontal, textAutoResize, letterSpacing, lineHeight, textCase, textDecoration, text fillsSupportedtext color is the first solid fill
loadFontAsync, listAvailableFontsAsync, hasMissingFontPartialno font downloads; a short list of common fonts
insertCharacters, deleteCharacters, getRange* / setRange*Partialwhole text only
textAlignVertical, paragraphSpacing, hyperlinks, lists, OpenType featuresMissing
VectorsvectorPathsPartialSVG path data; one winding rule per layer
vectorNetworkMissingProto stores SVG paths
ComponentsmainComponent, swapComponent, componentProperties, setProperties, detachInstance, variantPropertiesSupported
componentPropertyDefinitions, addComponentProperty (text, boolean, instance swap)Partialediting and deleting definitions is missing
importComponentByKeyAsync, team librariesMissing
Variablesfigma.variables.getLocalVariables(Async), getLocalVariableCollections(Async), getVariableById(Async), getVariableCollectionById(Async)Supported
createVariableCollection, createVariable, variable.setValueForMode, valuesByMode, name, remove, collection.addMode / renameMode / removeModeSupported
setBoundVariableForPaint, node.setBoundVariable (spacing, padding, radius, opacity, width, height), boundVariables, createVariableAliasPartialother fields throw
scopes, code syntax, extended collectionsMissingread as defaults
StylesgetLocalPaintStyles(Async), getLocalTextStyles(Async), getLocalEffectStyles(Async), getStyleById(Async)Supported
createPaintStyle, createTextStyle, createEffectStyle, style.paints / effects / fontSize / fontName / name / removePartialgrid styles and other text style fields are missing
Viewportfigma.viewport.center, zoom, bounds, scrollAndZoomIntoViewPartialscrollAndZoomIntoView shows the first layer
UIfigma.showUI (width, height, visible, title), figma.ui.postMessage, onmessage, on / once / off('message'), resize, show, hide, close, __html__, __uiFiles__Supportedposition and themeColors are ignored
Storagefigma.clientStorage.getAsync / setAsync / deleteAsync / keysAsyncSupported5 MB per plugin
Networkfetch in the main codeSupportedonly for approved, allowed domains (see Safety)
Manifestname, id, api, main, ui (file or map), editorType (figma), networkAccess, menu (commands, submenus)Supported
parameters, permissions, capabilities, relaunchButtons, enableProposedApi, widgets, FigJam- or Dev-Mode-only pluginsMissingwarned about or refused at install

For developers#

  • app/src/engine/proto/plugins/runtime.js: the figma global (pure, self-contained, serialized into the worker). It keeps a mirror of the design from the host's snapshot, applies writes to it immediately and records them as engine operations, sent in one batch per task (setTimeout 0) or at figma.commitUndo().
  • bridge.js: the host side (pure): applies batches through a callback as one undo step, allows only the operations in PLUGIN_OPS, answers storage and network requests, sends snapshots on selection, page and document changes, and enforces the size limits.
  • manifest.js: manifest validation, commands, the network allowlist (allowedUrl) and the UI frame's policy.
  • app/src/proto/plugins/host.js: the sandboxed frames, the UI window, installation (folder, ZIP), the Plugins dialog and the commands in commands/proto.js.
  • Tests: tests/proto/plugins/ runs self-written plugins in Node through the same runtime and bridge in a separate vm context (shapes and auto layout, renaming the selection, tree operations, a UI round trip, fonts and undo steps, variables and client storage, components and variants, network rules, hostile messages, events).

The API was implemented from Figma's public Plugin API documentation and the MIT-licensed @figma/plugin-typings as an interface reference; no Figma code is used (clean-room.md).

Edit on GitHub → docs/figma-plugins.md