Skip to content

feat(figma): mint stable file id from root pluginData instead of figma.fileKey#76

Open
piaskowyk wants to merge 2 commits into
mainfrom
figma/public-plugin-file-id
Open

feat(figma): mint stable file id from root pluginData instead of figma.fileKey#76
piaskowyk wants to merge 2 commits into
mainfrom
figma/public-plugin-file-id

Conversation

@piaskowyk

Copy link
Copy Markdown
Member

Why

figma.fileKey is gated behind the private plugin API (enablePrivatePluginApi: true), and a plugin with that flag set cannot be published publicly to the Figma Community — only as an org-private plugin. It was the only private API the plugin used; everything else (clientStorage, currentPage, getNodeByIdAsync, findAllWithCriteria, viewport, openExternal, notify, etc.) is standard public API.

What

  • Add resolveFileKey() in the main thread: reads a stable id from the document's root pluginData, minting and persisting one on first use.
  • Swap both figma.fileKey ?? null reads (init, request-preview-data) for resolveFileKey().
  • Flip enablePrivatePluginApifalse in manifest.json.
  • Refresh now-stale comments.

Root pluginData is stored in the file and syncs to every collaborator, so the key is just as stable and shared as fileKey was — it just lives in our own namespace instead of Figma's global one, which is fine since it only keys our own preview-server rows. fileKeyOverride is retained as a secondary fallback.

Notes

  • Existing files (pre-0.1.0, dev-only) keyed by the old figma.fileKey will mint a fresh id and create a new server row on first open — acceptable at this stage.
  • npm run typecheck and npm run build both pass.

🤖 Generated with Claude Code

piaskowyk and others added 2 commits June 11, 2026 15:34
…a.fileKey

`figma.fileKey` requires the private plugin API (`enablePrivatePluginApi`),
which blocks a public Figma Community release. It was the only private API in
use — everything else is standard.

Replace it with a per-document id minted on first use and persisted in the
document's root pluginData. Root pluginData is stored in the file and synced to
every collaborator, so the key is just as stable and shared as fileKey was; it
only lives in our own namespace, which is fine since it just keys our own server
rows. Flip `enablePrivatePluginApi` to false so the plugin can be published
publicly. `fileKeyOverride` is retained as a secondary fallback.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Rationale now lives in the PR description instead of inline.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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