figma-rust-mcp 3.0.2 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/plugin/code.js +45 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "figma-rust-mcp",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "Claude Code to Figma — Bidirectional MCP bridge. AI draws UI on Figma canvas, reads designs back. Works with Claude, Cursor, VS Code, Windsurf, Antigravity. No API key needed.",
|
|
5
5
|
"mcpName": "io.github.BuiHung1612/figma-mcp",
|
|
6
6
|
"type": "module",
|
package/plugin/code.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// figma-mcp — Figma Plugin main thread v1.2.1
|
|
2
2
|
// Handles both WRITE (draw UI) and READ (extract design) operations.
|
|
3
3
|
// AUTO-GENERATED by scripts/build-plugin.js — edit plugin-src/*.js instead
|
|
4
|
-
// Generated: 2026-08-
|
|
4
|
+
// Generated: 2026-08-29T13:39:20.933Z
|
|
5
5
|
|
|
6
6
|
// ── plugin-src/utils.js ──
|
|
7
7
|
// ─── UTILS ────────────────────────────────────────────────────────────────────
|
|
@@ -1348,7 +1348,7 @@ const handlers = {};
|
|
|
1348
1348
|
|
|
1349
1349
|
handlers.status = async () => ({
|
|
1350
1350
|
connected: true,
|
|
1351
|
-
version: "3.0.
|
|
1351
|
+
version: "3.0.3",
|
|
1352
1352
|
fileName: figma.root.name,
|
|
1353
1353
|
currentPage: figma.currentPage.name,
|
|
1354
1354
|
pageCount: figma.root.children.length,
|
|
@@ -1359,19 +1359,54 @@ handlers.listPages = async () =>
|
|
|
1359
1359
|
figma.root.children.map(p => ({ id: p.id, name: p.name }));
|
|
1360
1360
|
|
|
1361
1361
|
handlers.setPage = async (params) => {
|
|
1362
|
-
|
|
1363
|
-
|
|
1362
|
+
if (typeof figma.loadAllPagesAsync === "function") {
|
|
1363
|
+
try { await figma.loadAllPagesAsync(); } catch (e) {}
|
|
1364
|
+
}
|
|
1365
|
+
params = params || {};
|
|
1366
|
+
var name = typeof params === "string" ? params : (params.name || params.pageName || params.title || (typeof params.page === "string" ? params.page : (params.page && typeof params.page.name === "string" ? params.page.name : null)));
|
|
1367
|
+
var id = (typeof params === "object" && params !== null) ? (params.id || params.pageId || (params.page && typeof params.page.id === "string" ? params.page.id : null)) : null;
|
|
1368
|
+
var index = (typeof params === "number") ? params : ((typeof params === "object" && params !== null) ? (params.index !== undefined ? params.index : params.pageIndex) : undefined);
|
|
1369
|
+
|
|
1364
1370
|
var page = null;
|
|
1365
|
-
if (id)
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
if (!page
|
|
1371
|
+
if (id) {
|
|
1372
|
+
page = figma.root.children.find(function(p) { return p.id === id; });
|
|
1373
|
+
}
|
|
1374
|
+
if (!page && name) {
|
|
1375
|
+
page = figma.root.children.find(function(p) { return p.name === name; });
|
|
1376
|
+
if (!page) {
|
|
1377
|
+
// Case-insensitive & trimmed match fallback
|
|
1378
|
+
var lowerName = String(name).trim().toLowerCase();
|
|
1379
|
+
page = figma.root.children.find(function(p) { return p.name.trim().toLowerCase() === lowerName; });
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
if (!page && typeof index === "number" && index >= 0 && index < figma.root.children.length) {
|
|
1383
|
+
page = figma.root.children[index];
|
|
1384
|
+
}
|
|
1385
|
+
if (!page && !name && !id && index === undefined && figma.root.children.length === 1) {
|
|
1386
|
+
page = figma.root.children[0];
|
|
1387
|
+
}
|
|
1388
|
+
if (!page) {
|
|
1389
|
+
var requested = name || id || (index !== undefined ? ("index " + index) : null);
|
|
1390
|
+
var available = figma.root.children.map(function(p) { return p.name; }).join(", ");
|
|
1391
|
+
if (requested) {
|
|
1392
|
+
throw new Error("Page not found: \"" + requested + "\". Available: " + available);
|
|
1393
|
+
} else {
|
|
1394
|
+
throw new Error("setPage requires a valid page name, id, or index. Available: " + available);
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1369
1397
|
await figma.setCurrentPageAsync(page);
|
|
1370
1398
|
return { id: page.id, name: page.name };
|
|
1371
1399
|
};
|
|
1372
1400
|
|
|
1373
|
-
handlers.createPage = async (
|
|
1374
|
-
|
|
1401
|
+
handlers.createPage = async (params) => {
|
|
1402
|
+
if (typeof figma.loadAllPagesAsync === "function") {
|
|
1403
|
+
try { await figma.loadAllPagesAsync(); } catch (e) {}
|
|
1404
|
+
}
|
|
1405
|
+
var name = typeof params === "string" ? params : (params && (params.name || params.pageName || params.title));
|
|
1406
|
+
if (!name || typeof name !== "string") {
|
|
1407
|
+
throw new Error("createPage requires a valid page name string");
|
|
1408
|
+
}
|
|
1409
|
+
const existing = figma.root.children.find(p => p.name === name || p.name.trim().toLowerCase() === name.trim().toLowerCase());
|
|
1375
1410
|
if (existing) return { id: existing.id, name: existing.name, existed: true };
|
|
1376
1411
|
const page = figma.createPage();
|
|
1377
1412
|
page.name = name;
|