diff --git a/src/index.ts b/src/index.ts index a2d6284..480b313 100644 --- a/src/index.ts +++ b/src/index.ts @@ -26,7 +26,7 @@ export function VueMcp(options: VueMcpOptions = {}): Plugin { mcpServer = (vite: ViteDevServer, ctx: VueMcpContext) => import('./server').then(m => m.createMcpServerDefault(options, vite, ctx)), } = options - const cursorMcpOptions = typeof updateCursorMcpJson == 'boolean' + const cursorMcpOptions = typeof updateCursorMcpJson === 'boolean' ? { enabled: updateCursorMcpJson } : updateCursorMcpJson @@ -44,7 +44,7 @@ export function VueMcp(options: VueMcpOptions = {}): Plugin { async configureServer(vite) { const rpc = createServerRpc(ctx) - const rpcServer = createRPCServer( + const rpcServer = createRPCServer( 'vite-plugin-vue-mcp', vite.ws, rpc, @@ -86,7 +86,7 @@ export function VueMcp(options: VueMcpOptions = {}): Plugin { if (importee === vueMcpOptionsImportee) { return resolvedVueMcpOptions } - else if (importee.startsWith('virtual:vue-mcp-path:')) { + if (importee.startsWith('virtual:vue-mcp-path:')) { const resolved = importee.replace('virtual:vue-mcp-path:', `${vueMcpPath}/`) return `${resolved}${vueMcpResourceSymbol}` } @@ -105,7 +105,8 @@ export function VueMcp(options: VueMcpOptions = {}): Plugin { && ( (typeof appendTo === 'string' && filename.endsWith(appendTo)) || (appendTo instanceof RegExp && appendTo.test(filename)))) { - code = `import 'virtual:vue-mcp-path:overlay.js';\n${code}` + const modifiedCode = `import 'virtual:vue-mcp-path:overlay.js';\n${code}` + return modifiedCode } return code diff --git a/src/overlay.js b/src/overlay.js index d430c40..da16b02 100644 --- a/src/overlay.js +++ b/src/overlay.js @@ -20,7 +20,8 @@ function flattenChildren(node) { result.push(node) if (Array.isArray(node.children)) { - node.children.forEach(child => traverse(child)) + for (const child of node.children) + traverse(child) } } diff --git a/src/rpc.ts b/src/rpc.ts index 7b5f754..4a2e125 100644 --- a/src/rpc.ts +++ b/src/rpc.ts @@ -27,5 +27,9 @@ export function createServerRpc(ctx: VueMcpContext): RpcFunctions { onPiniaInfoUpdated: (event: string, data: string) => { ctx.hooks.callHook(event, data) }, + // edit component state + editComponentState: (options: { componentName: string, path: string[], value: string, valueType: string }) => {}, + // highlight component + highlightComponent: (options: { componentName: string }) => {}, } } diff --git a/src/types.ts b/src/types.ts index 4bb28ad..52678c0 100644 --- a/src/types.ts +++ b/src/types.ts @@ -54,7 +54,7 @@ export interface VueMcpOptions { * Setup the MCP server, this is called when the MCP server is created * You may also return a new MCP server to replace the default one */ - mcpServerSetup?: (server: McpServer, viteServer: ViteDevServer) => Awaitable + mcpServerSetup?: (server: McpServer, viteServer: ViteDevServer) => Awaitable /** * The path to the MCP server, default is `/__mcp`