@atezer/figma-mcp-bridge 1.3.2 → 1.4.1
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/CHANGELOG.md +45 -0
- package/README.md +4 -3
- package/dist/core/plugin-bridge-server.d.ts +16 -1
- package/dist/core/plugin-bridge-server.d.ts.map +1 -1
- package/dist/core/plugin-bridge-server.js +62 -2
- package/dist/core/plugin-bridge-server.js.map +1 -1
- package/dist/core/response-guard.d.ts +37 -0
- package/dist/core/response-guard.d.ts.map +1 -0
- package/dist/core/response-guard.js +166 -0
- package/dist/core/response-guard.js.map +1 -0
- package/dist/local-plugin-only.d.ts.map +1 -1
- package/dist/local-plugin-only.js +247 -1
- package/dist/local-plugin-only.js.map +1 -1
- package/dist/local.js +1 -1
- package/f-mcp-plugin/code.js +43 -0
- package/f-mcp-plugin/ui.html +186 -0
- package/package.json +10 -2
- package/dist/browser/base.d.ts +0 -50
- package/dist/browser/base.d.ts.map +0 -1
- package/dist/browser/base.js +0 -6
- package/dist/browser/base.js.map +0 -1
- package/dist/browser/local.d.ts +0 -81
- package/dist/browser/local.d.ts.map +0 -1
- package/dist/browser/local.js +0 -283
- package/dist/browser/local.js.map +0 -1
- package/dist/cloudflare/browser/base.js +0 -5
- package/dist/cloudflare/browser/cloudflare.js +0 -156
- package/dist/cloudflare/browser-manager.js +0 -157
- package/dist/cloudflare/core/audit-log.js +0 -62
- package/dist/cloudflare/core/config.js +0 -163
- package/dist/cloudflare/core/console-monitor.js +0 -427
- package/dist/cloudflare/core/design-system-manifest.js +0 -260
- package/dist/cloudflare/core/enrichment/enrichment-service.js +0 -272
- package/dist/cloudflare/core/enrichment/index.js +0 -7
- package/dist/cloudflare/core/enrichment/relationship-mapper.js +0 -351
- package/dist/cloudflare/core/enrichment/style-resolver.js +0 -326
- package/dist/cloudflare/core/figma-api.js +0 -273
- package/dist/cloudflare/core/figma-desktop-connector.js +0 -1041
- package/dist/cloudflare/core/figma-reconstruction-spec.js +0 -402
- package/dist/cloudflare/core/figma-tools.js +0 -2919
- package/dist/cloudflare/core/figma-url.js +0 -48
- package/dist/cloudflare/core/logger.js +0 -53
- package/dist/cloudflare/core/plugin-bridge-connector.js +0 -197
- package/dist/cloudflare/core/plugin-bridge-server.js +0 -375
- package/dist/cloudflare/core/snippet-injector.js +0 -96
- package/dist/cloudflare/core/types/enriched.js +0 -5
- package/dist/cloudflare/core/types/index.js +0 -4
- package/dist/cloudflare/index.js +0 -1061
- package/dist/cloudflare/test-browser.js +0 -88
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Snippet Injector
|
|
3
|
-
* Generates and manages console-based data extraction snippets for Figma
|
|
4
|
-
*/
|
|
5
|
-
import { createChildLogger } from './logger.js';
|
|
6
|
-
const logger = createChildLogger({ component: 'snippet-injector' });
|
|
7
|
-
export class SnippetInjector {
|
|
8
|
-
/**
|
|
9
|
-
* Generate variables extraction snippet for Figma console
|
|
10
|
-
*/
|
|
11
|
-
generateVariablesSnippet() {
|
|
12
|
-
return `
|
|
13
|
-
(async () => {
|
|
14
|
-
try {
|
|
15
|
-
const vars = await figma.variables.getLocalVariablesAsync();
|
|
16
|
-
const collections = await figma.variables.getLocalVariableCollectionsAsync();
|
|
17
|
-
|
|
18
|
-
const payload = {
|
|
19
|
-
timestamp: Date.now(),
|
|
20
|
-
variables: vars.map(v => ({
|
|
21
|
-
id: v.id,
|
|
22
|
-
name: v.name,
|
|
23
|
-
key: v.key,
|
|
24
|
-
resolvedType: v.resolvedType,
|
|
25
|
-
valuesByMode: v.valuesByMode,
|
|
26
|
-
variableCollectionId: v.variableCollectionId,
|
|
27
|
-
scopes: v.scopes,
|
|
28
|
-
description: v.description,
|
|
29
|
-
hiddenFromPublishing: v.hiddenFromPublishing
|
|
30
|
-
})),
|
|
31
|
-
variableCollections: collections.map(c => ({
|
|
32
|
-
id: c.id,
|
|
33
|
-
name: c.name,
|
|
34
|
-
key: c.key,
|
|
35
|
-
modes: c.modes.map(m => ({ modeId: m.modeId, name: m.name })),
|
|
36
|
-
defaultModeId: c.defaultModeId,
|
|
37
|
-
variableIds: c.variableIds
|
|
38
|
-
}))
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
console.log('[MCP_VARIABLES]', JSON.stringify(payload), '[MCP_VARIABLES_END]');
|
|
42
|
-
console.log('✅ Variables data captured! Run figma_get_variables({ parseFromConsole: true }) in Claude to retrieve.');
|
|
43
|
-
|
|
44
|
-
} catch (error) {
|
|
45
|
-
console.error('[MCP_VARIABLES_ERROR]', error.message);
|
|
46
|
-
console.log('❌ Make sure you\\'re running this in a Figma file with variables.');
|
|
47
|
-
}
|
|
48
|
-
})();
|
|
49
|
-
`.trim();
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Parse variables from console log entry
|
|
53
|
-
*/
|
|
54
|
-
parseVariablesFromLog(logEntry) {
|
|
55
|
-
try {
|
|
56
|
-
// Check for marker
|
|
57
|
-
if (!logEntry.message.includes('[MCP_VARIABLES]')) {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
// Extract JSON from args
|
|
61
|
-
// The snippet logs: console.log('[MCP_VARIABLES]', JSON.stringify(payload), '[MCP_VARIABLES_END]')
|
|
62
|
-
// So args[0] is the marker, args[1] is the JSON string
|
|
63
|
-
const jsonStr = logEntry.args[1] || logEntry.args[0];
|
|
64
|
-
if (!jsonStr) {
|
|
65
|
-
throw new Error('No data found in console log');
|
|
66
|
-
}
|
|
67
|
-
const data = typeof jsonStr === 'string' ? JSON.parse(jsonStr) : jsonStr;
|
|
68
|
-
logger.info({
|
|
69
|
-
variableCount: data.variables?.length || 0,
|
|
70
|
-
collectionCount: data.variableCollections?.length || 0,
|
|
71
|
-
}, 'Successfully parsed variables from console log');
|
|
72
|
-
return {
|
|
73
|
-
variables: data.variables || [],
|
|
74
|
-
variableCollections: data.variableCollections || [],
|
|
75
|
-
timestamp: data.timestamp || Date.now(),
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
logger.error({ error }, 'Failed to parse variables from console log');
|
|
80
|
-
throw new Error(`Failed to parse variables from console log: ${error instanceof Error ? error.message : String(error)}`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Find the most recent variables log entry
|
|
85
|
-
*/
|
|
86
|
-
findVariablesLog(logs) {
|
|
87
|
-
// Search in reverse (most recent first)
|
|
88
|
-
for (let i = logs.length - 1; i >= 0; i--) {
|
|
89
|
-
const log = logs[i];
|
|
90
|
-
if (log.message.includes('[MCP_VARIABLES]')) {
|
|
91
|
-
return log;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
}
|