@mp3wizard/figma-console-mcp 1.14.0
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/LICENSE +21 -0
- package/README.md +816 -0
- package/dist/apps/design-system-dashboard/scoring/accessibility.d.ts +14 -0
- package/dist/apps/design-system-dashboard/scoring/accessibility.d.ts.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/accessibility.js +278 -0
- package/dist/apps/design-system-dashboard/scoring/accessibility.js.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/component-metadata.d.ts +29 -0
- package/dist/apps/design-system-dashboard/scoring/component-metadata.d.ts.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/component-metadata.js +358 -0
- package/dist/apps/design-system-dashboard/scoring/component-metadata.js.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/consistency.d.ts +14 -0
- package/dist/apps/design-system-dashboard/scoring/consistency.d.ts.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/consistency.js +342 -0
- package/dist/apps/design-system-dashboard/scoring/consistency.js.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/coverage.d.ts +14 -0
- package/dist/apps/design-system-dashboard/scoring/coverage.d.ts.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/coverage.js +231 -0
- package/dist/apps/design-system-dashboard/scoring/coverage.js.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/engine.d.ts +27 -0
- package/dist/apps/design-system-dashboard/scoring/engine.d.ts.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/engine.js +93 -0
- package/dist/apps/design-system-dashboard/scoring/engine.js.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/naming-semantics.d.ts +14 -0
- package/dist/apps/design-system-dashboard/scoring/naming-semantics.d.ts.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/naming-semantics.js +309 -0
- package/dist/apps/design-system-dashboard/scoring/naming-semantics.js.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/token-architecture.d.ts +14 -0
- package/dist/apps/design-system-dashboard/scoring/token-architecture.d.ts.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/token-architecture.js +350 -0
- package/dist/apps/design-system-dashboard/scoring/token-architecture.js.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/types.d.ts +89 -0
- package/dist/apps/design-system-dashboard/scoring/types.d.ts.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/types.js +41 -0
- package/dist/apps/design-system-dashboard/scoring/types.js.map +1 -0
- package/dist/apps/design-system-dashboard/server.d.ts +24 -0
- package/dist/apps/design-system-dashboard/server.d.ts.map +1 -0
- package/dist/apps/design-system-dashboard/server.js +160 -0
- package/dist/apps/design-system-dashboard/server.js.map +1 -0
- package/dist/apps/token-browser/server.d.ts +26 -0
- package/dist/apps/token-browser/server.d.ts.map +1 -0
- package/dist/apps/token-browser/server.js +137 -0
- package/dist/apps/token-browser/server.js.map +1 -0
- package/dist/browser/base.d.ts +58 -0
- package/dist/browser/base.d.ts.map +1 -0
- package/dist/browser/base.js +6 -0
- package/dist/browser/base.js.map +1 -0
- package/dist/browser/local.d.ts +87 -0
- package/dist/browser/local.d.ts.map +1 -0
- package/dist/browser/local.js +318 -0
- package/dist/browser/local.js.map +1 -0
- package/dist/cloudflare/apps/design-system-dashboard/scoring/accessibility.js +277 -0
- package/dist/cloudflare/apps/design-system-dashboard/scoring/component-metadata.js +357 -0
- package/dist/cloudflare/apps/design-system-dashboard/scoring/consistency.js +341 -0
- package/dist/cloudflare/apps/design-system-dashboard/scoring/coverage.js +230 -0
- package/dist/cloudflare/apps/design-system-dashboard/scoring/engine.js +92 -0
- package/dist/cloudflare/apps/design-system-dashboard/scoring/naming-semantics.js +308 -0
- package/dist/cloudflare/apps/design-system-dashboard/scoring/token-architecture.js +349 -0
- package/dist/cloudflare/apps/design-system-dashboard/scoring/types.js +40 -0
- package/dist/cloudflare/apps/design-system-dashboard/server.js +159 -0
- package/dist/cloudflare/apps/token-browser/server.js +136 -0
- package/dist/cloudflare/browser/base.js +5 -0
- package/dist/cloudflare/browser/cloudflare.js +156 -0
- package/dist/cloudflare/browser-manager.js +157 -0
- package/dist/cloudflare/core/cloud-websocket-connector.js +267 -0
- package/dist/cloudflare/core/cloud-websocket-relay.js +199 -0
- package/dist/cloudflare/core/comment-tools.js +292 -0
- package/dist/cloudflare/core/config.js +161 -0
- package/dist/cloudflare/core/console-monitor.js +427 -0
- package/dist/cloudflare/core/design-code-tools.js +2504 -0
- package/dist/cloudflare/core/design-system-manifest.js +260 -0
- package/dist/cloudflare/core/design-system-tools.js +863 -0
- package/dist/cloudflare/core/enrichment/enrichment-service.js +272 -0
- package/dist/cloudflare/core/enrichment/index.js +7 -0
- package/dist/cloudflare/core/enrichment/relationship-mapper.js +351 -0
- package/dist/cloudflare/core/enrichment/style-resolver.js +326 -0
- package/dist/cloudflare/core/figma-api.js +409 -0
- package/dist/cloudflare/core/figma-connector.js +7 -0
- package/dist/cloudflare/core/figma-desktop-connector.js +1184 -0
- package/dist/cloudflare/core/figma-reconstruction-spec.js +402 -0
- package/dist/cloudflare/core/figma-style-extractor.js +311 -0
- package/dist/cloudflare/core/figma-tools.js +2947 -0
- package/dist/cloudflare/core/logger.js +53 -0
- package/dist/cloudflare/core/port-discovery.js +282 -0
- package/dist/cloudflare/core/snippet-injector.js +96 -0
- package/dist/cloudflare/core/types/design-code.js +4 -0
- package/dist/cloudflare/core/types/enriched.js +5 -0
- package/dist/cloudflare/core/types/index.js +4 -0
- package/dist/cloudflare/core/websocket-connector.js +256 -0
- package/dist/cloudflare/core/websocket-server.js +646 -0
- package/dist/cloudflare/core/write-tools.js +2091 -0
- package/dist/cloudflare/index.js +2899 -0
- package/dist/cloudflare/test-browser.js +88 -0
- package/dist/core/comment-tools.d.ts +11 -0
- package/dist/core/comment-tools.d.ts.map +1 -0
- package/dist/core/comment-tools.js +293 -0
- package/dist/core/comment-tools.js.map +1 -0
- package/dist/core/config.d.ts +17 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +162 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/console-monitor.d.ts +82 -0
- package/dist/core/console-monitor.d.ts.map +1 -0
- package/dist/core/console-monitor.js +428 -0
- package/dist/core/console-monitor.js.map +1 -0
- package/dist/core/design-code-tools.d.ts +127 -0
- package/dist/core/design-code-tools.d.ts.map +1 -0
- package/dist/core/design-code-tools.js +2505 -0
- package/dist/core/design-code-tools.js.map +1 -0
- package/dist/core/design-system-manifest.d.ts +272 -0
- package/dist/core/design-system-manifest.d.ts.map +1 -0
- package/dist/core/design-system-manifest.js +261 -0
- package/dist/core/design-system-manifest.js.map +1 -0
- package/dist/core/design-system-tools.d.ts +17 -0
- package/dist/core/design-system-tools.d.ts.map +1 -0
- package/dist/core/design-system-tools.js +864 -0
- package/dist/core/design-system-tools.js.map +1 -0
- package/dist/core/enrichment/enrichment-service.d.ts +52 -0
- package/dist/core/enrichment/enrichment-service.d.ts.map +1 -0
- package/dist/core/enrichment/enrichment-service.js +273 -0
- package/dist/core/enrichment/enrichment-service.js.map +1 -0
- package/dist/core/enrichment/index.d.ts +8 -0
- package/dist/core/enrichment/index.d.ts.map +1 -0
- package/dist/core/enrichment/index.js +8 -0
- package/dist/core/enrichment/index.js.map +1 -0
- package/dist/core/enrichment/relationship-mapper.d.ts +106 -0
- package/dist/core/enrichment/relationship-mapper.d.ts.map +1 -0
- package/dist/core/enrichment/relationship-mapper.js +352 -0
- package/dist/core/enrichment/relationship-mapper.js.map +1 -0
- package/dist/core/enrichment/style-resolver.d.ts +80 -0
- package/dist/core/enrichment/style-resolver.d.ts.map +1 -0
- package/dist/core/enrichment/style-resolver.js +327 -0
- package/dist/core/enrichment/style-resolver.js.map +1 -0
- package/dist/core/figma-api.d.ts +201 -0
- package/dist/core/figma-api.d.ts.map +1 -0
- package/dist/core/figma-api.js +410 -0
- package/dist/core/figma-api.js.map +1 -0
- package/dist/core/figma-connector.d.ts +48 -0
- package/dist/core/figma-connector.d.ts.map +1 -0
- package/dist/core/figma-connector.js +8 -0
- package/dist/core/figma-connector.js.map +1 -0
- package/dist/core/figma-desktop-connector.d.ts +265 -0
- package/dist/core/figma-desktop-connector.d.ts.map +1 -0
- package/dist/core/figma-desktop-connector.js +1184 -0
- package/dist/core/figma-desktop-connector.js.map +1 -0
- package/dist/core/figma-reconstruction-spec.d.ts +166 -0
- package/dist/core/figma-reconstruction-spec.d.ts.map +1 -0
- package/dist/core/figma-reconstruction-spec.js +403 -0
- package/dist/core/figma-reconstruction-spec.js.map +1 -0
- package/dist/core/figma-style-extractor.d.ts +76 -0
- package/dist/core/figma-style-extractor.d.ts.map +1 -0
- package/dist/core/figma-style-extractor.js +312 -0
- package/dist/core/figma-style-extractor.js.map +1 -0
- package/dist/core/figma-tools.d.ts +23 -0
- package/dist/core/figma-tools.d.ts.map +1 -0
- package/dist/core/figma-tools.js +2948 -0
- package/dist/core/figma-tools.js.map +1 -0
- package/dist/core/logger.d.ts +22 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +54 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/port-discovery.d.ts +110 -0
- package/dist/core/port-discovery.d.ts.map +1 -0
- package/dist/core/port-discovery.js +283 -0
- package/dist/core/port-discovery.js.map +1 -0
- package/dist/core/snippet-injector.d.ts +24 -0
- package/dist/core/snippet-injector.d.ts.map +1 -0
- package/dist/core/snippet-injector.js +97 -0
- package/dist/core/snippet-injector.js.map +1 -0
- package/dist/core/types/design-code.d.ts +262 -0
- package/dist/core/types/design-code.d.ts.map +1 -0
- package/dist/core/types/design-code.js +5 -0
- package/dist/core/types/design-code.js.map +1 -0
- package/dist/core/types/enriched.d.ts +213 -0
- package/dist/core/types/enriched.d.ts.map +1 -0
- package/dist/core/types/enriched.js +6 -0
- package/dist/core/types/enriched.js.map +1 -0
- package/dist/core/types/index.d.ts +112 -0
- package/dist/core/types/index.d.ts.map +1 -0
- package/dist/core/types/index.js +5 -0
- package/dist/core/types/index.js.map +1 -0
- package/dist/core/websocket-connector.d.ts +55 -0
- package/dist/core/websocket-connector.d.ts.map +1 -0
- package/dist/core/websocket-connector.js +257 -0
- package/dist/core/websocket-connector.js.map +1 -0
- package/dist/core/websocket-server.d.ts +191 -0
- package/dist/core/websocket-server.d.ts.map +1 -0
- package/dist/core/websocket-server.js +647 -0
- package/dist/core/websocket-server.js.map +1 -0
- package/dist/core/write-tools.d.ts +7 -0
- package/dist/core/write-tools.d.ts.map +1 -0
- package/dist/core/write-tools.js +2092 -0
- package/dist/core/write-tools.js.map +1 -0
- package/dist/local.d.ts +84 -0
- package/dist/local.d.ts.map +1 -0
- package/dist/local.js +5039 -0
- package/dist/local.js.map +1 -0
- package/figma-desktop-bridge/README.md +313 -0
- package/figma-desktop-bridge/code.js +2818 -0
- package/figma-desktop-bridge/manifest.json +67 -0
- package/figma-desktop-bridge/ui.html +1236 -0
- package/package.json +87 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Console Monitor
|
|
3
|
+
* Captures and manages console logs from Figma plugins
|
|
4
|
+
* Monitors both main page console AND Web Worker consoles (where Figma plugins run)
|
|
5
|
+
*/
|
|
6
|
+
import type { ConsoleLogEntry, ConsoleConfig } from './types/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Console Monitor
|
|
9
|
+
* Listens to page console events and maintains a circular buffer of logs
|
|
10
|
+
* Also monitors Web Workers to capture Figma plugin console logs
|
|
11
|
+
*/
|
|
12
|
+
export declare class ConsoleMonitor {
|
|
13
|
+
private logs;
|
|
14
|
+
private config;
|
|
15
|
+
private isMonitoring;
|
|
16
|
+
private page;
|
|
17
|
+
private workers;
|
|
18
|
+
private lastUrl;
|
|
19
|
+
constructor(config: ConsoleConfig);
|
|
20
|
+
/**
|
|
21
|
+
* Start monitoring console logs on a page
|
|
22
|
+
* Accepts any puppeteer Page type (puppeteer-core or @cloudflare/puppeteer)
|
|
23
|
+
*/
|
|
24
|
+
startMonitoring(page: any): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Attach console listeners to a Web Worker
|
|
27
|
+
* This captures Figma plugin console logs
|
|
28
|
+
*/
|
|
29
|
+
private attachWorkerListeners;
|
|
30
|
+
/**
|
|
31
|
+
* Process console message from Puppeteer
|
|
32
|
+
* @param msg - Console message from page or worker
|
|
33
|
+
* @param context - Where the message came from ('page' or 'worker')
|
|
34
|
+
* @param workerUrl - URL of the worker (if context is 'worker')
|
|
35
|
+
*/
|
|
36
|
+
private processConsoleMessage;
|
|
37
|
+
/**
|
|
38
|
+
* Determine if log is from plugin or Figma based on URL
|
|
39
|
+
*/
|
|
40
|
+
private determineSource;
|
|
41
|
+
/**
|
|
42
|
+
* Add log to circular buffer
|
|
43
|
+
*/
|
|
44
|
+
private addLog;
|
|
45
|
+
/**
|
|
46
|
+
* Truncate string to max length
|
|
47
|
+
*/
|
|
48
|
+
private truncateString;
|
|
49
|
+
/**
|
|
50
|
+
* Truncate value (string, array, object) intelligently
|
|
51
|
+
* Based on AgentDesk pattern to prevent context overflow
|
|
52
|
+
*/
|
|
53
|
+
private truncateValue;
|
|
54
|
+
/**
|
|
55
|
+
* Get logs with optional filtering
|
|
56
|
+
*/
|
|
57
|
+
getLogs(options?: {
|
|
58
|
+
count?: number;
|
|
59
|
+
level?: ConsoleLogEntry['level'] | 'all';
|
|
60
|
+
since?: number;
|
|
61
|
+
}): ConsoleLogEntry[];
|
|
62
|
+
/**
|
|
63
|
+
* Clear log buffer
|
|
64
|
+
*/
|
|
65
|
+
clear(): number;
|
|
66
|
+
/**
|
|
67
|
+
* Stop monitoring
|
|
68
|
+
*/
|
|
69
|
+
stopMonitoring(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Get monitoring status
|
|
72
|
+
*/
|
|
73
|
+
getStatus(): {
|
|
74
|
+
isMonitoring: boolean;
|
|
75
|
+
logCount: number;
|
|
76
|
+
bufferSize: number;
|
|
77
|
+
workerCount: number;
|
|
78
|
+
oldestTimestamp: number;
|
|
79
|
+
newestTimestamp: number;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=console-monitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console-monitor.d.ts","sourceRoot":"","sources":["../../src/core/console-monitor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAQvE;;;;GAIG;AACH,qBAAa,cAAc;IAC1B,OAAO,CAAC,IAAI,CAAyB;IACrC,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,OAAO,CAAc;gBAEjB,MAAM,EAAE,aAAa;IAIjC;;;OAGG;IACG,eAAe,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IA6L/C;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAgC7B;;;;;OAKG;YACW,qBAAqB;IAqEnC;;OAEG;IACH,OAAO,CAAC,eAAe;IA4BvB;;OAEG;IACH,OAAO,CAAC,MAAM;IAWd;;OAEG;IACH,OAAO,CAAC,cAAc;IAQtB;;;OAGG;IACH,OAAO,CAAC,aAAa;IAqDrB;;OAEG;IACH,OAAO,CAAC,OAAO,CAAC,EAAE;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;QACzC,KAAK,CAAC,EAAE,MAAM,CAAC;KACf,GAAG,eAAe,EAAE;IAqBrB;;OAEG;IACH,KAAK,IAAI,MAAM;IAOf;;OAEG;IACH,cAAc,IAAI,IAAI;IAYtB;;OAEG;IACH,SAAS;;;;;;;;CAUT"}
|
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Console Monitor
|
|
3
|
+
* Captures and manages console logs from Figma plugins
|
|
4
|
+
* Monitors both main page console AND Web Worker consoles (where Figma plugins run)
|
|
5
|
+
*/
|
|
6
|
+
import { createChildLogger } from './logger.js';
|
|
7
|
+
const logger = createChildLogger({ component: 'console-monitor' });
|
|
8
|
+
/**
|
|
9
|
+
* Console Monitor
|
|
10
|
+
* Listens to page console events and maintains a circular buffer of logs
|
|
11
|
+
* Also monitors Web Workers to capture Figma plugin console logs
|
|
12
|
+
*/
|
|
13
|
+
export class ConsoleMonitor {
|
|
14
|
+
constructor(config) {
|
|
15
|
+
this.logs = [];
|
|
16
|
+
this.isMonitoring = false;
|
|
17
|
+
this.page = null; // Supports both puppeteer-core and @cloudflare/puppeteer
|
|
18
|
+
this.workers = new Set();
|
|
19
|
+
this.lastUrl = ''; // Track the last URL to detect real navigations vs hash changes
|
|
20
|
+
this.config = config;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Start monitoring console logs on a page
|
|
24
|
+
* Accepts any puppeteer Page type (puppeteer-core or @cloudflare/puppeteer)
|
|
25
|
+
*/
|
|
26
|
+
async startMonitoring(page) {
|
|
27
|
+
if (this.isMonitoring && this.page === page) {
|
|
28
|
+
logger.info('Already monitoring this page');
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
this.page = page;
|
|
32
|
+
this.isMonitoring = true;
|
|
33
|
+
logger.info('Starting console monitoring (page + workers + frames)');
|
|
34
|
+
// DIAGNOSTIC: Log all frames on the page and add to console
|
|
35
|
+
const frames = page.frames();
|
|
36
|
+
logger.info({ frameCount: frames.length }, 'Frames detected on page');
|
|
37
|
+
// Add diagnostic marker to console logs
|
|
38
|
+
this.addLog({
|
|
39
|
+
timestamp: Date.now(),
|
|
40
|
+
level: 'info',
|
|
41
|
+
message: `[MCP DIAGNOSTIC] Monitoring started. Detected ${frames.length} frames and ${page.workers().length} workers.`,
|
|
42
|
+
args: [],
|
|
43
|
+
source: 'page',
|
|
44
|
+
});
|
|
45
|
+
for (const frame of frames) {
|
|
46
|
+
const frameUrl = frame.url();
|
|
47
|
+
const frameName = frame.name() || 'unnamed';
|
|
48
|
+
logger.info({
|
|
49
|
+
frameUrl,
|
|
50
|
+
isDetached: frame.isDetached(),
|
|
51
|
+
name: frameName
|
|
52
|
+
}, 'Frame details');
|
|
53
|
+
// Add frame detection to console logs
|
|
54
|
+
this.addLog({
|
|
55
|
+
timestamp: Date.now(),
|
|
56
|
+
level: 'info',
|
|
57
|
+
message: `[MCP DIAGNOSTIC] Frame detected: ${frameName} - ${frameUrl}`,
|
|
58
|
+
args: [],
|
|
59
|
+
source: 'page',
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
// Listen to ALL console events (includes main page, iframes, and workers)
|
|
63
|
+
page.on('console', async (msg) => {
|
|
64
|
+
try {
|
|
65
|
+
const location = msg.location();
|
|
66
|
+
const url = location?.url || 'unknown';
|
|
67
|
+
const text = msg.text();
|
|
68
|
+
const type = msg.type();
|
|
69
|
+
// DIAGNOSTIC: Log every console event with its source
|
|
70
|
+
logger.info({
|
|
71
|
+
type,
|
|
72
|
+
url,
|
|
73
|
+
textPreview: text.substring(0, 100),
|
|
74
|
+
location
|
|
75
|
+
}, 'Console event captured');
|
|
76
|
+
const entry = await this.processConsoleMessage(msg, 'page', url);
|
|
77
|
+
if (entry) {
|
|
78
|
+
this.addLog(entry);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
logger.error({ error }, 'Failed to process console message');
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
// Listen to page errors
|
|
86
|
+
page.on('pageerror', (error) => {
|
|
87
|
+
this.addLog({
|
|
88
|
+
timestamp: Date.now(),
|
|
89
|
+
level: 'error',
|
|
90
|
+
message: error.message,
|
|
91
|
+
args: [],
|
|
92
|
+
stackTrace: {
|
|
93
|
+
callFrames: error.stack
|
|
94
|
+
? error.stack.split('\n').map((line) => ({
|
|
95
|
+
functionName: line.trim(),
|
|
96
|
+
url: '',
|
|
97
|
+
lineNumber: 0,
|
|
98
|
+
columnNumber: 0,
|
|
99
|
+
}))
|
|
100
|
+
: [],
|
|
101
|
+
},
|
|
102
|
+
source: 'page',
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
// Monitor existing workers (for Figma plugin console logs)
|
|
106
|
+
const existingWorkers = page.workers();
|
|
107
|
+
logger.info({ workerCount: existingWorkers.length }, 'Found existing workers');
|
|
108
|
+
for (const worker of existingWorkers) {
|
|
109
|
+
this.attachWorkerListeners(worker);
|
|
110
|
+
}
|
|
111
|
+
// Listen for new workers being created (e.g., when plugin starts)
|
|
112
|
+
page.on('workercreated', (worker) => {
|
|
113
|
+
logger.info({ workerUrl: worker.url() }, 'New worker created');
|
|
114
|
+
this.attachWorkerListeners(worker);
|
|
115
|
+
});
|
|
116
|
+
// Listen for workers being destroyed
|
|
117
|
+
page.on('workerdestroyed', (worker) => {
|
|
118
|
+
logger.info({ workerUrl: worker.url() }, 'Worker destroyed');
|
|
119
|
+
this.workers.delete(worker);
|
|
120
|
+
});
|
|
121
|
+
// Listen for new frames being attached (e.g., when plugin UI loads)
|
|
122
|
+
page.on('frameattached', (frame) => {
|
|
123
|
+
const frameUrl = frame.url();
|
|
124
|
+
const frameName = frame.name() || 'unnamed';
|
|
125
|
+
logger.info({ frameUrl, frameName }, 'New frame attached');
|
|
126
|
+
// Add diagnostic marker for new frame
|
|
127
|
+
this.addLog({
|
|
128
|
+
timestamp: Date.now(),
|
|
129
|
+
level: 'info',
|
|
130
|
+
message: `[MCP DIAGNOSTIC] New frame attached: ${frameName} - ${frameUrl}`,
|
|
131
|
+
args: [],
|
|
132
|
+
source: 'page',
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
// Listen for frames being detached
|
|
136
|
+
page.on('framedetached', (frame) => {
|
|
137
|
+
logger.info({ frameUrl: frame.url() }, 'Frame detached');
|
|
138
|
+
});
|
|
139
|
+
// Listen for main frame navigation - clear logs when navigating to a DIFFERENT page
|
|
140
|
+
// (not just hash changes or SPA navigations within the same Figma file)
|
|
141
|
+
page.on('framenavigated', (frame) => {
|
|
142
|
+
// Only handle main frame navigation (not iframe navigations)
|
|
143
|
+
if (frame === page.mainFrame()) {
|
|
144
|
+
const frameUrl = frame.url();
|
|
145
|
+
// Extract base URL without hash/query params to detect real navigation
|
|
146
|
+
const getBaseUrl = (url) => {
|
|
147
|
+
try {
|
|
148
|
+
const urlObj = new URL(url);
|
|
149
|
+
// For Figma, consider the file ID part of the path
|
|
150
|
+
// Example: https://figma.com/design/FILE_ID/...
|
|
151
|
+
// Only clear if the file ID changes
|
|
152
|
+
return urlObj.origin + urlObj.pathname.split('?')[0].split('#')[0];
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
return url;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
const currentBaseUrl = getBaseUrl(frameUrl);
|
|
159
|
+
const previousBaseUrl = this.lastUrl ? getBaseUrl(this.lastUrl) : '';
|
|
160
|
+
// Only clear logs if we've actually navigated to a different file
|
|
161
|
+
// (not just hash changes like going from one component to another)
|
|
162
|
+
if (previousBaseUrl && currentBaseUrl !== previousBaseUrl) {
|
|
163
|
+
logger.info({
|
|
164
|
+
from: previousBaseUrl,
|
|
165
|
+
to: currentBaseUrl
|
|
166
|
+
}, 'Navigated to different file - clearing console logs');
|
|
167
|
+
// Clear old logs to prevent stale data from previous file
|
|
168
|
+
this.logs = [];
|
|
169
|
+
// Add diagnostic marker for navigation
|
|
170
|
+
this.addLog({
|
|
171
|
+
timestamp: Date.now(),
|
|
172
|
+
level: 'info',
|
|
173
|
+
message: `[MCP DIAGNOSTIC] Navigated to new file: ${frameUrl}. Console logs cleared.`,
|
|
174
|
+
args: [],
|
|
175
|
+
source: 'page',
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
// Update last URL for next comparison
|
|
179
|
+
this.lastUrl = frameUrl;
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
logger.info({
|
|
183
|
+
pageMonitoring: true,
|
|
184
|
+
workerMonitoring: true,
|
|
185
|
+
frameMonitoring: true,
|
|
186
|
+
initialWorkerCount: existingWorkers.length,
|
|
187
|
+
initialFrameCount: frames.length
|
|
188
|
+
}, 'Console monitoring started');
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Attach console listeners to a Web Worker
|
|
192
|
+
* This captures Figma plugin console logs
|
|
193
|
+
*/
|
|
194
|
+
attachWorkerListeners(worker) {
|
|
195
|
+
this.workers.add(worker);
|
|
196
|
+
const workerUrl = worker.url();
|
|
197
|
+
logger.info({ workerUrl }, 'Attaching console listener to worker');
|
|
198
|
+
// DIAGNOSTIC: Log a marker when worker listener is attached
|
|
199
|
+
this.addLog({
|
|
200
|
+
timestamp: Date.now(),
|
|
201
|
+
level: 'info',
|
|
202
|
+
message: `[MCP] Worker detected and monitored: ${workerUrl}`,
|
|
203
|
+
args: [],
|
|
204
|
+
source: 'plugin',
|
|
205
|
+
workerUrl,
|
|
206
|
+
});
|
|
207
|
+
// Listen to worker console events
|
|
208
|
+
worker.on('console', async (msg) => {
|
|
209
|
+
try {
|
|
210
|
+
logger.info({ workerUrl, type: msg.type(), text: msg.text() }, 'Worker console event received');
|
|
211
|
+
const entry = await this.processConsoleMessage(msg, 'worker', workerUrl);
|
|
212
|
+
if (entry) {
|
|
213
|
+
this.addLog(entry);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
logger.error({ error, workerUrl }, 'Failed to process worker console message');
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
// Worker doesn't have pageerror, but console.error will be captured above
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Process console message from Puppeteer
|
|
224
|
+
* @param msg - Console message from page or worker
|
|
225
|
+
* @param context - Where the message came from ('page' or 'worker')
|
|
226
|
+
* @param workerUrl - URL of the worker (if context is 'worker')
|
|
227
|
+
*/
|
|
228
|
+
async processConsoleMessage(msg, context, workerUrl) {
|
|
229
|
+
const level = msg.type();
|
|
230
|
+
// Filter by configured levels
|
|
231
|
+
if (this.config.filterLevels.length > 0 &&
|
|
232
|
+
!this.config.filterLevels.includes(level)) {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
try {
|
|
236
|
+
// Extract message text
|
|
237
|
+
const message = msg.text();
|
|
238
|
+
// Extract arguments (with truncation)
|
|
239
|
+
const args = await Promise.all(msg.args().map(async (arg) => {
|
|
240
|
+
try {
|
|
241
|
+
const jsonValue = await arg.jsonValue();
|
|
242
|
+
return this.truncateValue(jsonValue);
|
|
243
|
+
}
|
|
244
|
+
catch {
|
|
245
|
+
return String(arg);
|
|
246
|
+
}
|
|
247
|
+
}));
|
|
248
|
+
// Determine source based on context
|
|
249
|
+
let source;
|
|
250
|
+
if (context === 'worker') {
|
|
251
|
+
// Workers are where Figma plugins run
|
|
252
|
+
source = 'plugin';
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
// Page console - determine if plugin or figma
|
|
256
|
+
const location = msg.location();
|
|
257
|
+
source = this.determineSource(location?.url);
|
|
258
|
+
}
|
|
259
|
+
const entry = {
|
|
260
|
+
timestamp: Date.now(),
|
|
261
|
+
level,
|
|
262
|
+
message: this.truncateString(message),
|
|
263
|
+
args,
|
|
264
|
+
source,
|
|
265
|
+
};
|
|
266
|
+
// Add worker URL metadata for debugging
|
|
267
|
+
if (workerUrl && context === 'worker') {
|
|
268
|
+
entry.workerUrl = workerUrl;
|
|
269
|
+
}
|
|
270
|
+
// Add stack trace for errors
|
|
271
|
+
if (level === 'error' && msg.stackTrace) {
|
|
272
|
+
entry.stackTrace = {
|
|
273
|
+
callFrames: msg.stackTrace().callFrames || [],
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
return entry;
|
|
277
|
+
}
|
|
278
|
+
catch (error) {
|
|
279
|
+
logger.error({ error, context, workerUrl }, 'Failed to extract console message details');
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Determine if log is from plugin or Figma based on URL
|
|
285
|
+
*/
|
|
286
|
+
determineSource(url) {
|
|
287
|
+
if (!url)
|
|
288
|
+
return 'unknown';
|
|
289
|
+
// Check for plugin-related URLs
|
|
290
|
+
// Plugins might run in:
|
|
291
|
+
// - iframes with plugin-specific URLs
|
|
292
|
+
// - blob: URLs created by the plugin
|
|
293
|
+
// - chrome-extension: URLs (for dev mode)
|
|
294
|
+
// - any URL containing "plugin"
|
|
295
|
+
if (url.includes('plugin') ||
|
|
296
|
+
url.includes('iframe') ||
|
|
297
|
+
url.startsWith('blob:') ||
|
|
298
|
+
url.startsWith('chrome-extension:') ||
|
|
299
|
+
url.includes('figma.com/plugin') ||
|
|
300
|
+
url.includes('/plugin-')) {
|
|
301
|
+
return 'plugin';
|
|
302
|
+
}
|
|
303
|
+
// Main Figma application
|
|
304
|
+
if (url.includes('figma.com')) {
|
|
305
|
+
return 'figma';
|
|
306
|
+
}
|
|
307
|
+
return 'unknown';
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Add log to circular buffer
|
|
311
|
+
*/
|
|
312
|
+
addLog(entry) {
|
|
313
|
+
this.logs.push(entry);
|
|
314
|
+
// Maintain buffer size
|
|
315
|
+
if (this.logs.length > this.config.bufferSize) {
|
|
316
|
+
this.logs.shift();
|
|
317
|
+
}
|
|
318
|
+
logger.debug({ level: entry.level, source: entry.source }, 'Log captured');
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Truncate string to max length
|
|
322
|
+
*/
|
|
323
|
+
truncateString(str) {
|
|
324
|
+
const maxLength = this.config.truncation.maxStringLength;
|
|
325
|
+
if (str.length <= maxLength) {
|
|
326
|
+
return str;
|
|
327
|
+
}
|
|
328
|
+
return str.substring(0, maxLength) + '... (truncated)';
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Truncate value (string, array, object) intelligently
|
|
332
|
+
* Based on AgentDesk pattern to prevent context overflow
|
|
333
|
+
*/
|
|
334
|
+
truncateValue(value, depth = 0) {
|
|
335
|
+
const { maxStringLength, maxArrayLength, maxObjectDepth } = this.config.truncation;
|
|
336
|
+
// Max depth reached
|
|
337
|
+
if (depth >= maxObjectDepth) {
|
|
338
|
+
return '[Max depth reached]';
|
|
339
|
+
}
|
|
340
|
+
// Handle null/undefined
|
|
341
|
+
if (value === null || value === undefined) {
|
|
342
|
+
return value;
|
|
343
|
+
}
|
|
344
|
+
// Handle strings
|
|
345
|
+
if (typeof value === 'string') {
|
|
346
|
+
return this.truncateString(value);
|
|
347
|
+
}
|
|
348
|
+
// Handle arrays
|
|
349
|
+
if (Array.isArray(value)) {
|
|
350
|
+
const truncated = value.slice(0, maxArrayLength).map((item) => this.truncateValue(item, depth + 1));
|
|
351
|
+
if (value.length > maxArrayLength) {
|
|
352
|
+
truncated.push(`... (${value.length - maxArrayLength} more items)`);
|
|
353
|
+
}
|
|
354
|
+
return truncated;
|
|
355
|
+
}
|
|
356
|
+
// Handle objects
|
|
357
|
+
if (typeof value === 'object') {
|
|
358
|
+
const result = {};
|
|
359
|
+
let count = 0;
|
|
360
|
+
for (const [key, val] of Object.entries(value)) {
|
|
361
|
+
if (count >= 10) {
|
|
362
|
+
// Limit object properties
|
|
363
|
+
result['...'] = '(more properties)';
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
result[key] = this.truncateValue(val, depth + 1);
|
|
367
|
+
count++;
|
|
368
|
+
}
|
|
369
|
+
return result;
|
|
370
|
+
}
|
|
371
|
+
// Primitives (number, boolean, etc.)
|
|
372
|
+
return value;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Get logs with optional filtering
|
|
376
|
+
*/
|
|
377
|
+
getLogs(options) {
|
|
378
|
+
let filtered = [...this.logs];
|
|
379
|
+
// Filter by timestamp
|
|
380
|
+
if (options?.since) {
|
|
381
|
+
filtered = filtered.filter((log) => log.timestamp >= options.since);
|
|
382
|
+
}
|
|
383
|
+
// Filter by level
|
|
384
|
+
if (options?.level && options.level !== 'all') {
|
|
385
|
+
filtered = filtered.filter((log) => log.level === options.level);
|
|
386
|
+
}
|
|
387
|
+
// Limit count (get most recent)
|
|
388
|
+
if (options?.count) {
|
|
389
|
+
filtered = filtered.slice(-options.count);
|
|
390
|
+
}
|
|
391
|
+
return filtered;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Clear log buffer
|
|
395
|
+
*/
|
|
396
|
+
clear() {
|
|
397
|
+
const count = this.logs.length;
|
|
398
|
+
this.logs = [];
|
|
399
|
+
logger.info({ clearedCount: count }, 'Console buffer cleared');
|
|
400
|
+
return count;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Stop monitoring
|
|
404
|
+
*/
|
|
405
|
+
stopMonitoring() {
|
|
406
|
+
if (!this.isMonitoring) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
this.isMonitoring = false;
|
|
410
|
+
this.page = null;
|
|
411
|
+
this.lastUrl = ''; // Clear last URL to prevent stale comparisons after restart
|
|
412
|
+
logger.info('Console monitoring stopped');
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Get monitoring status
|
|
416
|
+
*/
|
|
417
|
+
getStatus() {
|
|
418
|
+
return {
|
|
419
|
+
isMonitoring: this.isMonitoring,
|
|
420
|
+
logCount: this.logs.length,
|
|
421
|
+
bufferSize: this.config.bufferSize,
|
|
422
|
+
workerCount: this.workers.size,
|
|
423
|
+
oldestTimestamp: this.logs[0]?.timestamp,
|
|
424
|
+
newestTimestamp: this.logs[this.logs.length - 1]?.timestamp,
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
//# sourceMappingURL=console-monitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console-monitor.js","sourceRoot":"","sources":["../../src/core/console-monitor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAO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AM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,SAAS;QACR,OAAO;YACN,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM;YAC1B,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU;YAClC,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;YAC9B,eAAe,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,SAAS;YACxC,eAAe,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,SAAS;SAC3D,CAAC;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Design-Code Parity Checker & Documentation Generator
|
|
3
|
+
* MCP tools for comparing Figma design specs with code-side data
|
|
4
|
+
* and generating platform-agnostic component documentation.
|
|
5
|
+
*/
|
|
6
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
7
|
+
import type { FigmaAPI } from "./figma-api.js";
|
|
8
|
+
import type { CompanyDocsContentEntry } from "./types/design-code.js";
|
|
9
|
+
/** Convert Figma RGBA (0-1 floats) to hex string */
|
|
10
|
+
export declare function figmaRGBAToHex(color: {
|
|
11
|
+
r: number;
|
|
12
|
+
g: number;
|
|
13
|
+
b: number;
|
|
14
|
+
a?: number;
|
|
15
|
+
}): string;
|
|
16
|
+
/** Normalize a color string for comparison (uppercase hex without alpha if fully opaque) */
|
|
17
|
+
export declare function normalizeColor(color: string): string;
|
|
18
|
+
/** Compare numeric values with a tolerance */
|
|
19
|
+
export declare function numericClose(a: number, b: number, tolerance?: number): boolean;
|
|
20
|
+
/** Calculate parity score from discrepancy counts */
|
|
21
|
+
export declare function calculateParityScore(critical: number, major: number, minor: number, info: number): number;
|
|
22
|
+
/** Split markdown by H2 headers for platforms that need chunking */
|
|
23
|
+
export declare function chunkMarkdownByHeaders(markdown: string): Array<{
|
|
24
|
+
heading: string;
|
|
25
|
+
content: string;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Clean a raw Figma variant name like "Type=Image, Size=12" into "Image / 12".
|
|
29
|
+
* Extracts just the values from "Key=Value" pairs, joined by " / ".
|
|
30
|
+
*/
|
|
31
|
+
export declare function cleanVariantName(rawName: string): string;
|
|
32
|
+
/** Structured content extracted from a Figma component description */
|
|
33
|
+
interface ParsedDescription {
|
|
34
|
+
/** The main overview/summary text */
|
|
35
|
+
overview: string;
|
|
36
|
+
/** "When to Use" bullet points */
|
|
37
|
+
whenToUse: string[];
|
|
38
|
+
/** "When NOT to Use" bullet points */
|
|
39
|
+
whenNotToUse: string[];
|
|
40
|
+
/** Content guidelines sections (title text, description text, etc.) */
|
|
41
|
+
contentGuidelines: Array<{
|
|
42
|
+
heading: string;
|
|
43
|
+
items: string[];
|
|
44
|
+
}>;
|
|
45
|
+
/** Accessibility notes */
|
|
46
|
+
accessibilityNotes: string[];
|
|
47
|
+
/** Any remaining unclassified content */
|
|
48
|
+
additionalNotes: string[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Parse a Figma component description into structured sections.
|
|
52
|
+
* Handles markdown-formatted descriptions with headers, bullet points, etc.
|
|
53
|
+
*/
|
|
54
|
+
export declare function parseComponentDescription(description: string): ParsedDescription;
|
|
55
|
+
/** Color data collected from a specific variant */
|
|
56
|
+
interface VariantColorData {
|
|
57
|
+
variantName: string;
|
|
58
|
+
fills: Array<{
|
|
59
|
+
hex: string;
|
|
60
|
+
nodeName: string;
|
|
61
|
+
variableId?: string;
|
|
62
|
+
variableName?: string;
|
|
63
|
+
}>;
|
|
64
|
+
strokes: Array<{
|
|
65
|
+
hex: string;
|
|
66
|
+
nodeName: string;
|
|
67
|
+
variableId?: string;
|
|
68
|
+
variableName?: string;
|
|
69
|
+
}>;
|
|
70
|
+
textColors: Array<{
|
|
71
|
+
hex: string;
|
|
72
|
+
nodeName: string;
|
|
73
|
+
variableId?: string;
|
|
74
|
+
variableName?: string;
|
|
75
|
+
}>;
|
|
76
|
+
icons: Array<{
|
|
77
|
+
name: string;
|
|
78
|
+
type: string;
|
|
79
|
+
}>;
|
|
80
|
+
}
|
|
81
|
+
/** Typography data from a text node */
|
|
82
|
+
interface TextStyleData {
|
|
83
|
+
nodeName: string;
|
|
84
|
+
fontFamily: string;
|
|
85
|
+
fontWeight: number;
|
|
86
|
+
fontWeightName: string;
|
|
87
|
+
fontSize: number;
|
|
88
|
+
lineHeight: number;
|
|
89
|
+
letterSpacing: number;
|
|
90
|
+
variableBindings?: Record<string, string>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Collect color data from all variants in a COMPONENT_SET.
|
|
94
|
+
* For single COMPONENTs, returns data for just that component.
|
|
95
|
+
*/
|
|
96
|
+
export declare function collectAllVariantData(node: any, varNameMap: Map<string, string>): VariantColorData[];
|
|
97
|
+
/**
|
|
98
|
+
* Collect typography data from all text nodes in a component tree.
|
|
99
|
+
*/
|
|
100
|
+
export declare function collectTypographyData(node: any, depth?: number, maxDepth?: number): TextStyleData[];
|
|
101
|
+
/**
|
|
102
|
+
* Build an anatomy tree representation from a Figma node structure.
|
|
103
|
+
* Returns a formatted string showing the component's nested structure.
|
|
104
|
+
*/
|
|
105
|
+
export declare function buildAnatomyTree(node: any, depth?: number, maxDepth?: number): string;
|
|
106
|
+
/**
|
|
107
|
+
* Resolve the node to use for visual/spacing/typography comparisons.
|
|
108
|
+
* COMPONENT_SET frames have container-level styling (Figma's purple dashed stroke,
|
|
109
|
+
* default cornerRadius: 5, organizational padding) that are NOT actual design specs.
|
|
110
|
+
* The real design properties live on the child COMPONENT variants.
|
|
111
|
+
* Returns the default variant (first child) for COMPONENT_SET, or the node itself otherwise.
|
|
112
|
+
*/
|
|
113
|
+
export declare function resolveVisualNode(node: any): any;
|
|
114
|
+
/** Detect if a node name is a Figma variant pattern like "Variant=Default, State=Hover, Size=lg" */
|
|
115
|
+
export declare function isVariantName(name: string): boolean;
|
|
116
|
+
/** Sanitize a component name for use as a file path */
|
|
117
|
+
export declare function sanitizeComponentName(name: string): string;
|
|
118
|
+
/** Convert generated markdown into a CompanyDocsMCP-compatible content entry */
|
|
119
|
+
export declare function toCompanyDocsEntry(markdown: string, componentName: string, figmaUrl: string, systemName?: string): CompanyDocsContentEntry;
|
|
120
|
+
export declare function registerDesignCodeTools(server: McpServer, getFigmaAPI: () => Promise<FigmaAPI>, getCurrentUrl: () => string | null, variablesCache?: Map<string, {
|
|
121
|
+
data: any;
|
|
122
|
+
timestamp: number;
|
|
123
|
+
}>, options?: {
|
|
124
|
+
isRemoteMode?: boolean;
|
|
125
|
+
}, getDesktopConnector?: () => Promise<any>): void;
|
|
126
|
+
export {};
|
|
127
|
+
//# sourceMappingURL=design-code-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"design-code-tools.d.ts","sourceRoot":"","sources":["../../src/core/design-code-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAK/C,OAAO,KAAK,EAUX,uBAAuB,EACvB,MAAM,wBAAwB,CAAC;AAShC,oDAAoD;AACpD,wBAAgB,cAAc,CAAC,KAAK,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAU7F;AAED,4FAA4F;AAC5F,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAWpD;AAED,8CAA8C;AAC9C,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,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