@mp3wizard/figma-console-mcp 1.14.1 → 1.15.2
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/README.md +21 -20
- package/dist/apps/design-system-dashboard/mcp-app.html +521 -0
- package/dist/apps/token-browser/mcp-app.html +410 -0
- package/dist/core/port-discovery.d.ts +11 -0
- package/dist/core/port-discovery.d.ts.map +1 -1
- package/dist/core/port-discovery.js +77 -0
- package/dist/core/port-discovery.js.map +1 -1
- package/dist/core/write-tools.d.ts.map +1 -1
- package/dist/core/write-tools.js +10 -2
- package/dist/core/write-tools.js.map +1 -1
- package/dist/local.d.ts +3 -1
- package/dist/local.d.ts.map +1 -1
- package/dist/local.js +147 -22
- package/dist/local.js.map +1 -1
- package/figma-desktop-bridge/code.js +60 -2
- package/figma-desktop-bridge/ui-full.html +1236 -0
- package/figma-desktop-bridge/ui.html +173 -1156
- package/package.json +1 -1
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
// Uses postMessage to communicate with UI, bypassing worker sandbox limitations
|
|
5
5
|
// Puppeteer can access UI iframe's window context to retrieve data
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// Plugin version — sent in FILE_INFO for server-side version compatibility checks.
|
|
8
|
+
// The server compares this against its own version to detect stale cached plugins.
|
|
9
|
+
var PLUGIN_VERSION = '1.14.0';
|
|
10
|
+
|
|
11
|
+
console.log('🌉 [Desktop Bridge] Plugin loaded (v' + PLUGIN_VERSION + ')');
|
|
8
12
|
|
|
9
13
|
// Show minimal UI - compact status indicator
|
|
10
14
|
figma.showUI(__html__, { width: 140, height: 50, visible: true, themeColors: true });
|
|
@@ -189,6 +193,59 @@ function hexToFigmaRGB(hex) {
|
|
|
189
193
|
// Listen for requests from UI (e.g., component data requests, write operations)
|
|
190
194
|
figma.ui.onmessage = async (msg) => {
|
|
191
195
|
|
|
196
|
+
// ============================================================================
|
|
197
|
+
// BOOT_LOAD_UI - Bootloader fetched fresh UI HTML from the MCP server.
|
|
198
|
+
// Replace the bootloader with the full, always-up-to-date plugin UI.
|
|
199
|
+
// This uses figma.showUI() with the HTML string directly — no redirects,
|
|
200
|
+
// no cross-origin, no CSP issues.
|
|
201
|
+
// ============================================================================
|
|
202
|
+
if (msg.type === 'BOOT_LOAD_UI' && msg.html) {
|
|
203
|
+
console.log('🌉 [Desktop Bridge] Bootloader delivered fresh UI (' + msg.html.length + ' bytes), loading...');
|
|
204
|
+
figma.showUI(msg.html, { width: 140, height: 50, visible: true, themeColors: true });
|
|
205
|
+
|
|
206
|
+
// Re-send variables data to the fresh UI — the original send went to the
|
|
207
|
+
// bootloader which discarded it. The fresh UI needs it to show "ready" status.
|
|
208
|
+
(async function() {
|
|
209
|
+
try {
|
|
210
|
+
var variables = await figma.variables.getLocalVariablesAsync();
|
|
211
|
+
var collections = await figma.variables.getLocalVariableCollectionsAsync();
|
|
212
|
+
figma.ui.postMessage({
|
|
213
|
+
type: 'VARIABLES_DATA',
|
|
214
|
+
data: {
|
|
215
|
+
success: true,
|
|
216
|
+
timestamp: Date.now(),
|
|
217
|
+
fileKey: figma.fileKey || null,
|
|
218
|
+
variables: variables.map(function(v) { return {
|
|
219
|
+
id: v.id, name: v.name, key: v.key, resolvedType: v.resolvedType,
|
|
220
|
+
valuesByMode: v.valuesByMode, variableCollectionId: v.variableCollectionId,
|
|
221
|
+
scopes: v.scopes, description: v.description, hiddenFromPublishing: v.hiddenFromPublishing
|
|
222
|
+
}; }),
|
|
223
|
+
variableCollections: collections.map(function(c) { return {
|
|
224
|
+
id: c.id, name: c.name, key: c.key, modes: c.modes,
|
|
225
|
+
defaultModeId: c.defaultModeId, variableIds: c.variableIds
|
|
226
|
+
}; })
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
console.log('🌉 [Desktop Bridge] Re-sent variables to fresh UI (' + variables.length + ' vars)');
|
|
230
|
+
} catch (e) {
|
|
231
|
+
console.log('🌉 [Desktop Bridge] Could not re-send variables:', e.message || e);
|
|
232
|
+
}
|
|
233
|
+
})();
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// ============================================================================
|
|
238
|
+
// BOOT_FALLBACK - Bootloader found an old server that doesn't support the
|
|
239
|
+
// bootloader protocol. Fall back to reloading the cached __html__ which
|
|
240
|
+
// contains the full UI (for users who haven't switched to the bootloader yet,
|
|
241
|
+
// __html__ IS the full UI; for bootloader users, this is a no-op reload).
|
|
242
|
+
// ============================================================================
|
|
243
|
+
if (msg.type === 'BOOT_FALLBACK') {
|
|
244
|
+
console.log('🌉 [Desktop Bridge] Old server detected on port ' + msg.port + ', using cached UI');
|
|
245
|
+
figma.showUI(__html__, { width: 140, height: 50, visible: true, themeColors: true });
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
|
|
192
249
|
// ============================================================================
|
|
193
250
|
// EXECUTE_CODE - Arbitrary code execution (Power Tool)
|
|
194
251
|
// ============================================================================
|
|
@@ -2042,7 +2099,8 @@ figma.ui.onmessage = async (msg) => {
|
|
|
2042
2099
|
fileKey: figma.fileKey || null,
|
|
2043
2100
|
currentPage: figma.currentPage.name,
|
|
2044
2101
|
currentPageId: figma.currentPage.id,
|
|
2045
|
-
selectionCount: selection ? selection.length : 0
|
|
2102
|
+
selectionCount: selection ? selection.length : 0,
|
|
2103
|
+
pluginVersion: PLUGIN_VERSION
|
|
2046
2104
|
}
|
|
2047
2105
|
});
|
|
2048
2106
|
} catch (error) {
|