返回 Skill 列表
extension
分类: 开发与工程无需 API Key

figjam-plugin

FigJam插件开发工作流程。在处理插件代码(code.ts, ui.ts)、调试WebSocket通信或构建插件时使用。

person作者: jakexiaohubgithub

FigJam Plugin Development

Architecture

| Thread | File | APIs | Role | |--------|------|------|------| | Main | code.ts | figma.* only | Canvas rendering | | UI | ui.ts | Browser APIs | WebSocket client, connection UI |

Critical: code.ts has NO browser APIs (window, document, fetch, WebSocket).

Communication

CLI ←─ WebSocket ─→ ui.ts ←─ postMessage ─→ code.ts ←─ figma.* ─→ Canvas

Build & Import

cd packages/plugin && bun run build

Import: Figma Desktop → Plugins → Development → Import from manifest → packages/plugin/manifest.json

Debugging

  • UI errors: Right-click plugin UI → Inspect
  • Main errors: Plugins → Development → Open console

JSON Import

  • Accepts DSL (nodes array) or IR (nodes object)
  • Validates with @figram/core, normalizes to IR
  • Errors shown in alert with path + message

Key Files

| File | Purpose | |------|---------| | manifest.json | Plugin config | | src/code.ts | Canvas rendering | | src/ui.ts | WebSocket + UI | | src/icons/ | Service icons |